Repository navigation
102 lines (89 loc) · 3.3 KB
/
Copy pathapi-diff.yml
File metadata and controls
102 lines (89 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: API compatibility
# Fails a pull request that breaks the HTTP API for existing clients. The OpenAPI document is generated by the
# backend's annotation processor (backend/build/classes/java/main/META-INF/swagger/quelea.yml), so the base and the
# head are each built from their own checkout and compared as files.
on:
pull_request:
permissions:
contents: read
jobs:
api-diff:
name: OpenAPI breaking changes
runs-on: ubuntu-latest
env:
SPEC_PATH: backend/build/classes/java/main/META-INF/swagger/quelea.yml
ONELITEFEATHER_MAVEN_USERNAME: ${{ secrets.ONELITEFEATHER_MAVEN_USERNAME }}
ONELITEFEATHER_MAVEN_PASSWORD: ${{ secrets.ONELITEFEATHER_MAVEN_PASSWORD }}
steps:
- name: Checkout the PR base
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
persist-credentials: false
- name: Checkout the PR head
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
path: head
persist-credentials: false
- name: Set up JDK 25
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: "25"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Build the OpenAPI document of the base
id: base
working-directory: base
run: |
./gradlew :backend:compileJava
mkdir -p "${GITHUB_WORKSPACE}/api-diff"
if [ -f "${SPEC_PATH}" ]; then
cp "${SPEC_PATH}" "${GITHUB_WORKSPACE}/api-diff/base.yml"
echo "present=true" >> "${GITHUB_OUTPUT}"
else
echo "present=false" >> "${GITHUB_OUTPUT}"
fi
- name: Build the OpenAPI document of the head
if: steps.base.outputs.present == 'true'
working-directory: head
run: |
./gradlew :backend:compileJava
cp "${SPEC_PATH}" "${GITHUB_WORKSPACE}/api-diff/head.yml"
- name: Explain the skipped check
if: steps.base.outputs.present != 'true'
run: echo "::notice::The base has no quelea.yml, so there is no API to compare against. Skipping the check."
- name: Summarize the API changes
if: steps.base.outputs.present == 'true'
uses: oasdiff/oasdiff-action/changelog@v0.2.0
with:
base: api-diff/base.yml
revision: api-diff/head.yml
format: markdown
output-to-file: api-diff/changelog.md
# Keep the specs inside CI: no upload to oasdiff.com and no PR comment.
review: "false"
github-token: ""
- name: Write the changelog to the job summary
if: steps.base.outputs.present == 'true'
run: |
{
echo "## API changelog"
echo
if [ -s api-diff/changelog.md ]; then
cat api-diff/changelog.md
else
echo "No API changes."
fi
} >> "${GITHUB_STEP_SUMMARY}"
- name: Fail on breaking changes
if: steps.base.outputs.present == 'true'
uses: oasdiff/oasdiff-action/breaking@v0.2.0
with:
base: api-diff/base.yml
revision: api-diff/head.yml
fail-on: ERR
review: "false"
github-token: ""