poulpy/.github/workflows/ci.yml
.github/workflows/ci.ymlRaw
1name: CI
2
3on:
4 push:
5 branches: [ main ]
6 pull_request:
7 branches: [ main ]
8
9jobs:
10 build-and-test:
11 runs-on: ubuntu-latest
12
13 steps:
14 - name: Checkout
15 uses: actions/checkout@v4
16 with:
17 submodules: recursive
18
19 - name: Install Rust nightly
20 uses: dtolnay/rust-toolchain@nightly
21 with:
22 components: clippy, rustfmt
23
24 - name: Cache cargo deps
25 uses: actions/cache@v4
26 with:
27 path: |
28 ~/.cargo/registry
29 ~/.cargo/git
30 target
31 key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32 restore-keys: |
33 ${{ runner.os }}-cargo-
34
35 # Detect whether runner supports AVX2 + FMA
36 - name: Detect AVX support
37 id: avxcheck
38 run: |
39 if lscpu | grep -qi avx2 && lscpu | grep -qi fma; then
40 echo "supported=true" >> $GITHUB_OUTPUT
41 else
42 echo "supported=false" >> $GITHUB_OUTPUT
43 fi
44
45 # rustfmt always runs — unrelated to AVX support
46 - name: rustfmt (check only)
47 run: cargo fmt --all --check
48
49 # Build / lint / test WITH AVX
50 - name: Build (AVX enabled)
51 if: steps.avxcheck.outputs.supported == 'true'
52 run: |
53 RUSTFLAGS="-C target-feature=+avx2,+fma" \
54 cargo build --workspace --all-targets --features enable-avx
55
56 - name: Clippy (AVX enabled)
57 if: steps.avxcheck.outputs.supported == 'true'
58 run: |
59 RUSTFLAGS="-C target-feature=+avx2,+fma" \
60 cargo clippy --workspace --all-targets --features enable-avx -- -D warnings
61
62 - name: Tests (AVX enabled)
63 if: steps.avxcheck.outputs.supported == 'true'
64 run: |
65 RUSTFLAGS="-C target-feature=+avx2,+fma" \
66 cargo test --workspace --features enable-avx
67
68 # Build / lint / test WITHOUT AVX
69 - name: Build (portable mode)
70 if: steps.avxcheck.outputs.supported == 'false'
71 run: cargo build --workspace --all-targets
72
73 - name: Clippy (portable mode)
74 if: steps.avxcheck.outputs.supported == 'false'
75 run: cargo clippy --workspace --all-targets -- -D warnings
76
77 - name: Tests (portable mode)
78 if: steps.avxcheck.outputs.supported == 'false'
79 run: cargo test --workspace