Skip to content

Commit

Permalink
Update CI workflows to run multiple versions of rust
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
declanvk committed Nov 21, 2022
1 parent 655e634 commit 8036bdd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 42 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 43 additions & 28 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 8036bdd

Please sign in to comment.