openapi.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. name: OpenAPI
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request_target:
  7. jobs:
  8. openapi-head:
  9. name: OpenAPI - HEAD
  10. runs-on: ubuntu-latest
  11. permissions: read-all
  12. steps:
  13. - name: Checkout repository
  14. uses: actions/checkout@v3
  15. with:
  16. ref: ${{ github.event.pull_request.head.sha }}
  17. repository: ${{ github.event.pull_request.head.repo.full_name }}
  18. - name: Setup .NET Core
  19. uses: actions/setup-dotnet@v3
  20. with:
  21. dotnet-version: '6.0.x'
  22. - name: Generate openapi.json
  23. run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
  24. - name: Upload openapi.json
  25. uses: actions/upload-artifact@v3
  26. with:
  27. name: openapi-head
  28. retention-days: 14
  29. if-no-files-found: error
  30. path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
  31. openapi-base:
  32. name: OpenAPI - BASE
  33. if: ${{ github.base_ref != '' }}
  34. runs-on: ubuntu-latest
  35. permissions: read-all
  36. steps:
  37. - name: Checkout repository
  38. uses: actions/checkout@v3
  39. with:
  40. ref: ${{ github.base_ref }}
  41. - name: Setup .NET Core
  42. uses: actions/setup-dotnet@v3
  43. with:
  44. dotnet-version: '6.0.x'
  45. - name: Generate openapi.json
  46. run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
  47. - name: Upload openapi.json
  48. uses: actions/upload-artifact@v3
  49. with:
  50. name: openapi-base
  51. retention-days: 14
  52. if-no-files-found: error
  53. path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
  54. openapi-diff:
  55. name: OpenAPI - Difference
  56. if: ${{ github.event_name == 'pull_request_target' }}
  57. runs-on: ubuntu-latest
  58. needs:
  59. - openapi-head
  60. - openapi-base
  61. steps:
  62. - name: Download openapi-head
  63. uses: actions/download-artifact@v3
  64. with:
  65. name: openapi-head
  66. path: openapi-head
  67. - name: Download openapi-base
  68. uses: actions/download-artifact@v3
  69. with:
  70. name: openapi-base
  71. path: openapi-base
  72. - name: Workaround openapi-diff issue
  73. run: |
  74. sed -i 's/"allOf"/"oneOf"/g' openapi-head/openapi.json
  75. sed -i 's/"allOf"/"oneOf"/g' openapi-base/openapi.json
  76. - name: Calculate OpenAPI difference
  77. uses: docker://openapitools/openapi-diff
  78. continue-on-error: true
  79. with:
  80. args: --fail-on-changed --markdown openapi-changes.md openapi-base/openapi.json openapi-head/openapi.json
  81. - id: read-diff
  82. name: Read openapi-diff output
  83. run: |
  84. body=$(cat openapi-changes.md)
  85. body="${body//'%'/'%25'}"
  86. body="${body//$'\n'/'%0A'}"
  87. body="${body//$'\r'/'%0D'}"
  88. echo ::set-output name=body::$body
  89. - name: Find difference comment
  90. uses: peter-evans/find-comment@v2
  91. id: find-comment
  92. with:
  93. issue-number: ${{ github.event.pull_request.number }}
  94. direction: last
  95. body-includes: openapi-diff-workflow-comment
  96. - name: Reply or edit difference comment (changed)
  97. uses: peter-evans/create-or-update-comment@v2
  98. if: ${{ steps.read-diff.outputs.body != '' }}
  99. with:
  100. issue-number: ${{ github.event.pull_request.number }}
  101. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  102. edit-mode: replace
  103. body: |
  104. <!--openapi-diff-workflow-comment-->
  105. <details>
  106. <summary>Changes in OpenAPI specification found. Expand to see details.</summary>
  107. ${{ steps.read-diff.outputs.body }}
  108. </details>
  109. - name: Edit difference comment (unchanged)
  110. uses: peter-evans/create-or-update-comment@v2
  111. if: ${{ steps.read-diff.outputs.body == '' && steps.find-comment.outputs.comment-id != '' }}
  112. with:
  113. issue-number: ${{ github.event.pull_request.number }}
  114. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  115. edit-mode: replace
  116. body: |
  117. <!--openapi-diff-workflow-comment-->
  118. No changes to OpenAPI specification found. See history of this comment for previous changes.