|
| 1 | +name: 'Verify libdd-heap-sampler bindings' |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, synchronize, reopened] |
| 5 | + paths: |
| 6 | + - 'libdd-heap-sampler/**' |
| 7 | + - '.github/workflows/verify-heap-sampler-bindings.yml' |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + CARGO_INCREMENTAL: 0 |
| 11 | +jobs: |
| 12 | + verify-bindings: |
| 13 | + name: "Verify libdd-heap-sampler generated bindings are in sync" |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout sources |
| 17 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 |
| 18 | + - name: Install libclang-dev + cross libc headers |
| 19 | + # Only this verification job needs libclang; the normal build |
| 20 | + # path for libdd-heap-sampler consumes the checked-in bindings |
| 21 | + # under `src/generated/<arch>/` and does not depend on bindgen |
| 22 | + # at all. The `*-cross` packages provide `<stdint.h>`, |
| 23 | + # `<string.h>`, etc. for the non-native target arch, letting |
| 24 | + # `build.rs` regenerate both aarch64 and x86_64 bindings from a |
| 25 | + # single runner via clang's `--target=<arch>-linux-gnu` flag. |
| 26 | + run: | |
| 27 | + sudo apt-get update |
| 28 | + sudo apt-get install -y libclang-dev libc6-dev-amd64-cross libc6-dev-arm64-cross |
| 29 | + - name: Read Rust version from rust-toolchain.toml |
| 30 | + id: rust-version |
| 31 | + run: echo "version=$(grep -Po '^channel = "\K[^"]+' rust-toolchain.toml)" >> $GITHUB_OUTPUT |
| 32 | + - name: Install ${{ steps.rust-version.outputs.version }} toolchain |
| 33 | + run: rustup set profile minimal && rustup install ${{ steps.rust-version.outputs.version }} && rustup default ${{ steps.rust-version.outputs.version }} |
| 34 | + - name: Cache [rust] |
| 35 | + uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1 |
| 36 | + with: |
| 37 | + cache-targets: true |
| 38 | + cache-bin: true |
| 39 | + - name: Regenerate bindings |
| 40 | + # `LIBDD_HEAP_SAMPLER_REGEN=1` rewrites `src/generated/<arch>/*` |
| 41 | + # in-place via bindgen. If the committed files were stale the |
| 42 | + # git diff below fails and instructs the author how to refresh |
| 43 | + # them. We use an env var (rather than a cargo feature) so that |
| 44 | + # unrelated `--all-features` CI jobs cannot accidentally invoke |
| 45 | + # bindgen — see libdd-heap-sampler/Cargo.toml for the rationale. |
| 46 | + run: LIBDD_HEAP_SAMPLER_REGEN=1 cargo build -p libdd-heap-sampler |
| 47 | + - name: Verify committed bindings match regenerated output |
| 48 | + run: | |
| 49 | + if ! git diff --exit-code libdd-heap-sampler/src/generated/; then |
| 50 | + echo "::error::libdd-heap-sampler/src/generated/ is out of date." |
| 51 | + echo "Run \`LIBDD_HEAP_SAMPLER_REGEN=1 cargo build -p libdd-heap-sampler\` locally and commit the result." |
| 52 | + exit 1 |
| 53 | + fi |
0 commit comments