-
Notifications
You must be signed in to change notification settings - Fork 1.9k
263 lines (218 loc) · 7.52 KB
/
rust.yml
File metadata and controls
263 lines (218 loc) · 7.52 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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: Rust CI
on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Check formatting, clippy warnings, run tests and check code coverage.
rust-lints:
permissions:
contents: read
checks: write
runs-on: ubuntu-24.04
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
run: |
tools/install-sys-dependencies-linux
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
rust
- name: Install Rust dependencies
run: |
tools/install-rust-dependencies dev
- name: Check code formatting
run: |
cargo fmt --check
working-directory: rust
- name: Check Clippy warnings
run: |
cargo clippy -- -D warnings
working-directory: rust
# Run Rust tests in WASM.
test-wasm:
runs-on: ubuntu-24.04
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
run: |
tools/install-sys-dependencies-linux
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
rust
- name: Install Rust dependencies
run: |
tools/install-rust-dependencies
- name: Install emsdk
run: tools/install-wasm-dependencies
- name: Run tests in WASM
run: tools/rust-test wasm
check-binary-sizes:
permissions:
contents: read
pull-requests: write
runs-on: macos-latest-xlarge
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
run: |
tools/install-sys-dependencies-mac
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
rust
- name: Install Rust dependencies
run: tools/install-rust-dependencies
- name: Install emsdk
run: tools/install-wasm-dependencies
- name: Compile release binaries
run: |
mkdir -p build/local/lib
source emsdk/emsdk_env.sh
tools/rust-bindgen
- name: Generate release report
run: |
./tools/release-size measure-rust > release-report.json
- name: Upload release report
uses: actions/upload-artifact@v4
with:
name: release_report
path: release-report.json
# Download previous release report, compare the release binary sizes, and post/update a comment at the Pull Request.
- name: Download previous release report
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: dawidd6/action-download-artifact@v6
with:
commit: ${{github.event.pull_request.base.sha}}
path: previous
if_no_artifact_found: warn
# Same artifact name as at the "Upload release report" step.
name: release_report
# Ignore status or conclusion in the search.
workflow_conclusion: ""
- name: Craft Comment Body
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
run: |
# Please note `previous/release-report.json` may not exist if the previous report was not found.
./tools/release-size compare --before previous/release-report.json --current release-report.json > report-diff.md
- name: Create or Update Comment
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: edumserrano/find-create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "Binary size comparison"
comment-author: 'github-actions[bot]'
edit-mode: replace
body-path: 'report-diff.md'
memory-profiler:
runs-on: ubuntu-24.04
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
rust
- name: Install llvm
run: |
# to get the symbolizer for debug symbol resolution
sudo apt install llvm
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
- name: Enable debug symbols
run: |
cd rust
# to fix buggy leak analyzer:
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
# ensure there's a profile.dev section
if ! grep -qE '^[ \t]*[profile.dev]' Cargo.toml; then
echo >> Cargo.toml
echo '[profile.dev]' >> Cargo.toml
fi
# remove pre-existing opt-levels in profile.dev
sed -i '/^\s*\[profile.dev\]/,/^\s*\[/ {/^\s*opt-level/d}' Cargo.toml
# now set opt-level to 1
sed -i '/^\s*\[profile.dev\]/a opt-level = 1' Cargo.toml
cat Cargo.toml
- name: cargo test -Zsanitizer=address
# only --lib --tests b/c of https://github.com/rust-lang/rust/issues/53945
run: |
cd rust
cargo test --lib --tests --all-features --target x86_64-unknown-linux-gnu
env:
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
RUSTFLAGS: "-Z sanitizer=address"
- name: cargo test -Zsanitizer=leak
if: always()
run: |
cd rust
cargo test --all-features --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "-Z sanitizer=leak"
coverage:
runs-on: ubuntu-24.04
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3
- name: Install system dependencies
run: |
tools/install-sys-dependencies-linux
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
rust
- name: Install Rust dependencies
run: |
tools/install-rust-dependencies dev
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: |
cd rust
cargo generate-lockfile
- name: Run tests
run: |
tools/rust-coverage
- name: Run Doc tests
run: |
tools/rust-test doc
- name: Record Rust version
run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV"
# TODO: Uncomment this when we have a codecov token
# - name: Upload to codecov.io
# uses: codecov/codecov-action@v5
# with:
# fail_ci_if_error: true
# token: ${{ secrets.CODECOV_TOKEN }}
# env_vars: OS,RUST
- name: Gather and check Rust code coverage
run: |
tools/check-coverage rust/coverage.stats rust/lcov.info