openapi-diff.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. name: openapi-diff
  2. on:
  3. pull_request:
  4. # Cancel in progress workflows on pull_requests.
  5. # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
  6. concurrency:
  7. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  8. cancel-in-progress: true
  9. # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
  10. env:
  11. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
  12. jobs:
  13. check-diff:
  14. name: (Optional) Shows the difference between the prod and dev schema
  15. runs-on: ubuntu-24.04
  16. timeout-minutes: 90
  17. steps:
  18. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  19. - name: Check for python file changes
  20. uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
  21. id: changes
  22. with:
  23. token: ${{ github.token }}
  24. filters: .github/file-filters.yml
  25. - name: Setup sentry env
  26. uses: ./.github/actions/setup-sentry
  27. with:
  28. use-new-devservices: true
  29. mode: migrations
  30. if: steps.changes.outputs.api_docs == 'true'
  31. - name: Checkout getsentry/sentry-api-schema
  32. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  33. if: steps.changes.outputs.api_docs == 'true'
  34. with:
  35. ref: 'main'
  36. repository: getsentry/sentry-api-schema
  37. path: sentry-api-schema
  38. - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
  39. id: setup-node
  40. with:
  41. node-version-file: '.volta.json'
  42. - name: Build OpenAPI Derefed JSON
  43. if: steps.changes.outputs.api_docs == 'true'
  44. # install ts-node for ts build scripts to execute properly without potentially installing
  45. # conflicting deps when running scripts locally
  46. # see: https://github.com/getsentry/sentry/pull/32328/files
  47. run: |
  48. yarn add ts-node && make build-api-docs
  49. - name: Compare OpenAPI Derefed JSON
  50. if: steps.changes.outputs.api_docs == 'true'
  51. run: |
  52. npx json-diff@0.5.4 --color sentry-api-schema/openapi-derefed.json tests/apidocs/openapi-derefed.json
  53. - name: Dump RPC schema for new version
  54. id: newschema
  55. if: steps.changes.outputs.api_docs == 'true'
  56. run: |
  57. mkdir schemas
  58. sentry rpcschema > rpc_method_schema.json
  59. - name: Output RPC schema comparison
  60. uses: oasdiff/oasdiff-action/breaking@a2ff6682b27d175162a74c09ace8771bd3d512f8 # A few commits after v0.0.19 to get fixes
  61. if: steps.changes.outputs.api_docs == 'true'
  62. with:
  63. base: sentry-api-schema/rpc_method_schema.json
  64. revision: ./rpc_method_schema.json
  65. fail-on: WARN