name: rust
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
linux:
name: validate (homelab-1)
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: [self-hosted, linux, x64, drep-linux]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: stable
components: rustfmt, clippy
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
cache-bin: false
- name: Format
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --all-targets --all-features
- name: Test
run: cargo test --all-targets --all-features
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: 1.88.0
- name: MSRV
run: cargo +1.88.0 check
test-macos:
name: test (Mac mini)
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: [self-hosted, macos, arm64, drep-macos]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
cache-bin: false
- run: cargo test --all-targets --all-features
mutants-diff:
name: mutate pushed diff (Legion)
needs: [linux, test-macos]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: [self-hosted, linux, x64, homelab-legion, drep-mutants]
timeout-minutes: 120
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
clean: false
fetch-depth: 0
persist-credentials: false
- name: Verify persistent workspace hygiene
shell: bash
run: |
set -euo pipefail
unexpected="$(
git status --porcelain=v1 --untracked-files=all --ignored=matching |
grep -Ev '^!! target/$' || true
)"
if [ -n "$unexpected" ]; then
echo "unexpected persistent runner state:" >&2
echo "$unexpected" >&2
exit 1
fi
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: stable
components: clippy
- uses: taiki-e/install-action@1ed6d7be6168f6c9046541087ff549b6bc581fdf with:
tool: cargo-mutants@27.1.0
- name: Materialize pushed diff
shell: bash
env:
PUSH_BASE: ${{ github.event.before }}
PUSH_HEAD: ${{ github.sha }}
run: |
set -euo pipefail
git diff --no-ext-diff --unified=0 "$PUSH_BASE" "$PUSH_HEAD" > "$RUNNER_TEMP/pushed.diff"
- run: ./scripts/mutants-run.sh --in-diff "$RUNNER_TEMP/pushed.diff"