-
Notifications
You must be signed in to change notification settings - Fork 25
108 lines (85 loc) · 2.65 KB
/
Copy pathrust.yml
File metadata and controls
108 lines (85 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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 }}"