openapi.yml 4.5 KB

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