Skip to content

Rust CI

Rust CI #220

Workflow file for this run

# Inspired by:
# systemd/zram-generator CI - https://github.com/systemd/zram-generator/blob/main/.github/workflows/ci.yml
# aufover/aufover-benchmark CI - https://github.com/aufover/aufover-benchmark/blob/main/.github/workflows/fedora.yml
---
name: Rust CI
on:
pull_request:
push:
branches: [ main ]
# Every Monday at 04:00 AM
schedule:
- cron: 0 4 * * 1
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
test:
name: "[ Fedora ${{ matrix.fedora }} ] - Cargo Test ${{ matrix.coverage == true && '& Coverage ' || '' }}(rust ${{ matrix.rust }})"
strategy:
fail-fast: false
matrix:
rust: [ stable, nightly ]
fedora: [ 39, 40, rawhide ]
include:
- rust: nightly
fedora: 39
coverage: true
runs-on: ubuntu-latest
container:
image: fedora:${{ matrix.fedora }}
# Docker seccomp policy incompatible with glibc 2.34
# https://github.com/actions/runner-images/issues/3812
options: --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v4
- name: Install rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Install Development Tools packages
# required to be able to build rust packages: Development Tools
# https://trendoceans.com/fix-linker-cc-not-found/
run: |
sudo dnf groupinstall -y "Development Tools" || \
sudo dnf5 group install -y development-tools || \
sudo dnf5 group list
- name: Test
if: ${{ matrix.coverage != true }}
run: |
cargo test --all-features --no-fail-fast
- name: Test + Coverage
# -Z flag is available only on rust nightly
if: ${{ matrix.coverage == true }}
run: |
cargo test --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- name: Generate coverage data
if: ${{ matrix.coverage == true }}
id: coverage
uses: actions-rs/[email protected]
- name: CodeCov - Upload coverage data
if: ${{ matrix.coverage == true }}
uses: codecov/codecov-action@v4
with:
files: ${{ steps.coverage.outputs.report }}
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
rustfmt:
name: Cargo Fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest stable rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Check format
run: |
cargo fmt -- --check
clippy:
name: Cargo Clippy
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- name: Install latest nightly rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: clippy
# https://github.com/psastras/sarif-rs
- name: Install required cargo
run: cargo install clippy-sarif sarif-fmt
# Clippy doesn't return non-zero exit code on error
# https://github.com/rust-lang/rust-clippy/issues/1209
- name: Run Clippy
continue-on-error: true
run: >
cargo clippy
--no-deps
--all-features
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
- name: Upload artifact with Clippy defects in SARIF format
uses: actions/upload-artifact@v4
with:
name: Cargo Clippy SARIF
path: rust-clippy-results.sarif
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: rust-clippy-results.sarif
...