Skip to content

Rust CI

Rust CI #449

Workflow file for this run

name: Rust CI
on:
push:
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
pull_request:
# Run every Saturday night
schedule:
- cron: "0 4 * * 6"
jobs:
clippy_check:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
rust: ["stable"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: clippy
- name: Install SARIF tools
run: cargo install --git https://github.com/jonasbb/sarif-rs clippy-sarif
- name: clippy "No Default Features" (${{ matrix.os }} / ${{ matrix.rust }})
run: cargo clippy
--quiet
--workspace
--no-default-features
--all-targets
--message-format=json-diagnostic-rendered-ansi |
clippy-sarif --emit-rendered-diagnostics >./rust-clippy-no-default-features.sarif
continue-on-error: true
- name: clippy "Default" (${{ matrix.os }} / ${{ matrix.rust }})
run: cargo clippy
--quiet
--workspace
--all-targets
--message-format=json-diagnostic-rendered-ansi |
clippy-sarif --emit-rendered-diagnostics >./rust-clippy-default.sarif
continue-on-error: true
- name: clippy "All Features" (${{ matrix.os }} / ${{ matrix.rust }})
run: cargo clippy
--quiet
--workspace
--all-features
--all-targets
--message-format=json-diagnostic-rendered-ansi |
clippy-sarif --emit-rendered-diagnostics >./rust-clippy-all-features.sarif
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-no-default-features.sarif
category: clippy-no-default-features
wait-for-processing: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-default.sarif
category: clippy-default-features
wait-for-processing: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-all-features.sarif
category: clippy-all-features
wait-for-processing: true
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
build_and_test:
name: Build and Test
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
rust: ["stable", "nightly"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
# The tests are split into build and run steps, to see the time impact of each
# cargo test --all-targets does NOT run doctests
# since doctests are important this should not be added
# https://github.com/rust-lang/cargo/issues/6669
- name: "Test Build (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-default-features --no-run
- name: "Test Run (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-default-features --no-fail-fast
- name: "Test Build (Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-run
- name: "Test Run (Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-fail-fast
- name: "Test Build (All Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --all-features --no-run
- name: "Test Run (All Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --all-features --no-fail-fast
# Added to summarize the matrix (otherwise we would need to list every single
# job in bors.toml)
# https://forum.bors.tech/t/bors-with-github-workflows/426
tests-result:
name: Tests result
if: always()
needs:
- rustfmt
- clippy_check
- build_and_test
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
if: "needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success'"
run: exit 0
- name: Mark the job as a failure
if: "!(needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success')"
run: exit 1