openapi-diff.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-20.04
  16. timeout-minutes: 90
  17. steps:
  18. - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  19. with:
  20. # Avoid codecov error message related to SHA resolution:
  21. # https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
  22. fetch-depth: '2'
  23. - name: Check for python file changes
  24. uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
  25. id: changes
  26. with:
  27. token: ${{ github.token }}
  28. filters: .github/file-filters.yml
  29. - name: Setup sentry env
  30. uses: ./.github/actions/setup-sentry
  31. if: steps.changes.outputs.api_docs == 'true'
  32. id: setup
  33. - name: Checkout getsentry/sentry-api-schema
  34. uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  35. if: steps.changes.outputs.api_docs == 'true'
  36. with:
  37. ref: 'main'
  38. repository: getsentry/sentry-api-schema
  39. path: sentry-api-schema
  40. - uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
  41. if: steps.changes.outputs.api_docs == 'true'
  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