Debian Codegraph @

debian/rust-vendor/crc-fast/.github/workflows/tests.yml

raw
1 name: Tests
2
3 on:
4 push:
5 pull_request:
6 workflow_dispatch:
7
8 jobs:
9 check-previous-run:
10 name: Check for previous successful run
11 runs-on: ubuntu-latest
12 outputs:
13 should_skip: ${{ steps.check.outputs.should_skip }}
14 steps:
15 - name: Check if commit was already tested
16 id: check
17 env:
18 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 run: |
20 echo "Current commit: ${{ github.sha }}"
21 echo "Current ref: ${{ github.ref }}"
22
23 # Check if there's a previous successful workflow run for this exact commit
24 PREVIOUS_RUN=$(gh api \
25 -H "Accept: application/vnd.github+json" \
26 "/repos/${{ github.repository }}/actions/workflows/tests.yml/runs?status=success&per_page=5" \
27 --jq '.workflow_runs[] | select(.head_sha == "${{ github.sha }}") | .id' \
28 | head -n 1)
29
30 if [ -n "$PREVIOUS_RUN" ] && [ "$PREVIOUS_RUN" != "${{ github.run_id }}" ]; then
31 echo "Found previous successful run: $PREVIOUS_RUN"
32 echo "should_skip=true" >> $GITHUB_OUTPUT
33 else
34 echo "No previous successful run found for this commit"
35 echo "should_skip=false" >> $GITHUB_OUTPUT
36 fi
37
38 test-aarch64:
39 name: Test aarch64
40 needs: check-previous-run
41 if: needs.check-previous-run.outputs.should_skip != 'true'
42 strategy:
43 matrix:
44 os: [ubuntu-22.04-arm, ubuntu-24.04-arm, macos-14, macos-15, macos-26, macos-latest, windows-11-arm]
45 rust-toolchain:
46 - "1.81" # minimum for this crate
47 - "stable"
48 - "nightly"
49 runs-on: ${{ matrix.os }}
50 steps:
51 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
52 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
53 with:
54 toolchain: ${{ matrix.rust-toolchain }}
55 components: rustfmt, clippy
56 cache-key: ${{ matrix.os }}-${{ matrix.rust-toolchain }}-v2
57 - name: Check
58 run: cargo check --all-features
59 - name: Architecture check
60 run: cargo run --features cli --bin arch-check
61 - if: ${{ matrix.rust-toolchain != 'nightly' }}
62 name: Format
63 run: cargo fmt -- --check
64 - if: ${{ matrix.rust-toolchain != 'nightly' }}
65 name: Clippy
66 run: cargo clippy --all-features -- -D warnings
67 - name: Test
68 run: cargo test --all-features
69
70 test-x86_64:
71 name: Test x86_64
72 needs: check-previous-run
73 if: needs.check-previous-run.outputs.should_skip != 'true'
74 strategy:
75 matrix:
76 os: [ ubuntu-latest, ubuntu-22.04, ubuntu-24.04, macos-15-intel, windows-2022, windows-2025, windows-latest ]
77 rust-toolchain:
78 - "1.81" # minimum for this crate
79 - "1.89" # when AVX-512 VPCLMULQDQ was stabilized
80 - "stable"
81 - "nightly"
82 runs-on: ${{ matrix.os }}
83 steps:
84 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
85 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
86 with:
87 toolchain: ${{ matrix.rust-toolchain }}
88 components: rustfmt, clippy
89 cache-key: ${{ matrix.os }}-${{ matrix.rust-toolchain }}-v2
90 - name: Check
91 run: cargo check --all-features
92 - name: Architecture check
93 run: cargo run --features cli --bin arch-check
94 - if: ${{ matrix.rust-toolchain != 'nightly' }}
95 name: Format
96 run: cargo fmt -- --check
97 - if: ${{ matrix.rust-toolchain != 'nightly' }}
98 name: Clippy
99 run: cargo clippy --all-features -- -D warnings
100 - name: Test
101 run: cargo test --all-features
102
103 test-x86-linux:
104 name: Test x86 Linux
105 needs: check-previous-run
106 if: needs.check-previous-run.outputs.should_skip != 'true'
107 runs-on: ubuntu-latest
108 strategy:
109 matrix:
110 target: [i586-unknown-linux-gnu, i686-unknown-linux-gnu]
111 rust-toolchain:
112 - "1.81" # minimum for this crate
113 - "stable"
114 - "nightly"
115 steps:
116 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
117 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
118 with:
119 toolchain: ${{ matrix.rust-toolchain }}
120 components: rustfmt, clippy
121 - name: Set up cross
122 run: cargo install cross --locked --version 0.2.5
123 - name: Check
124 run: cross check --all-features --target ${{ matrix.target }}
125 - name: Architecture check
126 run: cross run --features cli --bin arch-check --target ${{ matrix.target }}
127 - name: Test
128 run: cross test --all-features --target ${{ matrix.target }}
129
130 test-x86-windows:
131 name: Test x86 Windows
132 needs: check-previous-run
133 if: needs.check-previous-run.outputs.should_skip != 'true'
134 runs-on: windows-2022
135 strategy:
136 matrix:
137 rust-toolchain:
138 - "1.81" # minimum for this crate
139 - "stable"
140 - "nightly"
141 steps:
142 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
143 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
144 with:
145 toolchain: ${{ matrix.rust-toolchain }}
146 target: i686-pc-windows-msvc
147 components: rustfmt, clippy
148 cache-key: windows-x86-${{ matrix.rust-toolchain }}
149 - name: Check
150 run: cargo check --all-features --target i686-pc-windows-msvc
151 - name: Architecture check
152 run: cargo run --features cli --bin arch-check --target i686-pc-windows-msvc
153 - if: ${{ matrix.rust-toolchain != 'nightly' }}
154 name: Format
155 run: cargo fmt -- --check
156 - if: ${{ matrix.rust-toolchain != 'nightly' }}
157 name: Clippy
158 run: cargo clippy --all-features --target i686-pc-windows-msvc -- -D warnings
159 - name: Test
160 run: cargo test --all-features --target i686-pc-windows-msvc
161
162 test-software:
163 name: Test software fallback
164 needs: check-previous-run
165 if: needs.check-previous-run.outputs.should_skip != 'true'
166 runs-on: ubuntu-latest
167 strategy:
168 matrix:
169 target: [powerpc-unknown-linux-gnu, powerpc64-unknown-linux-gnu]
170 rust-toolchain:
171 - "1.81" # minimum for this crate
172 - "stable"
173 - "nightly"
174 steps:
175 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
176 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
177 with:
178 toolchain: ${{ matrix.rust-toolchain }}
179 components: rustfmt, clippy
180 - name: Set up cross
181 run: cargo install cross --locked --version 0.2.5
182 - name: Check
183 run: cross check --all-features --target ${{ matrix.target }}
184 - name: Architecture check
185 run: cross run --features cli --bin arch-check --target ${{ matrix.target }}
186 - name: Test
187 run: cross test --all-features --target ${{ matrix.target }}
188
189 miri-test-x86_64:
190 name: Miri Test x86_64
191 needs: [check-previous-run, test-x86_64]
192 if: needs.check-previous-run.outputs.should_skip != 'true'
193 runs-on: ubuntu-24.04
194 steps:
195 - uses: actions/checkout@v4
196 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9
197 with:
198 toolchain: nightly
199 components: miri
200 - name: Detect CPU cores
201 id: cores
202 run: |
203 CORES=$(nproc)
204 echo "count=$CORES" >> $GITHUB_OUTPUT
205 echo "use_nextest=$([[ $CORES -ge 2 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
206 - name: Install nextest
207 if: steps.cores.outputs.use_nextest == 'true'
208 run: cargo install cargo-nextest --locked
209 - name: Setup Miri
210 run: cargo miri setup
211 - name: Run Miri tests (parallel)
212 if: steps.cores.outputs.use_nextest == 'true'
213 run: cargo miri nextest run --all-features -j${{ steps.cores.outputs.count }}
214 - name: Run Miri tests (serial)
215 if: steps.cores.outputs.use_nextest == 'false'
216 run: cargo miri test --all-features
217
218 test-no-std:
219 name: Test no_std
220 needs: check-previous-run
221 if: needs.check-previous-run.outputs.should_skip != 'true'
222 runs-on: ubuntu-latest
223 strategy:
224 matrix:
225 target:
226 - thumbv7em-none-eabihf # ARM Cortex-M4F/M7F
227 - thumbv8m.main-none-eabihf # ARM Cortex-M33/M35P
228 - riscv32imac-unknown-none-elf # RISC-V 32-bit
229 rust-toolchain:
230 - "1.81" # minimum for this crate
231 - "stable"
232 - "nightly"
233 steps:
234 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
235 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
236 with:
237 toolchain: ${{ matrix.rust-toolchain }}
238 target: ${{ matrix.target }}
239 components: rustfmt, clippy
240 cache-key: ${{ matrix.target }}-${{ matrix.rust-toolchain }}-v2
241 - name: Check no_std (no features)
242 run: cargo check --target ${{ matrix.target }} --no-default-features --features panic-handler --lib
243 - name: Check no_std with alloc
244 run: cargo check --target ${{ matrix.target }} --no-default-features --features alloc,panic-handler --lib
245 - name: Check no_std with cache
246 run: cargo check --target ${{ matrix.target }} --no-default-features --features cache,panic-handler --lib
247 - name: Run no_std tests (on host with std test harness)
248 run: cargo test --test no_std_tests
249
250 test-wasm:
251 name: Test WASM
252 needs: check-previous-run
253 if: needs.check-previous-run.outputs.should_skip != 'true'
254 runs-on: ubuntu-latest
255 strategy:
256 matrix:
257 include:
258 # WASM 1.0/2.0 (32-bit) - all toolchains
259 - target: wasm32-unknown-unknown
260 rust-toolchain: "1.81"
261 - target: wasm32-unknown-unknown
262 rust-toolchain: "stable"
263 - target: wasm32-unknown-unknown
264 rust-toolchain: "nightly"
265 # WASI preview 1 (32-bit) - all toolchains
266 - target: wasm32-wasip1
267 rust-toolchain: "1.81"
268 - target: wasm32-wasip1
269 rust-toolchain: "stable"
270 - target: wasm32-wasip1
271 rust-toolchain: "nightly"
272 # WASI preview 2 (32-bit) - nightly only (experimental)
273 - target: wasm32-wasip2
274 rust-toolchain: "nightly"
275 # Note: wasm64-unknown-unknown removed - not consistently available in nightly
276 steps:
277 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
278 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
279 with:
280 toolchain: ${{ matrix.rust-toolchain }}
281 target: ${{ matrix.target }}
282 components: rustfmt, clippy
283 cache-key: ${{ matrix.target }}-${{ matrix.rust-toolchain }}-v2
284 - name: Check WASM (no features)
285 run: cargo check --target ${{ matrix.target }} --no-default-features --features panic-handler --lib
286 - name: Check WASM with alloc
287 run: cargo check --target ${{ matrix.target }} --no-default-features --features alloc,panic-handler --lib
288 - name: Check WASM with cache
289 run: cargo check --target ${{ matrix.target }} --no-default-features --features cache,panic-handler --lib
290 - name: Build WASM release
291 run: cargo build --target ${{ matrix.target }} --no-default-features --features alloc,panic-handler --lib --release
292 - name: Run WASM tests (on host with std test harness)
293 run: cargo test --test wasm_tests
294 - if: ${{ matrix.target == 'wasm32-unknown-unknown' && matrix.rust-toolchain == 'stable' }}
295 name: Install wasm-pack
296 run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
297 - if: ${{ matrix.target == 'wasm32-unknown-unknown' && matrix.rust-toolchain == 'stable' }}
298 name: Build WASM package with wasm-pack
299 run: wasm-pack build --target web --no-default-features --features alloc,panic-handler
300
301 fuzz-test:
302 name: Fuzz Testing
303 needs: check-previous-run
304 if: needs.check-previous-run.outputs.should_skip != 'true'
305 runs-on: ${{ matrix.os }}
306 strategy:
307 fail-fast: false
308 matrix:
309 os: [ubuntu-24.04, ubuntu-24.04-arm]
310 fuzz-target:
311 - digest_crc32_autosar
312 - digest_crc32_bzip2
313 - digest_crc32_iscsi
314 - digest_crc32_iso_hdlc
315 - digest_crc64_ecma_182
316 - digest_crc64_nvme
317 - checksum_crc32_autosar
318 - checksum_crc32_bzip2
319 - checksum_crc32_iscsi
320 - checksum_crc32_iso_hdlc
321 - checksum_crc64_ecma_182
322 - checksum_crc64_nvme
323 steps:
324 - uses: actions/checkout@v4 # not pinning to commit hash since this is a GitHub action, which we trust
325 - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
326 with:
327 toolchain: nightly
328 cache-key: ${{ matrix.os }}-nightly-fuzz
329 - name: Install cargo-fuzz
330 run: cargo install cargo-fuzz
331 - name: Run fuzzer
332 run: |
333 cargo fuzz run ${{ matrix.fuzz-target }} -- \
334 -max_total_time=60 \
335 -rss_limit_mb=2048 \
336 -timeout=10 \
337 -print_final_stats=1
338 continue-on-error: true
339 - name: Upload artifacts on crash
340 if: failure()
341 uses: actions/upload-artifact@v4
342 with:
343 name: fuzz-artifacts-${{ matrix.os }}-${{ matrix.fuzz-target }}
344 path: fuzz/artifacts/${{ matrix.fuzz-target }}/
345
346 tests-complete:
347 name: All tests complete
348 needs: [check-previous-run, test-aarch64, test-x86_64, test-x86-linux, test-x86-windows, test-software, miri-test-x86_64, test-no-std, test-wasm, fuzz-test]
349 if: always()
350 runs-on: ubuntu-latest
351 steps:
352 - name: Check test results
353 run: |
354 echo "Checking test results..."
355 echo "Previous run check: ${{ needs.check-previous-run.result }}"
356 echo "Should skip: ${{ needs.check-previous-run.outputs.should_skip }}"
357
358 if [ "${{ needs.check-previous-run.outputs.should_skip }}" == "true" ]; then
359 echo "✓ Tests were skipped because this commit was already tested successfully"
360 exit 0
361 fi
362
363 # Check if any test job failed
364 if [ "${{ needs.test-aarch64.result }}" == "failure" ] || \
365 [ "${{ needs.test-x86_64.result }}" == "failure" ] || \
366 [ "${{ needs.test-x86-linux.result }}" == "failure" ] || \
367 [ "${{ needs.test-x86-windows.result }}" == "failure" ] || \
368 [ "${{ needs.test-software.result }}" == "failure" ] || \
369 [ "${{ needs.miri-test-x86_64.result }}" == "failure" ] || \
370 [ "${{ needs.test-no-std.result }}" == "failure" ] || \
371 [ "${{ needs.test-wasm.result }}" == "failure" ] || \
372 [ "${{ needs.fuzz-test.result }}" == "failure" ]; then
373 echo "✗ One or more test jobs failed"
374 exit 1
375 fi
376
377 echo "✓ All test jobs passed"