-
Notifications
You must be signed in to change notification settings - Fork 6
210 lines (171 loc) · 5.13 KB
/
ci.yaml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: "CI"
on:
pull_request: {}
push:
paths-ignore:
- "docs/**"
- "**.md"
- "LICENSE"
branches:
- main
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1
CLICOLOR_FORCE: 1
permissions:
actions: read
contents: read
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Enable cargo cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Build
run: cargo build --release
test:
name: "Test"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: llvm-tools-preview
- name: Enable cargo cache
uses: Swatinem/rust-cache@v2
with:
# Needed to make sure cargo-deny is correctly cached.
cache-all-crates: true
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Install cargo-llvm-cov
run: cargo binstall --no-confirm --force cargo-llvm-cov
- name: Test
run: |
set -euxo pipefail
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace
result=0
RUSTC_BOOTSTRAP=1 BRUSH_TEST_REPORT=0 cargo test --workspace -- -Z unstable-options --format junit >raw-test-output.txt 2>test-errors.txt || result=$?
if [[ -f test-errors.txt ]]; then
cat test-errors.txt
fi
cargo llvm-cov report --cobertura --output-path ./codecov.xml
# Process raw test output
n=1
while IFS= read -r line
do
if [[ ${line} == "<?xml"* ]]; then
((n++))
fi
echo "${line}" >>"test-results-${n}.xml"
done <raw-test-output.txt
exit ${result}
- name: "Upload test results"
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
path: test-results-*.xml
- name: "Generate code coverage report"
uses: clearlyip/code-coverage-report-action@v5
if: always()
id: "code_coverage_report"
with:
artifact_download_workflow_names: "CI"
filename: "codecov.xml"
- name: "Upload code coverage report"
uses: actions/upload-artifact@v4
if: always()
with:
name: codecov-reports
path: code-coverage-results.md
- name: "Upload event file"
uses: actions/upload-artifact@v4
with:
name: event-file
path: ${{ github.event_path }}
check:
name: "Source code checks"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Enable cargo cache
uses: Swatinem/rust-cache@v2
with:
# Needed to make sure cargo-deny is correctly cached.
cache-all-crates: true
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Format check
run: cargo fmt --check --all
- name: Check
run: cargo check --all-targets
- name: Deny check
run: |
set -euo pipefail
cargo binstall --no-confirm --force cargo-deny
cargo deny check
- name: Clippy check
run: cargo clippy --all-targets
benchmark:
if: github.event_name == 'pull_request'
name: "Benchmarks"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: pr
- name: Checkout
uses: actions/checkout@v4
with:
path: main
ref: main
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Enable cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
./pr
./main
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Performance analysis on PR
run: cargo bench --workspace -- --output-format bencher | tee benchmarks.txt
working-directory: pr
- name: Performance analysis on main
run: cargo bench --workspace -- --output-format bencher | tee benchmarks.txt
working-directory: main
- name: Compare benchmark results
run: |
./pr/scripts/compare-benchmark-results.py -b main/benchmarks.txt -t pr/benchmarks.txt >benchmark-results.md
- name: Upload performance results
uses: actions/upload-artifact@v4
with:
name: perf-reports
path: |
pr/benchmarks.txt
main/benchmarks.txt
benchmark-results.md