Refactor CI and daily workflow #2100
Workflow file for this run
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
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 'main' | ||
defaults: | ||
run: | ||
shell: bash | ||
permissions: | ||
contents: read | ||
env: | ||
RUSTUP_MAX_RETRIES: 10 | ||
CARGO_INCREMENTAL: 0 | ||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- audit | ||
- careful | ||
- check | ||
- clippy | ||
- cross | ||
- deny | ||
- docs | ||
- fmt | ||
- fuzz | ||
- miri | ||
- outdated | ||
- test | ||
- udeps | ||
steps: | ||
- run: exit 0 | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: make check | ||
test: | ||
name: test ${{ matrix.target.triple }} - ${{ matrix.target.toolchain }} | ||
needs: check | ||
strategy: | ||
matrix: | ||
target: | ||
- { os: ubuntu-latest, toolchain: stable, triple: x86_64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: 1.74.1, triple: x86_64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: beta, triple: x86_64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: nightly, triple: x86_64-unknown-linux-gnu } | ||
- { os: macos-latest, toolchain: stable, triple: x86_64-apple-darwin } | ||
- { os: macos-latest, toolchain: 1.74.1, triple: x86_64-apple-darwin } | ||
- { os: windows-latest, toolchain: stable, triple: x86_64-pc-windows-gnu } | ||
- { os: windows-latest, toolchain: 1.74.1, triple: x86_64-pc-windows-gnu } | ||
- { os: windows-latest, toolchain: stable, triple: i686-pc-windows-msvc } | ||
- { os: windows-latest, toolchain: 1.74.1, triple: i686-pc-windows-msvc } | ||
runs-on: ${{ matrix.target.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.target.toolchain }} | ||
targets: ${{ matrix.target.triple }} | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: ci/prepare-tests.sh | ||
- run: make test | ||
cross: | ||
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | ||
name: cross ${{ matrix.target.triple }} - ${{ matrix.target.toolchain }} | ||
runs-on: ${{ matrix.target.os }} | ||
needs: check | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- { os: ubuntu-latest, toolchain: stable, triple: x86_64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: beta, triple: x86_64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: nightly, triple: x86_64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: stable, triple: x86_64-unknown-linux-musl } | ||
- { os: ubuntu-latest, toolchain: stable, triple: aarch64-unknown-linux-gnu } | ||
- { os: ubuntu-latest, toolchain: stable, triple: aarch64-unknown-linux-musl } | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.target.toolchain }} | ||
targets: ${{ matrix.target.triple }} | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install cross | ||
- run: | | ||
cross build --target ${{ matrix.target.triple }} | ||
fuzz: | ||
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} | ||
name: fuzz ${{ matrix.item.name }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 900 | ||
needs: check | ||
strategy: | ||
matrix: | ||
item: | ||
- { name: pica-record-ref, fuzz-dir: crates/pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 } | ||
- { name: pica-record-matcher, fuzz-dir: crates/pica-matcher/fuzz, target: fuzz-record-matcher, max-total-time: 300 } | ||
- { name: pica-select-query, fuzz-dir: crates/pica-select/fuzz, target: fuzz-query, max-total-time: 300 } | ||
- { name: pica-path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 } | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: dtolnay/install@cargo-fuzz | ||
- run: | | ||
cargo fuzz run --fuzz-dir ${{ matrix.item.fuzz-dir }} --jobs 2 ${{ matrix.item.target }} -- -max_total_time=${{ matrix.item.max-total-time }} | ||
fmt: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
components: rustfmt | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: make check-fmt | ||
clippy: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
components: clippy | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: make clippy | ||
careful: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install cargo-careful | ||
- run: ci/prepare-tests.sh | ||
- run: make careful | ||
udeps: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install cargo-udeps | ||
- run: cargo udeps --workspace | ||
deny: | ||
runs-on: ubuntu-latest | ||
needs: check | ||
strategy: | ||
matrix: | ||
checks: | ||
- bans licenses sources | ||
- advisories | ||
continue-on-error: ${{ matrix.checks == 'advisories' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: EmbarkStudios/cargo-deny-action@v1 | ||
with: | ||
command: check ${{ matrix.checks }} | ||
rust-version: stable | ||
audit: | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
runs-on: ubuntu-latest | ||
needs: test | ||
permissions: | ||
checks: write | ||
contents: read | ||
issues: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: rustsec/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
outdated: | ||
continue-on-error: ${{ github.ref != 'refs/heads/main' }} | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: dtolnay/install@cargo-outdated | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo outdated --exit-code 1 | ||
miri: | ||
name: miri | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@miri | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo miri test --workspace --lib --verbose | ||
env: | ||
MIRIFLAGS: -Zmiri-strict-provenance | ||
- run: cargo miri test --workspace --doc --verbose | ||
env: | ||
MIRIFLAGS: -Zmiri-strict-provenance | ||
docs: | ||
needs: | ||
- test | ||
- cross | ||
- fuzz | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: peaceiris/actions-hugo@v2 | ||
with: | ||
hugo-version: 'latest' | ||
extended: true | ||
- run: make docs | ||
- name: deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
permissions: | ||
contents: write | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: target/docs | ||
keep_files: false | ||
force_orphan: true |