From 6acde94931c5a7ac0f8b2abb38a91139d89c0675 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 4 Oct 2020 22:01:10 +0700 Subject: [PATCH] Add a working github actions template --- .appveyor.yml | 7 +++-- .github/workflows/ci.yml | 60 +++++++++++++++++++++++++++++++++++++++- .travis.yml | 9 ++++-- README.md | 8 +++++- ci.sh | 46 ++++++++++++++++++------------ 5 files changed, 105 insertions(+), 25 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 5cb5267a6da5..82c668f0e75d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,7 +3,7 @@ environment: global: PROJECT_NAME: miri matrix: - - TARGET: i686-pc-windows-msvc + - HOST_TARGET: i686-pc-windows-msvc matrix: fast_finish: true # Immediately finish build once one of the jobs fails. cache: @@ -23,7 +23,7 @@ install: # Install Rust. We use the "stable" toolchain for better caching, it is just used to build `rustup-toolchain-install-master`. # But we also need to take into account that the build cache might have a different, outdated default. - curl -sSf --retry 3 -o rustup-init.exe https://win.rustup.rs/ -- rustup-init.exe -y --default-host %TARGET% --default-toolchain none --profile minimal +- rustup-init.exe -y --default-host %HOST_TARGET% --default-toolchain none --profile minimal - set PATH=%USERPROFILE%\.cargo\bin;%PATH% - rustup default stable - rustup toolchain uninstall beta nightly @@ -36,7 +36,8 @@ install: - cargo --version test_script: -- set PYTHON=C:\msys64\mingw64\bin\python3.exe +# Add python3 path: https://www.appveyor.com/docs/windows-images-software/#python +- set PATH=C:\Python35-x64;%PATH% - bash ci.sh after_test: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e7d6e1cd616..b5ef3d861ead 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,13 +11,14 @@ on: - 'master' schedule: # Use to conveniently edit cron schedule. - - cron: "0 7 * * *" # At 07:00 UTC every day. + - cron: '0 7 * * *' # At 07:00 UTC every day. jobs: build: runs-on: ${{ matrix.os }} env: RUST_BACKTRACE: 1 + HOST_TARGET: ${{ matrix.host_target }} strategy: matrix: build: [linux64, macos, win32] @@ -34,6 +35,63 @@ jobs: steps: - uses: actions/checkout@v2 + # We install gnu-tar because BSD tar is buggy on macOS builders of GHA. + # See . + - name: Install GNU tar + if: runner.os == 'macOS' + run: | + brew install gnu-tar + echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH + + # Cache the global cargo directory, but NOT the local `target` directory which + # we cannot reuse anyway when the nightly changes (and it grows quite large + # over time). + - name: Add cache for cargo + uses: actions/cache@v2 + with: + path: | + # Taken from . + ~/.cargo/bin + ~/.cargo/registry/index + ~/.cargo/registry/cache + ~/.cargo/git/db + # contains package information of crates installed via `cargo install`. + ~/.cargo/.crates.toml + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo + + - name: Install rustup-toolchain-install-master and xargo + run: | + cargo install rustup-toolchain-install-master + cargo install xargo + shell: bash + + - name: Install "master" toolchain + run: | + if [[ ${{ github.event_name }} == 'schedule' ]]; then + RUSTC_HASH=$(git ls-remote https://github.com/rust-lang/rust.git master | awk '{print $1}') + else + RUSTC_HASH=$(< rust-version) + fi + rustup-toolchain-install-master \ + -f \ + -n master "$RUSTC_HASH" \ + -c rust-src \ + -c rustc-dev \ + -c llvm-tools \ + --host ${{ matrix.host_target }} + rustup default master + shell: bash + + - name: Show Rust version + run: | + rustup show + rustc -Vv + cargo -V + + - name: Test + run: bash ./ci.sh + # These jobs doesn't actually test anything, but they're only used to tell # bors the build completed, as there is no practical way to detect when a # workflow is successful listening to webhooks only. diff --git a/.travis.yml b/.travis.yml index fcef17b124dd..86dcf78435b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,10 @@ language: generic -os: -- linux -- osx +jobs: + include: + - os: linux + env: HOST_TARGET=x86_64-unknown-linux-gnu + - os: osx + env: HOST_TARGET=x86_64-apple-darwin dist: xenial cache: # Cache the global cargo directory, but NOT the local `target` directory which diff --git a/README.md b/README.md index 2b015104828e..418b7a1ee301 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ -# Miri [![Build Status](https://travis-ci.com/rust-lang/miri.svg?branch=master)](https://travis-ci.com/rust-lang/miri) [![Windows build status](https://ci.appveyor.com/api/projects/status/github/rust-lang/miri?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/miri) +# Miri +[![Actions build status][actions-badge]][actions-url] +[![Travis build status](https://travis-ci.com/rust-lang/miri.svg?branch=master)](https://travis-ci.com/rust-lang/miri) +[![Appveyor Windows build status](https://ci.appveyor.com/api/projects/status/github/rust-lang/miri?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/miri) + +[actions-badge]: https://github.com/rust-lang/miri/workflows/CI/badge.svg?branch=master +[actions-url]: https://github.com/rust-lang/miri/actions An experimental interpreter for [Rust][rust]'s [mid-level intermediate representation][mir] (MIR). It can run binaries and diff --git a/ci.sh b/ci.sh index a6daa8064530..8827c90d3bdf 100755 --- a/ci.sh +++ b/ci.sh @@ -23,32 +23,44 @@ function run_tests { fi ./miri test --locked - if ! [ -n "${MIRI_TEST_TARGET+exists}" ]; then + if [ -z "${MIRI_TEST_TARGET+exists}" ]; then # Only for host architecture: tests with MIR optimizations #FIXME: Only testing opt level 1 due to . MIRIFLAGS="-Z mir-opt-level=1" ./miri test --locked fi + + # On Windows, there is always "python", not "python3" or "python2". + if command -v python3 > /dev/null; then + PYTHON=python3 + else + PYTHON=python + fi + # "miri test" has built the sysroot for us, now this should pass without # any interactive questions. - ${PYTHON:-python3} test-cargo-miri/run-test.py - + ${PYTHON} test-cargo-miri/run-test.py echo } # host run_tests -if [ "${TRAVIS_OS_NAME:-}" == linux ]; then - MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests - MIRI_TEST_TARGET=x86_64-apple-darwin run_tests - MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests -elif [ "${TRAVIS_OS_NAME:-}" == osx ]; then - MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture - MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests -elif [ "${CI_WINDOWS:-}" == True ]; then - MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests - MIRI_TEST_TARGET=x86_64-apple-darwin run_tests -else - echo "FATAL: unknown CI platform" - exit 1 -fi +case $HOST_TARGET in + x86_64-unknown-linux-gnu) + MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=x86_64-apple-darwin run_tests + MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests + ;; + x86_64-apple-darwin) + MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture + MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests + ;; + i686-pc-windows-msvc) + MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=x86_64-apple-darwin run_tests + ;; + *) + echo "FATAL: unknown OS" + exit 1 + ;; +esac