-
-
Notifications
You must be signed in to change notification settings - Fork 817
200 lines (165 loc) · 6.04 KB
/
test_rust.yml
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
name: Test Rust
on:
push:
branches: [master]
pull_request:
branches: [master]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FEATURES: lzma,jpegxr
TEST_OPTS: --workspace --locked --no-fail-fast -j 4
# This is to counteract the disabling by rust-cache.
# See: https://github.com/Swatinem/rust-cache/issues/43
CARGO_INCREMENTAL: '1'
# Supposedly makes "Updating crates.io index" faster on Windows.
# See: https://github.com/rust-lang/cargo/issues/9167
CARGO_NET_GIT_FETCH_WITH_CLI: 'true'
# Workaround for: https://github.com/nextest-rs/nextest/issues/1493
# See also: https://github.com/rust-lang/rustup/issues/3825
RUSTUP_WINDOWS_PATH_ADD_BIN: '1'
# (Linux) Just to silence warnings about it missing
XDG_RUNTIME_DIR: ''
jobs:
changes:
name: Paths filter
runs-on: ubuntu-24.04
outputs:
should_run: ${{ steps.filter.outputs.src }}
steps:
- uses: actions/checkout@v4
- uses: AurorNZ/paths-filter@v4
id: filter
with:
filters: |
src:
- '!web/package.json'
- '!web/package-lock.json'
- '!web/packages/**'
- '!**/*.md'
build:
needs: changes
if: needs.changes.outputs.should_run == 'true'
name: Test Rust ${{ matrix.rust_version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.rust_version == 'nightly' || matrix.rust_version == 'beta' }}
strategy:
fail-fast: false
matrix:
rust_version: [stable]
os: [ubuntu-24.04, windows-latest, macos-14]
include:
- rust_version: nightly
os: ubuntu-24.04
- rust_version: beta
os: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust_version }}
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev mesa-vulkan-drivers libpango1.0-dev libudev-dev
# Needed after: https://github.com/rust-lang/rust/pull/124129
# See also: https://github.com/dtolnay/linkme/issues/94
# Additionally: https://lld.llvm.org/ELF/start-stop-gc
- name: Disable linker start-stop-gc
if: runner.os == 'Linux'
run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=web_sys_unstable_apis\ -Clink-args=-znostart-stop-gc >> $GITHUB_ENV
- name: Enable image tests
if: runner.os != 'macOS'
shell: bash
run: echo FEATURES=${FEATURES},imgtests | tee -a $GITHUB_ENV
- name: Cache Cargo output
uses: Swatinem/rust-cache@v2
with:
shared-key: "desktop"
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Install cargo nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Run tests
shell: bash
run: cargo nextest run --profile ci --cargo-profile ci ${TEST_OPTS} --features ${FEATURES}
- name: Run doctests
shell: bash
run: cargo test --doc --profile ci ${TEST_OPTS} --features ${FEATURES}
- name: Upload images
if: failure()
uses: actions/upload-artifact@v4
with:
name: swf_images_${{ matrix.rust_version }}_${{ matrix.os }}
path: |
tests*/**/*.actual*.png
tests*/**/*.difference*.png
lints:
needs: changes
if: needs.changes.outputs.should_run == 'true'
name: Lints with Rust ${{ matrix.rust_version }}
runs-on: ubuntu-24.04
continue-on-error: ${{ matrix.rust_version == 'nightly' || matrix.rust_version == 'beta' }}
strategy:
fail-fast: false
matrix:
rust_version: [stable, beta, nightly]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust_version }}
components: rustfmt, clippy
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev mesa-vulkan-drivers libpango1.0-dev libudev-dev
- name: Check formatting
run: cargo fmt --all -- --check
- name: Check clippy (with tests)
# Don't fail the build for clippy on nightly, since we get a lot of false-positives
run: cargo clippy --all --all-features --tests ${{ (matrix.rust_version != 'nightly' && '-- -D warnings') || '' }}
- name: Check clippy (without tests)
# Don't fail the build for clippy on nightly, since we get a lot of false-positives
run: cargo clippy --all --all-features ${{ (matrix.rust_version != 'nightly' && '-- -D warnings') || '' }}
- name: Check documentation
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
dependencies:
needs: changes
if: needs.changes.outputs.should_run == 'true'
name: Check dependencies
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Check licenses, duplicates, and advisories
uses: EmbarkStudios/cargo-deny-action@v2
- name: Check unused dependencies
uses: bnjbvr/cargo-machete@main
# So the previous step failing doesn't prevent this one from running.
if: always()
check-required:
needs: changes
if: needs.changes.outputs.should_run == 'false'
name: Test Rust ${{ matrix.rust_version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust_version: [stable]
os: [ubuntu-24.04, windows-latest, macos-14]
include:
- rust_version: nightly
os: ubuntu-24.04
- rust_version: beta
os: ubuntu-24.04
steps:
- name: No-op
run: echo noop