add default environment #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
name: ci | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
RUST_BACKTRACE: 1 | |
# Pin the nightly toolchain to prevent breakage. | |
# This should be occasionally updated. | |
RUST_NIGHTLY_TOOLCHAIN: nightly-2022-04-12 | |
jobs: | |
env: | |
runs-on: ubuntu-latest | |
outputs: | |
rust-versions: ${{ steps.definitions.outputs.versions }} | |
msrv: ${{ steps.definitions.outputs.msrv }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Evaluate definitions | |
id: definitions | |
run: | | |
export MSRV=$(cat rust-toolchain | awk '{$1=$1};1') | |
echo "::set-output name=msrv::$MSRV" | |
export RAW_VERSIONS="stable beta $RUST_NIGHTLY_TOOLCHAIN $MSRV" | |
export VERSIONS=$(echo $RAW_VERSIONS | jq -scR 'rtrimstr("\n")|split(" ")|.') | |
echo "::set-output name=versions::$VERSIONS" | |
rustfmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }} | |
profile: minimal | |
override: true | |
components: rustfmt | |
- name: Run cargo fmt | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
clippy: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: [stable, beta] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions-rs/[email protected] | |
id: toolchain | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
profile: minimal | |
override: true | |
components: clippy | |
- uses: camshaft/rust-cache@v1 | |
# TODO translate json reports to in-action warnings | |
- name: Run cargo clippy | |
uses: actions-rs/[email protected] | |
with: | |
command: clippy | |
args: --all-features --all-targets -- -D warnings | |
udeps: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions-rs/[email protected] | |
id: toolchain | |
with: | |
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }} | |
profile: minimal | |
override: true | |
- uses: camshaft/rust-cache@v1 | |
- uses: camshaft/install@v1 | |
with: | |
crate: cargo-udeps | |
- name: Run cargo udeps | |
run: cargo udeps --workspace --all-targets | |
env: | |
RUSTC_WRAPPER: "" | |
test: | |
runs-on: ${{ matrix.os }} | |
needs: env | |
strategy: | |
matrix: | |
rust: ${{ fromJson(needs.env.outputs.rust-versions) }} | |
os: [ubuntu-latest, macOS-latest, windows-latest] | |
steps: | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
toolchain: ${{ matrix.rust }} | |
override: true | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- uses: camshaft/rust-cache@v1 | |
with: | |
key: ${{ matrix.target }} | |
- name: Run cargo test | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
miri: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
crate: [bach] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions-rs/[email protected] | |
id: toolchain | |
with: | |
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }} | |
override: true | |
components: miri, rust-src | |
- uses: camshaft/rust-cache@v1 | |
with: | |
key: ${{ matrix.crate }} | |
- name: ${{ matrix.crate }} | |
# Disabling capture speeds up miri execution: https://github.com/rust-lang/miri/issues/1780#issuecomment-830664528 | |
run: cd ${{ matrix.crate }} && cargo miri test -- --nocapture | |
env: | |
# needed to read corpus files from filesystem | |
MIRIFLAGS: -Zmiri-disable-isolation |