|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +env: |
| 16 | + CARGO_TERM_COLOR: always |
| 17 | + # Override the [profile.release] settings from Cargo.toml for CI: fat-LTO + |
| 18 | + # codegen-units=1 are great for release binaries but ~10× slower to compile |
| 19 | + # than thin-LTO, which bites hard on every matrix leg. Release binaries in |
| 20 | + # release.yml unset these so they get the real profile. |
| 21 | + CARGO_PROFILE_RELEASE_LTO: "thin" |
| 22 | + CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16" |
| 23 | + |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + name: Test (${{ matrix.name }}) |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - name: linux-x86_64 |
| 33 | + os: ubuntu-latest |
| 34 | + - name: linux-x86_64-v3 |
| 35 | + os: ubuntu-latest |
| 36 | + target_cpu: x86-64-v3 |
| 37 | + - name: linux-aarch64 |
| 38 | + os: ubuntu-24.04-arm |
| 39 | + - name: macos-aarch64 |
| 40 | + os: macos-latest |
| 41 | + - name: windows-x86_64 |
| 42 | + os: windows-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 |
| 45 | + |
| 46 | + - name: Install Rust toolchain |
| 47 | + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable |
| 48 | + |
| 49 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1 |
| 50 | + |
| 51 | + - name: Detect host triple |
| 52 | + if: matrix.target_cpu |
| 53 | + shell: bash |
| 54 | + run: echo "HOST_TRIPLE=$(rustc -vV | awk '/^host:/ {print $2}')" >> "$GITHUB_ENV" |
| 55 | + |
| 56 | + - name: Build |
| 57 | + shell: bash |
| 58 | + run: > |
| 59 | + cargo build --release |
| 60 | + ${TARGET_CPU:+--target "$HOST_TRIPLE" --config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"} |
| 61 | + env: |
| 62 | + TARGET_CPU: ${{ matrix.target_cpu || '' }} |
| 63 | + |
| 64 | + - name: Test |
| 65 | + shell: bash |
| 66 | + run: > |
| 67 | + cargo test --release |
| 68 | + ${TARGET_CPU:+--target "$HOST_TRIPLE" --config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"} |
| 69 | + env: |
| 70 | + TARGET_CPU: ${{ matrix.target_cpu || '' }} |
| 71 | + |
| 72 | + fmt: |
| 73 | + name: Formatting |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 |
| 77 | + - uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable |
| 78 | + with: |
| 79 | + components: rustfmt |
| 80 | + - run: cargo fmt --check |
| 81 | + |
| 82 | + clippy: |
| 83 | + name: Clippy |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 |
| 87 | + |
| 88 | + - name: Install Rust toolchain |
| 89 | + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@stable |
| 90 | + with: |
| 91 | + components: clippy |
| 92 | + |
| 93 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1 |
| 94 | + |
| 95 | + - run: cargo clippy -- -D warnings |
| 96 | + |
| 97 | + msrv: |
| 98 | + name: MSRV check |
| 99 | + runs-on: ubuntu-latest |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 |
| 102 | + |
| 103 | + - name: Install Rust MSRV toolchain |
| 104 | + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # ratchet:dtolnay/rust-toolchain@master |
| 105 | + with: |
| 106 | + toolchain: "1.88" |
| 107 | + |
| 108 | + - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1 |
| 109 | + |
| 110 | + - name: Check MSRV compiles |
| 111 | + run: cargo check |
| 112 | + |
| 113 | + audit: |
| 114 | + name: Security audit |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 |
| 118 | + - uses: rustsec/audit-check@v2 |
| 119 | + with: |
| 120 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments