|
name: Rust |
|
|
|
on: |
|
push: |
|
branches: [ "main" ] |
|
pull_request: |
|
branches: [ "main" ] |
|
paths-ignore: |
|
- "README.md" |
|
- "CONTRIBUTING.md" |
|
merge_group: |
|
types: [checks_requested] |
|
|
|
|
|
env: |
|
CARGO_TERM_COLOR: always |
|
# https://github.com/xd009642/tarpaulin |
|
TARPAULIN_VERSION: 0.35.1 |
|
# https://github.com/est31/cargo-udeps |
|
UDEPS_VERSION: 0.1.60 |
|
# https://github.com/rustsec/rustsec |
|
AUDIT_VERSION: 0.22.1 |
|
|
|
concurrency: |
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
|
cancel-in-progress: true |
|
|
|
jobs: |
|
tests: |
|
name: Cargo fmt,clippy,build,test,tarpaulin |
|
runs-on: ${{ matrix.os }} |
|
|
|
strategy: |
|
matrix: |
|
os: [ubuntu-latest, macos-latest] |
|
|
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
|
|
- name: Cargo fmt |
|
run: cargo fmt --all -- --check |
|
|
|
- name: Cargo clippy |
|
run: cargo clippy --all-targets -- -D warnings |
|
|
|
- name: Cargo build |
|
run: cargo build --verbose |
|
|
|
- name: Cargo test |
|
run: cargo test --verbose |
|
|
|
- name: Install cargo-tarpaulin@${{ env.TARPAULIN_VERSION }} |
|
uses: taiki-e/install-action@f8d25fb8a2df08dcd3cead89780d572767b8655f # v2.68.0 |
|
if: matrix.os == 'ubuntu-latest' |
|
with: |
|
tool: cargo-tarpaulin@${{ env.TARPAULIN_VERSION }} |
|
|
|
- name: Cargo tarpaulin |
|
if: matrix.os == 'ubuntu-latest' |
|
run: cargo tarpaulin --verbose |
|
|
|
audit: |
|
runs-on: ubuntu-latest |
|
name: Cargo udeps and audit |
|
needs: tests |
|
|
|
steps: |
|
- uses: actions/checkout@v4 |
|
|
|
- name: Install cargo-udeps@${{ env.UDEPS_VERSION }} |
|
uses: taiki-e/install-action@f8d25fb8a2df08dcd3cead89780d572767b8655f # v2.68.0 |
|
with: |
|
tool: cargo-udeps@${{ env.UDEPS_VERSION }} |
|
|
|
- name: Install cargo-audit@${{ env.AUDIT_VERSION }} |
|
uses: taiki-e/install-action@f8d25fb8a2df08dcd3cead89780d572767b8655f # v2.68.0 |
|
with: |
|
tool: cargo-audit@${{ env.AUDIT_VERSION }} |
|
|
|
- name: Run cargo udeps |
|
run: cargo +nightly udeps --verbose |
|
|
|
- name: Run cargo audit |
|
run: cargo audit |
|
|
|
# https://github.com/orgs/community/discussions/12395#discussioncomment-12970019 |
|
check-workflow-status: |
|
name: Check Workflow Status |
|
runs-on: ubuntu-latest |
|
if: always() |
|
|
|
needs: |
|
- tests |
|
- audit |
|
|
|
steps: |
|
- name: Check Workflow Status |
|
run: | |
|
exit_on_result() { |
|
if [[ "$2" == "failure" || "$2" == "cancelled" ]]; then |
|
echo "Job '$1' failed or was cancelled." |
|
exit 1 |
|
fi |
|
} |
|
exit_on_result "linter" "${{ needs.linter.result }}" |
|
exit_on_result "tests" "${{ needs.tests.result }}" |
|
exit_on_result "audit" "${{ needs.audit.result }}" |