Repository navigation
132 lines (114 loc) · 4.43 KB
/
Copy pathci.yml
File metadata and controls
132 lines (114 loc) · 4.43 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Builds and tests every push to master and every pull request.
name: CI
on:
push:
branches: [master]
paths-ignore: ['**.md', '**.adoc']
pull_request:
paths-ignore: ['**.md', '**.adoc']
workflow_dispatch:
# Supersede in-flight runs for the same ref.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
# The plugin compiles with a Java 8 toolchain: use the JDK 8 installed by setup-java
# instead of downloading one.
env:
GRADLE_ARGS: --console=plain -Porg.gradle.java.installations.fromEnv=JAVA_HOME_8_X64 -Porg.gradle.java.installations.auto-download=false
jobs:
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
# Windows too: the long-classpath pathing jar and stopping the application work differently there.
matrix:
os: [ubuntu-latest, windows-latest]
defaults:
run:
# Git Bash on Windows, so that $GRADLE_ARGS and ./gradlew work the same everywhere
shell: bash
steps:
- uses: actions/checkout@v7
# The last version listed is the default JDK that runs Gradle: plugin-publish 2.x needs 17. The plugin itself
# is still compiled for, and tested on, the Java 8 toolchain.
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: |
8
17
# Caches Gradle and validates the wrapper.
- uses: gradle/actions/setup-gradle@v5
# build = tests + detekt.
- name: Build
run: ./gradlew $GRADLE_ARGS build
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@v7
with:
name: test-reports-${{ matrix.os }}
path: build/reports/
# Checks that the plugin from this commit works with the public demo projects (demo-2 is private, so the
# workflow token cannot check it out).
demo:
name: Demo (${{ matrix.demo.name }})
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
demo:
- name: Spring Boot 2
repository: springdoc/springdoc-openapi-gradle-plugin-demo
build-file: build.gradle
output: build/swagger.json
- name: Spring Boot 4
repository: springdoc/springdoc-openapi-gradle-plugin-demo-3
build-file: build.gradle.kts
output: build/openapi.json
# The oldest supported Gradle version
- name: Spring Boot 2, Gradle 8.0
repository: springdoc/springdoc-openapi-gradle-plugin-demo
build-file: build.gradle
output: build/swagger.json
gradle-version: 8.0.2
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: ${{ matrix.demo.repository }}
path: demo
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: |
8
17
- uses: gradle/actions/setup-gradle@v5
- name: Publish the plugin to Maven Local
run: ./gradlew $GRADLE_ARGS publishToMavenLocal
# The demo resolves plugins from mavenLocal() first: align its plugin version with this build.
- name: Use the local plugin version in the demo
run: |
version=$(./gradlew -q properties --property version | sed -n 's/^version: //p')
sed -i -E "s/(id\(\"org.springdoc.openapi-gradle-plugin\"\) version )\"[^\"]+\"/\1\"$version\"/" demo/${{ matrix.demo.build-file }}
grep -n 'openapi-gradle-plugin' demo/${{ matrix.demo.build-file }}
- name: Use Gradle ${{ matrix.demo.gradle-version }} in the demo
if: matrix.demo.gradle-version
run: |
sed -i -E "s#gradle-[0-9.]+-bin.zip#gradle-${{ matrix.demo.gradle-version }}-bin.zip#" demo/gradle/wrapper/gradle-wrapper.properties
grep -n distributionUrl demo/gradle/wrapper/gradle-wrapper.properties
- name: Generate the demo OpenAPI docs
working-directory: demo
run: |
./gradlew --console=plain clean generateOpenApiDocs
test -s ${{ matrix.demo.output }}
jq -e '.paths | length > 0' ${{ matrix.demo.output }}
- name: Second run is up to date
working-directory: demo
run: ./gradlew --console=plain generateOpenApiDocs | tee run2.log && grep -q 'generateOpenApiDocs UP-TO-DATE' run2.log