2021-07-12 04:06:13 -04:00
|
|
|
name: OpenAPI
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2021-11-05 14:09:44 -04:00
|
|
|
pull_request_target:
|
2021-07-12 04:06:13 -04:00
|
|
|
|
2022-12-03 10:47:30 -05:00
|
|
|
permissions: {}
|
|
|
|
|
2021-07-12 04:06:13 -04:00
|
|
|
jobs:
|
|
|
|
openapi-head:
|
|
|
|
name: OpenAPI - HEAD
|
|
|
|
runs-on: ubuntu-latest
|
2021-11-05 17:43:09 -04:00
|
|
|
permissions: read-all
|
2021-07-12 04:06:13 -04:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-10-17 20:15:17 -04:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2021-11-05 14:09:44 -04:00
|
|
|
with:
|
2022-02-19 11:36:53 -05:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2021-11-05 17:12:43 -04:00
|
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
2022-11-09 09:28:52 -05:00
|
|
|
- name: Setup .NET
|
2023-12-04 10:55:08 -05:00
|
|
|
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
2021-07-12 04:06:13 -04:00
|
|
|
with:
|
2023-11-15 10:16:51 -05:00
|
|
|
dotnet-version: '8.0.x'
|
2021-07-12 04:06:13 -04:00
|
|
|
- name: Generate openapi.json
|
2021-09-15 13:32:55 -04: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 04:06:13 -04:00
|
|
|
- name: Upload openapi.json
|
2024-02-05 17:58:13 -05:00
|
|
|
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
|
2021-07-12 04:06:13 -04:00
|
|
|
with:
|
|
|
|
name: openapi-head
|
|
|
|
retention-days: 14
|
|
|
|
if-no-files-found: error
|
2023-10-23 17:36:56 -04:00
|
|
|
path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net8.0/openapi.json
|
2021-07-12 04:06:13 -04:00
|
|
|
|
|
|
|
openapi-base:
|
|
|
|
name: OpenAPI - BASE
|
|
|
|
if: ${{ github.base_ref != '' }}
|
|
|
|
runs-on: ubuntu-latest
|
2021-11-05 17:43:09 -04:00
|
|
|
permissions: read-all
|
2021-07-12 04:06:13 -04:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-10-17 20:15:17 -04:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2021-07-12 04:06:13 -04:00
|
|
|
with:
|
2022-12-30 10:08:02 -05:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Checkout common ancestor
|
2023-06-19 09:56:15 -04:00
|
|
|
env:
|
|
|
|
HEAD_REF: ${{ github.head_ref }}
|
2022-12-30 10:08:02 -05:00
|
|
|
run: |
|
|
|
|
git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}
|
|
|
|
git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules upstream +refs/heads/*:refs/remotes/upstream/* +refs/tags/*:refs/tags/*
|
2023-06-19 10:51:01 -04:00
|
|
|
ANCESTOR_REF=$(git merge-base upstream/${{ github.base_ref }} origin/$HEAD_REF)
|
2022-12-30 10:08:02 -05:00
|
|
|
git checkout --progress --force $ANCESTOR_REF
|
2022-11-09 09:28:52 -05:00
|
|
|
- name: Setup .NET
|
2023-12-04 10:55:08 -05:00
|
|
|
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
|
2021-07-12 04:06:13 -04:00
|
|
|
with:
|
2023-11-15 10:16:51 -05:00
|
|
|
dotnet-version: '8.0.x'
|
2021-07-12 04:06:13 -04:00
|
|
|
- name: Generate openapi.json
|
2021-09-15 13:32:55 -04: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 04:06:13 -04:00
|
|
|
- name: Upload openapi.json
|
2024-02-05 17:58:13 -05:00
|
|
|
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
|
2021-07-12 04:06:13 -04:00
|
|
|
with:
|
|
|
|
name: openapi-base
|
|
|
|
retention-days: 14
|
|
|
|
if-no-files-found: error
|
2023-10-23 17:36:56 -04:00
|
|
|
path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net8.0/openapi.json
|
2021-07-12 04:06:13 -04:00
|
|
|
|
|
|
|
openapi-diff:
|
2022-12-03 10:47:30 -05:00
|
|
|
permissions:
|
|
|
|
pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
|
|
|
|
|
2021-07-12 04:06:13 -04:00
|
|
|
name: OpenAPI - Difference
|
2021-11-05 14:09:44 -04:00
|
|
|
if: ${{ github.event_name == 'pull_request_target' }}
|
2021-07-12 04:06:13 -04:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- openapi-head
|
|
|
|
- openapi-base
|
|
|
|
steps:
|
|
|
|
- name: Download openapi-head
|
2024-02-26 18:08:21 -05:00
|
|
|
uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3
|
2021-07-12 04:06:13 -04:00
|
|
|
with:
|
|
|
|
name: openapi-head
|
|
|
|
path: openapi-head
|
|
|
|
- name: Download openapi-base
|
2024-02-26 18:08:21 -05:00
|
|
|
uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3
|
2021-07-12 04:06:13 -04: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
|
2024-01-25 07:09:55 -05:00
|
|
|
uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e # v3.0.0
|
2021-07-12 04:06:13 -04: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)
|
2024-01-25 07:09:48 -05:00
|
|
|
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
|
2021-07-12 04:06:13 -04: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)
|
2024-01-25 07:09:48 -05:00
|
|
|
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
|
2021-07-12 04:06:13 -04: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.
|