-
Notifications
You must be signed in to change notification settings - Fork 71
253 lines (242 loc) · 9.22 KB
/
build.yml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: Main build
env:
EXPERIMENTAL_JAVA: 22
on:
# We want to trigger our builds all the time for the default branch
# except when Shipkit creates a new version tag
push:
branches: ['main']
tags-ignore:
- 'v**'
# Each pull request is important to us, doesn't matter from which branch.
# Furthermore, we do not want to build on just the default GitHub Action
# events, we also want to react onto `labeled` events for our extended
# build execution
pull_request:
types: [labeled, opened, synchronize, reopened]
# We also utilize this pipeline for releasing. By providing a `version`
# and setting `releasing` to `true`, we can trigger a release.
workflow_dispatch:
inputs:
releasing:
description: "Release build"
type: boolean
default: false
version:
description: 'Version string, e.g. 2.3.1:'
required: true
jobs:
# Basic Gradle wrapper validation. This step is run first, due to security
# concerns. Running our whole pipeline with Gradle with a corrupt wrapper,
# could expose our secrets, and we definitely want to prevent this.
validation:
runs-on: ubuntu-latest
timeout-minutes: 15
name: Gradle wrapper validation
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
# Our basic build step as we want contributors to have a nice developer
# experience with little build time and sufficient feedback. Therefore, we
# only build this on our default Java version but for all operating systems
# we are supporting. This allows for a fast execution and fast feedback. The
# extended tests will run later under certain conditions.
basic:
runs-on: ${{ matrix.os }}-latest
needs: validation
timeout-minutes: 15
strategy:
matrix:
os: [ubuntu, macos, windows]
name: with Java 11 on ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Gradle build
run: ./gradlew --refresh-dependencies --stacktrace --scan clean build -x spotlessCheck
# SonarCloud analysis
sonar-cloud-analysis:
runs-on: ubuntu-latest
needs: validation
timeout-minutes: 15
name: SonarCloud analysis
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
# Sonar needs the whole Git history for issue assignment
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Cache SonarCloud results
uses: actions/cache@v4
with:
path: ~/.sonar/cache/
key: ubuntu-sonar
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Gradle build
run: ./gradlew --refresh-dependencies --stacktrace --scan clean build -x spotlessCheck
- name: SonarCloud analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: "61ab2579215aa8a0024a2f9368fc1298fdecfd18"
run: ./gradlew jacocoTestReport sonarqube --stacktrace -i
# Code format check
code-format-check:
runs-on: ubuntu-latest
needs: validation
timeout-minutes: 15
name: Code format check
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Spotless check
run: ./gradlew --scan spotlessCheck
# Our full integration job, which will build for a matrix out of our
# supported Java versions, operating systems and various JUnit versions.
# This build is executed on all tags and the default branch as well as
# for pull requests with the label `full-build`.
full-featured:
if: (contains(github.event.pull_request.labels.*.name, 'full-build') || !github.event.pull_request)
needs: basic
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 15
strategy:
matrix:
java: [ 11, 17, 21 ]
junit-version: [ '5.9.2', '5.10.0' ]
os: [ubuntu, macos, windows]
name: with Java ${{ matrix.java }}, JUnit ${{ matrix.junit-version }} on ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Gradle build
env:
ORG_GRADLE_PROJECT_junitVersion: ${{ matrix.junit-version }}
run: ./gradlew --refresh-dependencies --stacktrace --scan clean build -x spotlessCheck
# We want to be up-to-date and know issues with future Java versions as soon as possible.
# Furthermore, we also would love to see our build working with the latest Gradle version.
# As those builds might fail, they are allowed to fail, and should not prevent merges.
experimental:
if: (contains(github.event.pull_request.labels.*.name, 'full-build') || !github.event.pull_request)
needs: full-featured
runs-on: ${{ matrix.os }}-latest
continue-on-error: true
timeout-minutes: 15
strategy:
matrix:
junit-version: [ '5.9.2', '5.10.0' ]
os: [ubuntu, macos, windows]
name: Experimental build with newest JDK early-access build and Gradle release candidate
# Gradle doesn't work with JDK EA builds, so we launch it with a supported Java version,
# but set the Gradle toolchain to use the experimental version.
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up experimental Java
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ env.EXPERIMENTAL_JAVA }}
- name: Prepare JDK_EXPERIMENTAL env var
shell: bash
run: echo "JDK_EXPERIMENTAL=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up supported Java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: release-candidate
- name: Gradle version
run: gradle --version
- name: Gradle toolchains
env:
ORG_GRADLE_PROJECT_org.gradle.java.installations.auto-download: false
run: gradle javaToolchains
- name: Gradle build
env:
ORG_GRADLE_PROJECT_experimentalJavaVersion: ${{ env.EXPERIMENTAL_JAVA }}
ORG_GRADLE_PROJECT_junitVersion: ${{ matrix.junit-version }}
ORG_GRADLE_PROJECT_org.gradle.java.installations.auto-download: false
run: gradle --refresh-dependencies --stacktrace --scan clean build -x spotlessCheck
# A release will be created if there is a `version` defined and `releasing` is set to `true`.
# If not, this stage will be ignored.
release:
if: github.event.inputs.version != '' && github.event.inputs.releasing == 'true'
runs-on: ubuntu-latest
needs: full-featured
timeout-minutes: 15
name: Release Pioneer into the wild
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
# Shipkit needs the whole Git history for changelog generation
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v4
with:
# we build the Javadoc with JDK 17 (for better results),
# so install that as well
java-version: |
21
11
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Perform release
env:
# used to trigger website build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# used by `io.github.gradle-nexus.publish-plugin` to sign artifacts
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.JUNIT_PIONEER_PGP_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.JUNIT_PIONEER_PGP_PASSWORD }}
# used by `io.github.gradle-nexus.publish-plugin` to publish to Maven Central
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.NEXUS_TOKEN_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.NEXUS_TOKEN_PASSWORD }}
# defines released version according to GitHub Action input
ORG_GRADLE_PROJECT_version: ${{ github.event.inputs.version }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository githubRelease
# After our release, we also need to trigger an update for our website build
update-website:
runs-on: ubuntu-latest
needs: release
timeout-minutes: 15
name: Update website
steps:
- name: Trigger website build
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GH_WRITE_TOKEN }}
repository: junit-pioneer/junit-pioneer.github.io
event-type: triggerSiteBuild