CI #2766
This file contains hidden or 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
| name: CI | |
| on: | |
| merge_group: | |
| pull_request: | |
| schedule: | |
| - cron: "0 3 * * sun" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-up-to-dateness: | |
| outputs: | |
| is-up-to-date: ${{ steps.main.outputs.is-up-to-date }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: main | |
| uses: trailofbits/check-up-to-dateness@v2 | |
| test: | |
| needs: [check-up-to-dateness] | |
| if: needs.check-up-to-dateness.outputs.is-up-to-date != 'true' | |
| strategy: | |
| fail-fast: ${{ github.event_name == 'merge_group' }} | |
| matrix: | |
| environment: [ubuntu-latest, macos-latest, windows-latest] | |
| index: [crates-index, tame-index] | |
| runs-on: ${{ matrix.environment }} | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| RUST_BACKTRACE: 1 | |
| GIT_LFS_SKIP_SMUDGE: 1 | |
| GROUP_RUNNER: target.'cfg(all())'.runner = 'group-runner' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| # smoelius: Do NOT cache ~/.cache/cargo-unmaintained. Sure, it makes CI faster. But it | |
| # also makes it harder to tell when test files need to be updated. | |
| # ~/.cache/cargo-unmaintained/ | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('.github/workflows/ci.yml', 'tests/ci.rs') }} | |
| - uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-audit, cargo-hack, cargo-udeps | |
| - name: Install tools | |
| run: | | |
| rustup update --no-self-update | |
| rustup install nightly --no-self-update | |
| rustup component add clippy --toolchain nightly | |
| rustup component add rustfmt --toolchain nightly | |
| export CARGO_TARGET_DIR="$(mktemp -d)" | |
| cargo install cargo-dylint dylint-link || true | |
| cargo install cargo-license || true | |
| cargo install cargo-supply-chain || true | |
| cargo install group-runner || true | |
| - name: Enable verbose logging | |
| if: ${{ runner.debug == 1 }} | |
| run: echo 'VERBOSE=1' >> "$GITHUB_ENV" | |
| - name: Build | |
| run: cargo test --workspace --no-run | |
| - name: Test | |
| run: cargo test --config "$GROUP_RUNNER" | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Test `ei` | |
| if: matrix.environment == 'ubuntu-latest' | |
| run: | | |
| EI='-p ei --lib' | |
| if [[ '${{ github.event_name }}' = 'schedule' || '${{ github.event_name }}' = 'workflow_dispatch' ]] || | |
| git diff --name-only ${{ github.event.pull_request.base.sha }} | grep -w 'ei' >/dev/null | |
| then | |
| EI="$EI --test dogfood --test rustsec_advisories --test rustsec_issues --test snapbox_real_github" | |
| fi | |
| cargo test --config "$GROUP_RUNNER" $EI | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Test `ci` | |
| if: matrix.environment == 'ubuntu-latest' | |
| run: cargo test --config "$GROUP_RUNNER" -p ci | |
| all-checks: | |
| needs: [test] | |
| # smoelius: From "Defining prerequisite jobs" | |
| # (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs): | |
| # > If you would like a job to run even if a job it is dependent on did not succeed, use the | |
| # > `always()` conditional expression in `jobs.<job_id>.if`. | |
| if: ${{ always() }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check results | |
| if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | |
| run: exit 1 |