From 8036bdd7d87400c5db0cb423fb03fc4004898365 Mon Sep 17 00:00:00 2001 From: Declan Kelly Date: Sun, 20 Nov 2022 21:46:35 -0800 Subject: [PATCH] Update CI workflows to run multiple versions of rust **Description** - Update CI to run multiple versions of rust: stable, beta, nightly, and 1.62 (as MSRV) - Update documentation to use `+nightly` when required, assuming a stable-preferred development environment. - In CI when running under the `nightly` version of rust, enable the `nightly` cargo feature when building and running tests - Add a new job that runs miri tests **Motivation** This change is taking advantage of the completion of issue #20, now that we don't strictly require any nightly unstable features. This allows us to test on multiple versions of rust. **Testing Done** None --- .github/workflows/documentation.yml | 15 ++---- .github/workflows/rust-ci.yml | 71 +++++++++++++++++------------ README.md | 6 +-- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index c36722b7..02e58245 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -9,26 +9,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install nightly toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true + uses: dtolnay/rust-toolchain@nightly - name: Build Documentation - uses: actions-rs/cargo@v1 - with: - command: doc - args: --workspace --no-deps + run: cargo doc --workspace --no-deps --all-features - name: Prepare to publish run: ./scripts/prep_documentation.sh - name: Publish to Github Pages - uses: JamesIves/github-pages-deploy-action@v4.2.3 + uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: target/doc diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index bc192df5..5b9a2f5e 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -11,64 +11,79 @@ env: jobs: test: + strategy: + fail-fast: true + matrix: + rust: + - nightly + - beta + - stable + - 1.62.0 # MSRV for the crate + runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install nightly toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: nightly - override: true + toolchain: ${{matrix.rust}} - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --examples --tests --benches + if: ${{ matrix.rust != "nightly" }} + run: cargo build --all-targets + + - name: Build with 'nightly' feature + if: ${{ matrix.rust == "nightly" }} + run: cargo build --all-targets --features nightly - name: Test - uses: actions-rs/cargo@v1 - with: - command: test + if: ${{ matrix.rust != "nightly" }} + run: cargo test + + - name: Test with 'nightly' feature + if: ${{ matrix.rust == "nightly" }} + run: cargo test --features nightly format: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install nightly toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@nightly with: - profile: minimal - toolchain: nightly - override: true components: rustfmt - name: Check format - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt -- --check lint: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install nightly toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@nightly with: - profile: minimal - toolchain: nightly - override: true components: clippy - name: Lint - uses: actions-rs/clippy-check@v1 + run: cargo clippy --all-features + + miri: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Install nightly toolchain + uses: dtolnay/rust-toolchain@nightly with: - token: ${{ secrets.GITHUB_TOKEN }} + components: miri + + - name: Run miri tests + run: cargo miri test diff --git a/README.md b/README.md index 316a28a5..f5e6b68e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Currently we're using some specific crates (`sptr` and in the future back to `core::ptr::*`) to ensure that we're compatible with [Strict Provenance][sp-issue]. The following `MIRIFLAGS` setup should enable checking to make sure that we're compatible. ```bash -MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" cargo miri test +MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" cargo +nightly miri test ``` I think this is useful because we're doing some pointer times with our tagged pointers implementation, mutating the contents of the pointer to store bits of data. @@ -21,7 +21,7 @@ I think this is useful because we're doing some pointer times with our tagged po To run the fuzzer I use the command: ```bash -cargo fuzz run -j 8 -s address fuzz_raw_api -- -max_len=32768 -max_total_time=3600 && cargo fuzz cmin fuzz_raw_api +cargo +nightly fuzz run -j 8 -s address fuzz_raw_api -- -max_len=32768 -max_total_time=3600 && cargo +nightly fuzz cmin fuzz_raw_api ``` This will run the fuzzer for a total of 3600 seconds (1 hour), using 8 jobs (half of the total number of cores on my dev box), and using the address sanitizer. The `cmin` command is used to compact the corpus after generating new entries. @@ -33,7 +33,7 @@ To generate coverage reports from fuzzing corpus: ```bash # replace with own triple as required TARGET_TRIPLE="x86_64-unknown-linux-gnu" -cargo fuzz coverage fuzz_raw_api && cargo cov -- show fuzz/target/"$TARGET_TRIPLE"/release/fuzz_raw_api \ +cargo +nightly fuzz coverage fuzz_raw_api && cargo cov -- show fuzz/target/"$TARGET_TRIPLE"/release/fuzz_raw_api \ --format=html \ -instr-profile=fuzz/coverage/fuzz_raw_api/coverage.profdata \ > index.html