|
| 1 | +name: ci |
| 2 | + |
| 3 | +# Core CI: formatting, linting, workspace tests, and a publish dry-run |
| 4 | +# of hyperdb-bootstrap. Separate from verify-hyperd-pin.yml, which only |
| 5 | +# HEADs the pinned release's URLs. |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + pull_request: {} |
| 11 | + workflow_dispatch: {} |
| 12 | + |
| 13 | +# Cancel a PR's in-progress CI runs when a new push lands on the PR. |
| 14 | +# Pushes to main always run to completion. |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 18 | + |
| 19 | +env: |
| 20 | + CARGO_TERM_COLOR: always |
| 21 | + RUST_BACKTRACE: 1 |
| 22 | + |
| 23 | +jobs: |
| 24 | + fmt: |
| 25 | + name: rustfmt |
| 26 | + runs-on: ubuntu-latest |
| 27 | + timeout-minutes: 10 |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v6 |
| 30 | + - uses: dtolnay/rust-toolchain@stable |
| 31 | + with: |
| 32 | + components: rustfmt |
| 33 | + - run: cargo fmt --all --check |
| 34 | + |
| 35 | + clippy: |
| 36 | + # Clippy lints are platform-independent, so a single runner is enough. |
| 37 | + # If a lint ever diverges by target (rare), broaden the matrix. |
| 38 | + name: clippy |
| 39 | + runs-on: ubuntu-latest |
| 40 | + timeout-minutes: 30 |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v6 |
| 43 | + - name: Install system libraries (fontconfig for plotters, mold for fast linking, protobuf) |
| 44 | + run: sudo apt-get update -q && sudo apt-get install -y libfontconfig1-dev mold protobuf-compiler |
| 45 | + - uses: dtolnay/rust-toolchain@stable |
| 46 | + with: |
| 47 | + components: clippy |
| 48 | + - uses: Swatinem/rust-cache@v2 |
| 49 | + with: |
| 50 | + key: clippy |
| 51 | + - name: Clippy (workspace, all targets) |
| 52 | + # Every crate in the workspace is linted under the Microsoft Rust |
| 53 | + # Guidelines config in `[workspace.lints]` (see Cargo.toml and |
| 54 | + # docs/RUST_GUIDELINES.md). Warnings are treated as errors. |
| 55 | + run: cargo clippy --workspace --all-targets --all-features -- -D warnings |
| 56 | + |
| 57 | + test: |
| 58 | + name: test (${{ matrix.os }}) |
| 59 | + runs-on: ${{ matrix.os }} |
| 60 | + timeout-minutes: 45 |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + os: [ubuntu-latest, macos-14, windows-latest] |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v6 |
| 67 | + - name: Free disk space (Linux only) |
| 68 | + if: runner.os == 'Linux' |
| 69 | + run: | |
| 70 | + sudo rm -rf /usr/local/lib/android |
| 71 | + sudo rm -rf /usr/share/dotnet |
| 72 | + sudo rm -rf /opt/ghc |
| 73 | + sudo rm -rf /usr/local/share/boost |
| 74 | + - name: Install system libraries (Linux) |
| 75 | + if: runner.os == 'Linux' |
| 76 | + run: sudo apt-get update -q && sudo apt-get install -y libfontconfig1-dev mold protobuf-compiler |
| 77 | + - name: Install protobuf (macOS) |
| 78 | + if: runner.os == 'macOS' |
| 79 | + run: brew install protobuf |
| 80 | + - name: Install protobuf (Windows) |
| 81 | + if: runner.os == 'Windows' |
| 82 | + run: choco install protoc -y |
| 83 | + - uses: dtolnay/rust-toolchain@stable |
| 84 | + - name: Ensure cargo is on PATH |
| 85 | + run: echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" |
| 86 | + - uses: Swatinem/rust-cache@v2 |
| 87 | + with: |
| 88 | + # Keep this cache separate from the clippy job's; the test |
| 89 | + # profile has different artifacts and mixing them causes |
| 90 | + # unnecessary rebuilds. |
| 91 | + key: test-${{ matrix.os }} |
| 92 | + |
| 93 | + - name: Cache hyperd binary |
| 94 | + # Keyed on the pinned release file, so bumping the pin |
| 95 | + # (hyperdb-bootstrap/hyperd-version.toml) invalidates the cache |
| 96 | + # automatically and the next run re-downloads. |
| 97 | + id: hyperd-cache |
| 98 | + uses: actions/cache@v4 |
| 99 | + with: |
| 100 | + path: .hyperd |
| 101 | + key: hyperd-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('hyperdb-bootstrap/hyperd-version.toml') }} |
| 102 | + |
| 103 | + - name: Download hyperd |
| 104 | + if: steps.hyperd-cache.outputs.cache-hit != 'true' |
| 105 | + run: cargo run --release -p hyperdb-bootstrap --bin hyperdb-bootstrap -- download |
| 106 | + |
| 107 | + - name: Workspace tests |
| 108 | + shell: bash |
| 109 | + env: |
| 110 | + # .hyperd/current accepts either a file or directory per the |
| 111 | + # hyperdb-api process loader; passing the directory keeps the |
| 112 | + # command identical across OSes (hyperd vs hyperd.exe). |
| 113 | + HYPERD_PATH: ${{ github.workspace }}/.hyperd/current |
| 114 | + run: | |
| 115 | + cargo test --workspace \ |
| 116 | + --exclude hyperdb-api-node \ |
| 117 | + --exclude hyperdb-bootstrap |
| 118 | + # hyperdb-api-node needs napi-rs + a Node.js toolchain; it gets |
| 119 | + # its own workflow when wired up. hyperdb-bootstrap has its own |
| 120 | + # coverage (next step) and doesn't need hyperd running. |
| 121 | + |
| 122 | + - name: hyperdb-bootstrap tests |
| 123 | + run: cargo test -p hyperdb-bootstrap |
| 124 | + |
| 125 | + publish-dry-run: |
| 126 | + # Catches Cargo.toml metadata regressions (missing license, bad |
| 127 | + # include paths, etc.) on the subset of crates that have no |
| 128 | + # workspace deps — those are the only ones `cargo publish --dry-run` |
| 129 | + # can check before anything's on crates.io. The other 4 crates |
| 130 | + # (hyperdb-api-core, hyperdb-api-salesforce, hyperdb-api, hyperdb-mcp) |
| 131 | + # resolve their path+version deps against the live index, which can't |
| 132 | + # succeed until those deps are themselves published. (Note: |
| 133 | + # hyperdb-api-core has an optional workspace dep on |
| 134 | + # hyperdb-api-salesforce via its `salesforce-auth` feature, which |
| 135 | + # triggers the same path-resolution failure even though the dep is |
| 136 | + # optional.) They're exercised end-to-end by release.yml at tag |
| 137 | + # time, when the whole wave ships together. |
| 138 | + name: publish dry-run |
| 139 | + runs-on: ubuntu-latest |
| 140 | + timeout-minutes: 15 |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v6 |
| 143 | + - name: Install mold linker |
| 144 | + run: sudo apt-get update -q && sudo apt-get install -y mold |
| 145 | + - uses: dtolnay/rust-toolchain@stable |
| 146 | + - uses: Swatinem/rust-cache@v2 |
| 147 | + with: |
| 148 | + key: publish-dry-run |
| 149 | + - run: | |
| 150 | + cargo publish -p hyperdb-bootstrap --dry-run |
| 151 | + cargo publish -p sea-query-hyperdb --dry-run |
| 152 | +
|
| 153 | + deny: |
| 154 | + # Enforces license allowlist, advisory ignore list, and banned-source |
| 155 | + # rules from deny.toml. Pairs with the `audit` job — `cargo-deny` and |
| 156 | + # `cargo-audit` have separate ignore mechanisms; both must agree. |
| 157 | + name: cargo-deny |
| 158 | + runs-on: ubuntu-latest |
| 159 | + timeout-minutes: 10 |
| 160 | + steps: |
| 161 | + - uses: actions/checkout@v6 |
| 162 | + - uses: EmbarkStudios/cargo-deny-action@v2 |
| 163 | + with: |
| 164 | + command: check |
| 165 | + arguments: --all-features --workspace |
| 166 | + |
| 167 | + audit: |
| 168 | + # Enforces the RustSec advisory ignore list in .cargo/audit.toml. |
| 169 | + # Fails on any unfixed advisory for a crate in the lockfile. |
| 170 | + name: cargo-audit |
| 171 | + runs-on: ubuntu-latest |
| 172 | + timeout-minutes: 10 |
| 173 | + steps: |
| 174 | + - uses: actions/checkout@v6 |
| 175 | + - uses: dtolnay/rust-toolchain@stable |
| 176 | + - uses: Swatinem/rust-cache@v2 |
| 177 | + with: |
| 178 | + key: audit |
| 179 | + - run: cargo install cargo-audit --locked |
| 180 | + - run: cargo audit --deny warnings |
0 commit comments