Continuous Integration #726
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: Continuous Integration | |
on: | |
pull_request: | |
paths-ignore: | |
- "**/*.md" | |
push: | |
branches: | |
- main | |
- "renovate/**" | |
paths-ignore: | |
- "**/*.md" | |
schedule: | |
- cron: "0 0 * * 0" | |
merge_group: | |
types: [checks_requested] | |
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that | |
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
CI: true | |
jobs: | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Run Cargo Fmt | |
run: cargo fmt --all -- --check | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
toolchain: [stable] | |
steps: | |
- uses: actions/checkout@v4 # v4 | |
- name: Install Rust ${{ matrix.toolchain }} | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
components: clippy | |
- uses: Swatinem/rust-cache@v2 | |
- name: Run clippy | |
if: ${{ matrix.toolchain == 'stable' }} | |
run: cargo clippy --all-targets -- -D warnings | |
- name: Run clippy on beta but do not fail on us, we are just testing | |
if: ${{ matrix.toolchain == 'beta' }} | |
run: cargo clippy --all-targets | |
clippy-future: | |
name: Clippy (Future) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Get early warning of new lints which are regularly introduced in beta/nightly channels. | |
toolchain: [beta, nightly] | |
steps: | |
- uses: actions/checkout@v4 # v4 | |
- name: Install Rust ${{ matrix.toolchain }} | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
components: clippy | |
- uses: Swatinem/rust-cache@v2 | |
- name: Run clippy | |
run: cargo clippy --all-targets | |
test: | |
name: Test | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# Get early warning of new lints which are regularly introduced in beta channels. | |
toolchain: [stable, beta] | |
job: | |
- os: macos-latest | |
- os: ubuntu-latest | |
- os: windows-latest | |
steps: | |
- uses: actions/checkout@v4 # v4 | |
if: github.event_name != 'pull_request' | |
with: | |
fetch-depth: 0 | |
- uses: actions/checkout@v4 # v4 | |
if: github.event_name == 'pull_request' | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-nextest | |
- name: Install Rust ${{ matrix.toolchain }} | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
- uses: Swatinem/rust-cache@v2 | |
- name: Run Cargo Test | |
id: run_tests | |
# run: cargo test --all-targets --features ${{ matrix.feature }} --workspace | |
run: cargo nextest run --all-features --workspace -- --include-ignored | |
env: | |
INSTA_UPDATE: new | |
- name: Upload snapshots of failed tests | |
if: ${{ failure() && steps.run_tests.outcome == 'failure' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: failed-snapshots | |
path: "**/snapshots/*.snap.new" | |
docs: | |
name: Build docs | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
matrix: | |
rust: [stable] | |
job: | |
- os: macos-latest | |
- os: ubuntu-latest | |
- os: windows-latest | |
steps: | |
- uses: actions/checkout@v4 # v4 | |
if: github.event_name != 'pull_request' | |
with: | |
fetch-depth: 0 | |
- uses: actions/checkout@v4 # v4 | |
if: github.event_name == 'pull_request' | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: nightly | |
- uses: Swatinem/rust-cache@v2 | |
- name: cargo doc | |
run: cargo doc --no-deps --all-features --workspace --examples | |
env: | |
RUSTDOCFLAGS: --cfg docsrs | |
msrv: | |
name: Check MSRV | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
crate: [pace-rs, pace_core, pace_cli] | |
msrv: [1.74.1] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install ${{ matrix.msrv }} | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.msrv }} | |
- name: Install cargo-hack | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-hack | |
- name: Run Cargo Hack | |
run: cargo +${{ matrix.msrv }} hack check --rust-version -p ${{ matrix.crate }} | |
powerset: | |
# cargo-hack checks combinations of feature flags to ensure that features are all additive | |
# which is required for feature unification | |
runs-on: ubuntu-latest | |
name: ubuntu / stable / features | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install stable | |
uses: dtolnay/rust-toolchain@stable | |
- name: cargo install cargo-hack | |
uses: taiki-e/install-action@cargo-hack | |
# intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4 | |
# --feature-powerset runs for every combination of features | |
- name: cargo hack | |
run: cargo hack --feature-powerset check | |
result: | |
name: Result (CI) | |
runs-on: ubuntu-latest | |
needs: | |
- fmt | |
- clippy | |
- test | |
- docs | |
- msrv | |
- powerset | |
# - clippy-future # We intentionally don't use that here, as it's not a blocking check right now, but we want to see the results | |
steps: | |
- name: Mark the job as successful | |
run: exit 0 | |
if: success() | |
- name: Mark the job as unsuccessful | |
run: exit 1 | |
if: "!success()" |