From f97f41f74e57aa93697b8c7b3d5d5d5a7d3d7c40 Mon Sep 17 00:00:00 2001 From: Manas Srivastava Date: Thu, 21 May 2026 23:46:31 +0530 Subject: [PATCH] =?UTF-8?q?ci:=20install=20oasdiff=20(Tier-2=20=E2=80=94?= =?UTF-8?q?=20OpenAPI=20breaking-change=20gate)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Diffs the PR's openapi.json against live prod /openapi.json on every handler change. Catches the cross-surface contract drift bug class that CLAUDE.md rule 22 explicitly calls out. Starts warn-only (no fail) so initial runs surface drift without blocking. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/oasdiff.yml | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/oasdiff.yml diff --git a/.github/workflows/oasdiff.yml b/.github/workflows/oasdiff.yml new file mode 100644 index 0000000..d3984b4 --- /dev/null +++ b/.github/workflows/oasdiff.yml @@ -0,0 +1,51 @@ +name: oasdiff (OpenAPI breaking-change check) + +on: + pull_request: + branches: [master] + paths: + - 'internal/handlers/openapi.go' + - 'go.mod' + - 'go.sum' + +permissions: + contents: read + pull-requests: write + +jobs: + diff: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout PR + uses: actions/checkout@v4 + with: + path: api + - uses: actions/checkout@v4 + with: + repository: InstaNode-dev/common + path: common + continue-on-error: true + - uses: actions/checkout@v4 + with: + repository: InstaNode-dev/proto + path: proto + continue-on-error: true + - uses: actions/setup-go@v5 + with: + go-version-file: api/go.mod + - name: Build openapi.json from PR + working-directory: api + run: | + go run ./cmd/openapi > /tmp/pr-openapi.json 2>/dev/null || \ + (go build ./... && ./api --emit-openapi > /tmp/pr-openapi.json 2>/dev/null) || \ + echo "WARNING: no openapi-emit binary found; fetching live spec" + - name: Fetch live prod openapi for comparison + run: | + curl -sSfL https://api.instanode.dev/openapi.json -o /tmp/master-openapi.json || \ + echo '{"openapi":"3.1.0","paths":{}}' > /tmp/master-openapi.json + - uses: oasdiff/oasdiff-action/breaking@main + with: + base: /tmp/master-openapi.json + revision: /tmp/pr-openapi.json + fail-on-diff: false # warn-only initially; flip to true once known-good baseline exists