This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
rust #394
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: rust | |
"on": | |
pull_request: | |
branches: | |
- main | |
merge_group: | |
types: | |
- checks_requested | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: -D warnings | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
changes: | |
name: detect file changes | |
permissions: | |
pull-requests: read | |
runs-on: ubuntu-latest | |
outputs: | |
github-actions: ${{ steps.filter.outputs.github-actions }} | |
github-actions_files: ${{ steps.filter.outputs.github-actions_files }} | |
markdown: ${{ steps.filter.outputs.markdown }} | |
markdown_files: ${{ steps.filter.outputs.markdown_files }} | |
rust: ${{ steps.filter.outputs.rust }} | |
rust_files: ${{ steps.filter.outputs.rust_files }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
with: | |
fetch-depth: 20 | |
- name: Filter changed repository files | |
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 | |
id: filter | |
with: | |
list-files: shell | |
filters: | | |
github-actions: | |
- .github/**/*.yml | |
markdown: | |
- added|modified: '**/*.md' | |
rust: | |
- '**/*.rs' | |
- '**/Cargo.*' | |
- .github/workflows/rust.yml | |
format: | |
name: format | |
needs: | |
- changes | |
runs-on: ubuntu-latest | |
if: needs.changes.outputs.rust == 'true' | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
- name: Install nightly Rust toolchain | |
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e | |
with: | |
toolchain: nightly | |
components: rustfmt | |
- name: Check formatting | |
run: cargo +nightly fmt --check | |
lint: | |
name: lint | |
needs: | |
- changes | |
runs-on: ubuntu-latest | |
if: needs.changes.outputs.rust == 'true' | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
- name: Install stable Rust toolchain | |
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e | |
with: | |
toolchain: stable | |
components: clippy | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@2656b87321093db1cb55fbd73183d195214fdfd1 | |
with: | |
shared-key: stable-ubuntu-latest | |
timeout-minutes: 5 | |
- name: Check lints | |
run: cargo clippy --locked --all-targets -- -D warnings | |
test_stable: | |
name: test / stable | |
needs: | |
- format | |
- lint | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- macos-latest | |
- ubuntu-latest | |
- windows-latest | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
- name: Install stable Rust toolchain | |
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e | |
with: | |
toolchain: stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@2656b87321093db1cb55fbd73183d195214fdfd1 | |
with: | |
shared-key: stable-${{ matrix.platform }} | |
timeout-minutes: 5 | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@d3712f40a2bae95e3ce25a24f82a795ed3df0f1c | |
with: | |
tool: cargo-nextest | |
- name: Compile tests | |
run: cargo test --locked --no-run | |
- name: Run tests | |
run: cargo nextest run --locked --all-targets | |
- name: Run doctests | |
run: cargo test --locked --doc | |
test_msrv: | |
name: test / msrv | |
needs: | |
- format | |
- lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
- id: msrv | |
name: Get MSRV from package metadata | |
run: awk -F '"' '/rust-version/{ print "version=" $2 }' Cargo.toml >> "$GITHUB_OUTPUT" | |
- name: Install ${{ steps.msrv.outputs.version }} Rust toolchain | |
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e | |
with: | |
toolchain: ${{ steps.msrv.outputs.version }} | |
- name: Install nightly Rust toolchain | |
uses: dtolnay/rust-toolchain@0e66bd3e6b38ec0ad5312288c83e47c143e6b09e | |
with: | |
toolchain: nightly | |
- name: Resolve minimal dependency versions instead of maximum | |
run: cargo +nightly update -Z direct-minimal-versions | |
- name: Set override to MSRV Rust | |
run: rustup override set ${{ steps.msrv.outputs.version }} | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@2656b87321093db1cb55fbd73183d195214fdfd1 | |
with: | |
shared-key: msrv-ubuntu-latest | |
timeout-minutes: 5 | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@d3712f40a2bae95e3ce25a24f82a795ed3df0f1c | |
with: | |
tool: cargo-nextest | |
- name: Compile tests | |
run: cargo test --locked --no-run | |
- name: Run tests | |
run: cargo nextest run --locked --all-targets | |
- name: Run doctests | |
run: cargo test --locked --doc | |
merge_queue: | |
name: rust workflow ready | |
needs: | |
- changes | |
- format | |
- lint | |
- test_stable | |
- test_msrv | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: "Check status of job_id: changes" | |
run: |- | |
RESULT="${{ needs.changes.result }}"; | |
if [[ $RESULT == "success" || $RESULT == "skipped" ]]; then | |
exit 0 | |
else | |
echo "***" | |
echo "Error: The required job did not pass." | |
exit 1 | |
fi | |
- name: "Check status of job_id: format" | |
run: |- | |
RESULT="${{ needs.format.result }}"; | |
if [[ $RESULT == "success" || $RESULT == "skipped" ]]; then | |
exit 0 | |
else | |
echo "***" | |
echo "Error: The required job did not pass." | |
exit 1 | |
fi | |
- name: "Check status of job_id: lint" | |
run: |- | |
RESULT="${{ needs.lint.result }}"; | |
if [[ $RESULT == "success" || $RESULT == "skipped" ]]; then | |
exit 0 | |
else | |
echo "***" | |
echo "Error: The required job did not pass." | |
exit 1 | |
fi | |
- name: "Check status of job_id: test_stable" | |
run: |- | |
RESULT="${{ needs.test_stable.result }}"; | |
if [[ $RESULT == "success" || $RESULT == "skipped" ]]; then | |
exit 0 | |
else | |
echo "***" | |
echo "Error: The required job did not pass." | |
exit 1 | |
fi | |
- name: "Check status of job_id: test_msrv" | |
run: |- | |
RESULT="${{ needs.test_msrv.result }}"; | |
if [[ $RESULT == "success" || $RESULT == "skipped" ]]; then | |
exit 0 | |
else | |
echo "***" | |
echo "Error: The required job did not pass." | |
exit 1 | |
fi |