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