openapi-diff.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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: build api
  15. runs-on: ubuntu-22.04
  16. timeout-minutes: 90
  17. steps:
  18. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  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. if: steps.changes.outputs.api_docs == 'true'
  28. - name: Checkout getsentry/sentry-api-schema
  29. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  30. if: steps.changes.outputs.api_docs == 'true'
  31. with:
  32. ref: 'main'
  33. repository: getsentry/sentry-api-schema
  34. path: sentry-api-schema
  35. - uses: getsentry/action-setup-volta@e4939d337b83760d13a9d7030a6f68c9d0ee7581 # v2.0.0
  36. if: steps.changes.outputs.api_docs == 'true'
  37. - name: Build OpenAPI Derefed JSON
  38. if: steps.changes.outputs.api_docs == 'true'
  39. # install ts-node for ts build scripts to execute properly without potentially installing
  40. # conflicting deps when running scripts locally
  41. # see: https://github.com/getsentry/sentry/pull/32328/files
  42. run: |
  43. yarn add ts-node && make build-api-docs
  44. - name: Compare OpenAPI Derefed JSON
  45. if: steps.changes.outputs.api_docs == 'true'
  46. run: |
  47. npx json-diff@0.5.4 --color sentry-api-schema/openapi-derefed.json tests/apidocs/openapi-derefed.json
  48. # Do RPC compatibility checks. Combined with public API audits
  49. # to avoid workflow/job setup overhead.
  50. - name: Dump RPC schema for new version
  51. id: newschema
  52. if: steps.changes.outputs.api_docs == 'true'
  53. run: |
  54. mkdir schemas
  55. sentry rpcschema --partial > schemas/new_schema.json
  56. - name: Dump RPC schema for master
  57. id: oldschema
  58. if: steps.changes.outputs.api_docs == 'true'
  59. run: |
  60. git fetch origin
  61. git switch master
  62. sentry rpcschema --partial > schemas/old_schema.json
  63. - name: Invoke oasdiff on RPC schemas
  64. uses: oasdiff/oasdiff-action/breaking@fc826b9f0d21b85b085842521c7a8cc445412c08 # v0.0.19
  65. if: steps.changes.outputs.api_docs == 'true'
  66. with:
  67. base: ./schemas/old_schema.json
  68. revision: ./schemas/new_schema.json
  69. format: 'text'
  70. fail-on-diff: true