|
| 1 | +name: Breaking changes |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +on: |
| 11 | + pull_request: |
| 12 | + branches: [main] |
| 13 | + # Re-run when override labels are added or removed |
| 14 | + types: [opened, synchronize, reopened, labeled, unlabeled] |
| 15 | + |
| 16 | +jobs: |
| 17 | + proto-breaking: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + env: |
| 20 | + SKIP: ${{ contains(github.event.pull_request.labels.*.name, 'breaking-change:proto') || contains(github.event.pull_request.labels.*.name, 'breaking-change:approved') }} |
| 21 | + steps: |
| 22 | + - name: Skipped — intentional breaking change (label override) |
| 23 | + if: env.SKIP == 'true' |
| 24 | + run: | |
| 25 | + echo "::notice title=Proto breaking check skipped::This PR has label breaking-change:proto or breaking-change:approved. A maintainer acknowledged an intentional proto break. Remove the label to re-enable buf breaking." |
| 26 | +
|
| 27 | + - name: Checkout code |
| 28 | + if: env.SKIP != 'true' |
| 29 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + submodules: recursive |
| 33 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - name: Setup Bun |
| 36 | + if: env.SKIP != 'true' |
| 37 | + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 38 | + with: |
| 39 | + bun-version: 1.3.12 |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + if: env.SKIP != 'true' |
| 43 | + run: bun install --frozen-lockfile |
| 44 | + |
| 45 | + # cre-sdk's buf.yaml points at ../../submodules/chainlink-protos/cre, which buf rejects when |
| 46 | + # --against uses subdir=packages/cre-sdk (module path escapes the context). Run breaking on |
| 47 | + # the chainlink-protos workspace instead, comparing HEAD to the submodule commit pinned on main. |
| 48 | + - name: Buf breaking (proto) |
| 49 | + if: env.SKIP != 'true' |
| 50 | + run: | |
| 51 | + set -euo pipefail |
| 52 | + REPO="${{ github.workspace }}" |
| 53 | + SUBMODULE="${REPO}/submodules/chainlink-protos" |
| 54 | + BASE_COMMIT=$(git -C "$REPO" rev-parse origin/main:submodules/chainlink-protos) |
| 55 | + BASE_DIR="${RUNNER_TEMP}/chainlink-protos-baseline" |
| 56 | + if ! git -C "$SUBMODULE" cat-file -e "${BASE_COMMIT}^{commit}" 2>/dev/null; then |
| 57 | + git -C "$SUBMODULE" fetch --no-tags origin "${BASE_COMMIT}" |
| 58 | + fi |
| 59 | + git -C "$SUBMODULE" worktree add "${BASE_DIR}" "${BASE_COMMIT}" --detach |
| 60 | + cleanup() { |
| 61 | + git -C "$SUBMODULE" worktree remove "${BASE_DIR}" --force || true |
| 62 | + } |
| 63 | + trap cleanup EXIT |
| 64 | + (cd "$SUBMODULE" && bun x @bufbuild/buf breaking cre --against "${BASE_DIR}/cre" --error-format github-actions) |
| 65 | +
|
| 66 | + ts-api-surface: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + env: |
| 69 | + SKIP: ${{ contains(github.event.pull_request.labels.*.name, 'breaking-change:typescript-api') || contains(github.event.pull_request.labels.*.name, 'breaking-change:approved') }} |
| 70 | + steps: |
| 71 | + - name: Skipped — intentional breaking change (label override) |
| 72 | + if: env.SKIP == 'true' |
| 73 | + run: | |
| 74 | + echo "::notice title=TypeScript API check skipped::This PR has label breaking-change:typescript-api or breaking-change:approved. Commit an updated api-baseline.d.ts when appropriate; this label only bypasses CI." |
| 75 | +
|
| 76 | + - name: Checkout code |
| 77 | + if: env.SKIP != 'true' |
| 78 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 79 | + with: |
| 80 | + submodules: recursive |
| 81 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + |
| 83 | + - name: Setup Bun |
| 84 | + if: env.SKIP != 'true' |
| 85 | + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 86 | + with: |
| 87 | + bun-version: 1.3.12 |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + if: env.SKIP != 'true' |
| 91 | + run: bun install --frozen-lockfile |
| 92 | + |
| 93 | + - name: Diff TypeScript public API vs baseline |
| 94 | + if: env.SKIP != 'true' |
| 95 | + working-directory: packages/cre-sdk |
| 96 | + run: | |
| 97 | + bun run update-api-baseline |
| 98 | +
|
| 99 | + if ! git diff --exit-code api-baseline.d.ts; then |
| 100 | + echo "::error::TypeScript public API surface changed. Run 'bun run update-api-baseline' locally and commit the updated api-baseline.d.ts." |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | +
|
| 104 | + host-bindings: |
| 105 | + runs-on: ubuntu-latest |
| 106 | + env: |
| 107 | + SKIP: ${{ contains(github.event.pull_request.labels.*.name, 'breaking-change:host-bindings') || contains(github.event.pull_request.labels.*.name, 'breaking-change:approved') }} |
| 108 | + steps: |
| 109 | + - name: Skipped — intentional breaking change (label override) |
| 110 | + if: env.SKIP == 'true' |
| 111 | + run: | |
| 112 | + echo "::notice title=Host bindings check skipped::This PR has label breaking-change:host-bindings or breaking-change:approved. Update snapshots and host-imports-baseline.txt when appropriate; this label only bypasses CI." |
| 113 | +
|
| 114 | + - name: Checkout code |
| 115 | + if: env.SKIP != 'true' |
| 116 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 117 | + with: |
| 118 | + submodules: recursive |
| 119 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + |
| 121 | + - name: Setup Bun |
| 122 | + if: env.SKIP != 'true' |
| 123 | + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 124 | + with: |
| 125 | + bun-version: 1.3.12 |
| 126 | + |
| 127 | + - name: Install dependencies |
| 128 | + if: env.SKIP != 'true' |
| 129 | + run: bun install --frozen-lockfile |
| 130 | + |
| 131 | + - name: JS host bindings snapshot test |
| 132 | + if: env.SKIP != 'true' |
| 133 | + working-directory: packages/cre-sdk |
| 134 | + run: bun test src/sdk/wasm/host-bindings-contract.test.ts |
| 135 | + |
| 136 | + - name: Diff Rust host imports vs baseline |
| 137 | + if: env.SKIP != 'true' |
| 138 | + run: | |
| 139 | + grep -E '^\s+fn [a-z_]+\(' \ |
| 140 | + packages/cre-sdk-javy-plugin/src/javy_chainlink_sdk/src/lib.rs \ |
| 141 | + | grep -v '{$' > /tmp/current-imports.txt |
| 142 | +
|
| 143 | + if ! diff packages/cre-sdk-javy-plugin/src/javy_chainlink_sdk/host-imports-baseline.txt \ |
| 144 | + /tmp/current-imports.txt; then |
| 145 | + echo "::error::Rust host import signatures changed. Update host-imports-baseline.txt if intentional." |
| 146 | + exit 1 |
| 147 | + fi |
0 commit comments