-
Notifications
You must be signed in to change notification settings - Fork 2
116 lines (99 loc) · 2.54 KB
/
Copy pathci.yml
File metadata and controls
116 lines (99 loc) · 2.54 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
109
110
111
112
113
114
115
116
name: CI
on:
push:
branches: [main]
paths:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/.github/workflows/*.yml'
- 'flake.nix'
- '.cargo/config.toml'
pull_request:
paths:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/.github/workflows/*.yml'
- 'flake.nix'
- '.cargo/config.toml'
merge_group:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
jobs:
# Fast checks that don't need compilation
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# Compilation and clippy checks
check:
name: Check & Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: "check-clippy"
- name: Cargo check
run: cargo check --all-targets --all-features
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Tests
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: "test"
- name: Run tests
run: cargo test --all-features --workspace
# Build check
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
shared-key: "build"
- name: Build
run: cargo build --release
# All checks passed
ci-success:
name: CI Success
needs: [fmt, check, test, build]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check results
run: |
if [[ "${{ needs.fmt.result }}" != "success" ]] || \
[[ "${{ needs.check.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]] || \
[[ "${{ needs.build.result }}" != "success" ]]; then
echo "CI failed"
exit 1
fi
echo "CI succeeded"