2021-07-12 01:06:13 -07:00
|
|
|
name: OpenAPI
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2021-11-05 11:09:44 -07:00
|
|
|
pull_request_target:
|
2021-07-12 01:06:13 -07:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
openapi-head:
|
|
|
|
name: OpenAPI - HEAD
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2021-11-05 11:09:44 -07:00
|
|
|
with:
|
2021-11-05 14:12:43 -07:00
|
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
2021-07-12 01:06:13 -07:00
|
|
|
- name: Setup .NET Core
|
|
|
|
uses: actions/setup-dotnet@v1
|
|
|
|
with:
|
2021-11-02 10:55:07 -07:00
|
|
|
dotnet-version: '6.0.x'
|
|
|
|
include-prerelease: true
|
2021-07-12 01:06:13 -07:00
|
|
|
- name: Generate openapi.json
|
2021-09-15 10:32:55 -07: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 01:06:13 -07:00
|
|
|
- name: Upload openapi.json
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: openapi-head
|
|
|
|
retention-days: 14
|
|
|
|
if-no-files-found: error
|
2021-11-02 10:55:07 -07:00
|
|
|
path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
|
2021-07-12 01:06:13 -07:00
|
|
|
|
|
|
|
openapi-base:
|
|
|
|
name: OpenAPI - BASE
|
|
|
|
if: ${{ github.base_ref != '' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
ref: ${{ github.base_ref }}
|
|
|
|
- name: Setup .NET Core
|
|
|
|
uses: actions/setup-dotnet@v1
|
|
|
|
with:
|
2021-11-02 10:55:07 -07:00
|
|
|
dotnet-version: '6.0.x'
|
|
|
|
include-prerelease: true
|
2021-07-12 01:06:13 -07:00
|
|
|
- name: Generate openapi.json
|
2021-09-15 10:32:55 -07: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 01:06:13 -07:00
|
|
|
- name: Upload openapi.json
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: openapi-base
|
|
|
|
retention-days: 14
|
|
|
|
if-no-files-found: error
|
2021-11-02 10:55:07 -07:00
|
|
|
path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
|
2021-07-12 01:06:13 -07:00
|
|
|
|
|
|
|
openapi-diff:
|
|
|
|
name: OpenAPI - Difference
|
2021-11-05 11:09:44 -07:00
|
|
|
if: ${{ github.event_name == 'pull_request_target' }}
|
2021-07-12 01:06:13 -07:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- openapi-head
|
|
|
|
- openapi-base
|
|
|
|
steps:
|
|
|
|
- name: Download openapi-head
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: openapi-head
|
|
|
|
path: openapi-head
|
|
|
|
- name: Download openapi-base
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
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
|
|
|
|
uses: peter-evans/find-comment@v1
|
|
|
|
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)
|
|
|
|
uses: peter-evans/create-or-update-comment@v1.4.5
|
|
|
|
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)
|
|
|
|
uses: peter-evans/create-or-update-comment@v1.4.5
|
|
|
|
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.
|