openapi.yml 4.3 KB

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