2021-07-12 08:06:13 +00:00
|
|
|
name: OpenAPI
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2021-11-05 18:09:44 +00:00
|
|
|
pull_request_target:
|
2021-07-12 08:06:13 +00:00
|
|
|
|
2022-12-03 15:47:30 +00:00
|
|
|
permissions: {}
|
|
|
|
|
2021-07-12 08:06:13 +00:00
|
|
|
jobs:
|
|
|
|
openapi-head:
|
|
|
|
name: OpenAPI - HEAD
|
|
|
|
runs-on: ubuntu-latest
|
2021-11-05 21:43:09 +00:00
|
|
|
permissions: read-all
|
2021-07-12 08:06:13 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-12-13 12:45:54 +00:00
|
|
|
uses: actions/checkout@7dd9e2a3dc350cf687eb1b2a4fadfee8c8e49675 # v3
|
2021-11-05 18:09:44 +00:00
|
|
|
with:
|
2022-02-19 16:36:53 +00:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2021-11-05 21:12:43 +00:00
|
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
2022-11-09 14:28:52 +00:00
|
|
|
- name: Setup .NET
|
2022-10-28 15:43:14 +00:00
|
|
|
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
2022-11-09 14:28:52 +00:00
|
|
|
dotnet-version: '7.0.x'
|
2021-07-12 08:06:13 +00:00
|
|
|
- name: Generate openapi.json
|
2021-09-15 17:32:55 +00:00
|
|
|
run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
|
2021-07-12 08:06:13 +00:00
|
|
|
- name: Upload openapi.json
|
2022-11-03 14:59:20 +00:00
|
|
|
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
|
|
|
name: openapi-head
|
|
|
|
retention-days: 14
|
|
|
|
if-no-files-found: error
|
2022-11-09 14:28:52 +00:00
|
|
|
path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net7.0/openapi.json
|
2021-07-12 08:06:13 +00:00
|
|
|
|
|
|
|
openapi-base:
|
|
|
|
name: OpenAPI - BASE
|
|
|
|
if: ${{ github.base_ref != '' }}
|
|
|
|
runs-on: ubuntu-latest
|
2021-11-05 21:43:09 +00:00
|
|
|
permissions: read-all
|
2021-07-12 08:06:13 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-12-13 12:45:54 +00:00
|
|
|
uses: actions/checkout@7dd9e2a3dc350cf687eb1b2a4fadfee8c8e49675 # v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.base_ref }}
|
2022-11-09 14:28:52 +00:00
|
|
|
- name: Setup .NET
|
2022-10-28 15:43:14 +00:00
|
|
|
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
2022-11-09 14:28:52 +00:00
|
|
|
dotnet-version: '7.0.x'
|
2021-07-12 08:06:13 +00:00
|
|
|
- name: Generate openapi.json
|
2021-09-15 17:32:55 +00:00
|
|
|
run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
|
2021-07-12 08:06:13 +00:00
|
|
|
- name: Upload openapi.json
|
2022-11-03 14:59:20 +00:00
|
|
|
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
|
|
|
name: openapi-base
|
|
|
|
retention-days: 14
|
|
|
|
if-no-files-found: error
|
2022-11-09 14:28:52 +00:00
|
|
|
path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net7.0/openapi.json
|
2021-07-12 08:06:13 +00:00
|
|
|
|
|
|
|
openapi-diff:
|
2022-12-03 15:47:30 +00:00
|
|
|
permissions:
|
|
|
|
pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
|
|
|
|
|
2021-07-12 08:06:13 +00:00
|
|
|
name: OpenAPI - Difference
|
2021-11-05 18:09:44 +00:00
|
|
|
if: ${{ github.event_name == 'pull_request_target' }}
|
2021-07-12 08:06:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- openapi-head
|
|
|
|
- openapi-base
|
|
|
|
steps:
|
|
|
|
- name: Download openapi-head
|
2022-11-03 14:59:31 +00:00
|
|
|
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # tag=v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
|
|
|
name: openapi-head
|
|
|
|
path: openapi-head
|
|
|
|
- name: Download openapi-base
|
2022-11-03 14:59:31 +00:00
|
|
|
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # tag=v3
|
2021-07-12 08:06:13 +00:00
|
|
|
with:
|
|
|
|
name: openapi-base
|
|
|
|
path: openapi-base
|
|
|
|
- name: Workaround openapi-diff issue
|
|
|
|
run: |
|
|
|
|
sed -i 's/"allOf"/"oneOf"/g' openapi-head/openapi.json
|
|
|
|
sed -i 's/"allOf"/"oneOf"/g' openapi-base/openapi.json
|
|
|
|
- name: Calculate OpenAPI difference
|
|
|
|
uses: docker://openapitools/openapi-diff
|
|
|
|
continue-on-error: true
|
|
|
|
with:
|
|
|
|
args: --fail-on-changed --markdown openapi-changes.md openapi-base/openapi.json openapi-head/openapi.json
|
|
|
|
- id: read-diff
|
|
|
|
name: Read openapi-diff output
|
|
|
|
run: |
|
|
|
|
body=$(cat openapi-changes.md)
|
|
|
|
body="${body//'%'/'%25'}"
|
|
|
|
body="${body//$'\n'/'%0A'}"
|
|
|
|
body="${body//$'\r'/'%0D'}"
|
|
|
|
echo ::set-output name=body::$body
|
|
|
|
- name: Find difference comment
|
2022-12-01 14:26:18 +00:00
|
|
|
uses: peter-evans/find-comment@f4499a714d59013c74a08789b48abe4b704364a0 # v2
|
2021-07-12 08:06:13 +00:00
|
|
|
id: find-comment
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
direction: last
|
|
|
|
body-includes: openapi-diff-workflow-comment
|
|
|
|
- name: Reply or edit difference comment (changed)
|
2022-10-26 13:19:07 +00:00
|
|
|
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # tag=v2
|
2021-07-12 08:06:13 +00:00
|
|
|
if: ${{ steps.read-diff.outputs.body != '' }}
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
|
|
|
edit-mode: replace
|
|
|
|
body: |
|
|
|
|
<!--openapi-diff-workflow-comment-->
|
|
|
|
<details>
|
|
|
|
<summary>Changes in OpenAPI specification found. Expand to see details.</summary>
|
|
|
|
|
|
|
|
${{ steps.read-diff.outputs.body }}
|
|
|
|
|
|
|
|
</details>
|
|
|
|
- name: Edit difference comment (unchanged)
|
2022-10-26 13:19:07 +00:00
|
|
|
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # tag=v2
|
2021-07-12 08:06:13 +00:00
|
|
|
if: ${{ steps.read-diff.outputs.body == '' && steps.find-comment.outputs.comment-id != '' }}
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
|
|
|
edit-mode: replace
|
|
|
|
body: |
|
|
|
|
<!--openapi-diff-workflow-comment-->
|
|
|
|
|
|
|
|
No changes to OpenAPI specification found. See history of this comment for previous changes.
|