forked from unbroken-dome/gradle-xjc-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
319 lines (275 loc) · 12.7 KB
/
canary-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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
name: CI-Gradle-canary-build
# This build exists to test compatibility of the plugin project build to generate the plugin
# with the latest Gradle version.
# This is checking and reporting about the plugin maintainers perspective of building this plugin
# This also indirectly tests against JVM updates as well but that is not considered the main focus
#
# So I'm calling this a canary as it provides an early warning after a new official Gradle release
# of consumer issues. We do not test release candidates or against any Gradle builds that are not
# an official release as there is no maintenance capacity to keep uptodate with daily issues from
# doing this not any reason to thing doing this will improve the quality of the plugin.
#
# Gradle publishes public data to in this area to help with automation:
# https://services.gradle.org/versions/
# https://raw.githubusercontent.com/gradle/gradle/master/released-versions.json
## TODO build project test, using newer Gradle versions, setup matrix of useful version
## TODO run deprecation test turn on warnings, collect output to summary
## TODO emit compile log output warnings to summary
on:
workflow_dispatch:
inputs:
GRADLE_TARGET_ENABLE_integrationTest:
description: 'Run with integrationTest ?'
default: true
type: boolean
schedule:
# setup weekly canary build
- cron: '45 4 * * 6'
jobs:
build:
strategy:
max-parallel: 3
matrix:
# Maintenance update as necessary the expected latest Gradle version supports the JVM matrix listed
os: [ubuntu-latest]
jvm: ['8', '11', '17', '21']
gradle: [
'latest',
'8',
'8.5', # JDK21
'7',
'7.6',
'7.3', # JDK11
'6',
'6.6.1' # oldest supported to build project with
]
exclude:
- jvm: 21
gradle: 7
- jvm: 21
gradle: 7.6
- jvm: 21
gradle: 7.3
- jvm: 21
gradle: 6
- jvm: 21
gradle: 6.6.1
- jvm: 17
gradle: 6
- jvm: 17
gradle: 6.6.1
fail-fast: false
runs-on: ${{ matrix.os }}
env:
GRADLE_EXTRA_ARGS: --no-daemon --warning-mode=all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Matrix Check
run: |
## Disable runs requesting invalid matrix (done via 'strategy.matrix.exclude' GHA setting)
# jvm=21 only latest 8.5
# jvm=17 only latest 8.5 7 7.6 7.3
# jvm=11 only latest 8.5 7 7.6 7.3 6 5 5.6
# jvm=8 only latest 8.5 7 7.6 7.3 6 5 5.6
# Resolve all values to actual value
# Remove duplicates (and alias runs)
if [ -z "${{ matrix.os }}" ]
then
echo "$0: matrix.os is not setup" 1>&2
exit 1
fi
if [ -z "${{ matrix.jvm }}" ]
then
echo "$0: matrix.jvm is not setup" 1>&2
exit 1
fi
if [ -z "${{ matrix.gradle }}" ]
then
echo "$0: matrix.gradle is not setup" 1>&2
exit 1
fi
- name: GHA Option Setup
run: |
if [ -z "${GRADLE_TARGET_ENABLE_integrationTest}" ] && [ -n "${{ github.event.schedule }}" ]; then
# force this on for schedule build
# "${{ github.event.schedule }}" == "45 4 18 * *"
# $GITHUB_EVENT_NAME == "schedule"
echo "GRADLE_TARGET_ENABLE_integrationTest=true" >> $GITHUB_ENV
fi
target_plugin="org.unbroken-dome.xjc"
target_group=$(grep "^group=" gradle.properties | cut -d'=' -f2-)
target_artifact="gradle-xjc-plugin"
target_version=$(grep "^version=" gradle.properties | cut -d'=' -f2-)
echo "target_plugin=$target_plugin" >> $GITHUB_ENV
echo "target_group=$target_group" >> $GITHUB_ENV
echo "target_artifact=$target_artifact" >> $GITHUB_ENV
echo "target_version=$target_version" >> $GITHUB_ENV
- name: Gradle Version Setup
run: |
#
curl -s "https://raw.githubusercontent.com/gradle/gradle/master/released-versions.json" > released-versions.json
# Only supporting 6.6.1 or newer (to build the project itself)
GRADLE_ALL_VERSIONS=$(jq '.finalReleases[].version' -r released-versions.json | sort -rn | tr '\n' ' ' | sed -e 's#\s6.6\s.*##')
echo "GRADLE_ALL_VERSIONS=$GRADLE_ALL_VERSIONS"
GRADLE_CANARY_VERSION=$(jq '.finalReleases[].version' -r released-versions.json | sort -rn | head -n1)
echo "GRADLE_CANARY_VERSION=$GRADLE_CANARY_VERSION"
GRADLE_CANARY_MAJOR=$(echo -n "$GRADLE_CANARY_VERSION" | cut -d '.' -f1)
regex_transform=$(echo -ne "${{ matrix.gradle }}" | sed -e 's#\.#\\\0#g')
GRADLE_MATRIX_VERSION=$(jq '.finalReleases[].version' -r released-versions.json | sort -rn | egrep -- "^${regex_transform}" | head -n1 | tr -d '\r\n')
echo "GRADLE_MATRIX_VERSION=$GRADLE_MATRIX_VERSION"
GRADLE_MATRIX_MAJOR=$(echo -n "$GRADLE_MATRIX_VERSION" | cut -d '.' -f1)
if gradlew -v || which gradlew
then
# confirm GHA didn't provide its own
echo "$0: ERROR ./gradlew appears to already be installed" 1>&2
exit 1
fi
if [ "${{ matrix.gradle }}" = "latest" ]
then
GRADLE_VERSION="$GRADLE_CANARY_VERSION"
else
GRADLE_VERSION="$GRADLE_MATRIX_VERSION"
fi
GRADLE_VERSION_MAJOR=$(echo -n "$GRADLE_VERSION" | cut -d '.' -f1)
# TODO disable duplicate runs which resolve to the same matrix versions
# latest 8 8.5 all resolve to 8.5 for example
echo "GRADLE_ALL_VERSIONS=$GRADLE_ALL_VERSIONS" >> $GITHUB_ENV
echo "GRADLE_CANARY_VERSION=$GRADLE_CANARY_VERSION" >> $GITHUB_ENV
echo "GRADLE_CANARY_MAJOR=$GRADLE_CANARY_MAJOR" >> $GITHUB_ENV
echo "GRADLE_MATRIX_VERSION=$GRADLE_MATRIX_VERSION" >> $GITHUB_ENV
echo "GRADLE_MATRIX_MAJOR=$GRADLE_MATRIX_MAJOR" >> $GITHUB_ENV
echo "GRADLE_VERSION=$GRADLE_VERSION" >> $GITHUB_ENV
echo "GRADLE_VERSION_MAJOR=$GRADLE_VERSION_MAJOR" >> $GITHUB_ENV
# Make the version so with wrapper edit
sed -e 's/^distributionUrl=/\#\0/' -i gradle/wrapper/gradle-wrapper.properties
echo "distributionUrl=https\://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip" >> gradle/wrapper/gradle-wrapper.properties
# Fixup gradle.properties based on Gradle major used to build
sed -e 's/^kotlinVersion=/\#\0/' -i gradle.properties
sed -e 's/^testSetsVersion=/\#\0/' -i gradle.properties
case "$GRADLE_VERSION_MAJOR" in
5|6) echo "kotlinVersion=1.3.72" >> gradle.properties
echo "testSetsVersion=3.0.1" >> gradle.properties
;;
7) echo "kotlinVersion=1.6.21" >> gradle.properties
echo "testSetsVersion=4.0.0" >> gradle.properties
;;
8|*) echo "kotlinVersion=1.9.20" >> gradle.properties
if [ "${{ matrix.jvm }}" = "8" ]
then
# The official org.unbroken-dome.test-sets 4.1.0 Needs Java11+ and is the first version to support Gradle 8.x
#echo "testSetsVersion=4.0.0" >> gradle.properties
# So this is why this if[] exists, but the we now use unofficial:
#org.darrylmiles.repack.org.unbroken-dome.test-sets which a release in Java8 bytecode of 4.1.0
echo "testSetsVersion=4.1.0" >> gradle.properties
else
# The official org.unbroken-dome.test-sets 4.1.0 Needs Java11+
echo "testSetsVersion=4.1.0" >> gradle.properties
fi
;;
esac
echo "### gradle.properties:"
cat gradle.properties
- name: Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.jvm }}
- name: Gradle - wrapper-validation-action
uses: gradle/wrapper-validation-action@v1
- name: Gradle - setup
uses: gradle/gradle-build-action@v2
- name: Show Diff
run: |
git diff || true
- name: Report Versions
run: |
# Print verbose diagnostics into logs
java -version
# download-artifact removes executable perm from files
test -x ./gradlew || chmod -c a+x ./gradlew
# Now run it
./gradlew -v
JAVA_ARG_VERSION=$(java -version 2>&1 | sed -e ':a;N;$!ba;s/\n/<br>/g' -e 's#|#\\|#g')
JAVA_ARG_VERSION_SUMMARY=$(java -version 2>&1 | head -n1 | sed -e 's#openjdk\s\+##' -e 's#version\s\+##' -e 's#"##g' -e 's#\s\+.*$##')
GRADLE_ARG_VERSION=$(./gradlew -v 2>&1 | sed -e ':a;N;$!ba;s/\n/<br>/g' -e 's#|#\\|#g')
GRADLE_WRAPPER_VERSION=$(egrep "^distributionUrl\s*=" gradle/wrapper/gradle-wrapper.properties | sed -e 's#^.*=##' -e 's#.*distributions/##' -e 's#^gradle\-##' -e 's#\-.*$##')
cat <<EOF >> /tmp/GITHUB_STEP_SUMMARY$$.txt
Gradle Version $GRADLE_VERSION (${{ matrix.gradle }}) JDK $JAVA_ARG_VERSION_SUMMARY (${{ matrix.jvm }})
| Package | Details |
| ---------- | --------------------- |
| Java | ${JAVA_ARG_VERSION} |
| Gradle | ${GRADLE_ARG_VERSION} |
EOF
cat /tmp/GITHUB_STEP_SUMMARY$$.txt
cat /tmp/GITHUB_STEP_SUMMARY$$.txt >> $GITHUB_STEP_SUMMARY
- name: Gradle - dependencies
env: # to resolve artifacts from GH packages
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew $GRADLE_EXTRA_ARGS dependencies
- name: Gradle - assemble
env: # to resolve artifacts from GH packages
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew $GRADLE_EXTRA_ARGS assemble
- name: Gradle - build
run: ./gradlew $GRADLE_EXTRA_ARGS build
- name: Gradle - check
run: |
if ! ./gradlew $GRADLE_EXTRA_ARGS check
then
./gradlew $GRADLE_EXTRA_ARGS --stacktrace check
fi
- name: Gradle - integrationTest
if: ${{ vars.GRADLE_TARGET_ENABLE_integrationTest == 'true' || inputs.GRADLE_TARGET_ENABLE_integrationTest }}
run: ./gradlew $GRADLE_EXTRA_ARGS "-Dorg.unbrokendome.gradle.plugins.xjc.testutil.GradleVersions=${GRADLE_VERSION}" integrationTest
- name: Gradle - asciidoctor
if: false # needs fixing for 7.x
run: ./gradlew $GRADLE_EXTRA_ARGS asciidoctor
- name: Gradle - dokka
if: false # needs fixing for 7.x
run: ./gradlew $GRADLE_EXTRA_ARGS dokka
- name: Gradle - publish
run: ./gradlew $GRADLE_EXTRA_ARGS publish
- name: Gradle - deprecation check
run: ./gradlew -Dorg.gradle.deprecation.trace=true --warning-mode=all --stacktrace validatePlugins
- name: Upload - prepare
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
mkdir dist
_build_repo_list=$(find . -type d -path "*/build/repo")
if [ -n "${_build_repo_list}" ]
then
for dir in ${_build_repo_list}
do
cp -a "$dir" "dist/"
done
else
echo "$0: no **/build/repo directories found" 1>&2
fi
find "dist" -type f -exec ls -ld {} \;
du -s "dist"
mkdir -p build/gh-pages
[ -d build/reports/tests ] && cp -a build/reports/tests build/gh-pages/
docs_build_dir="build"
[ -d docs/build ] && docs_build_dir="docs/build" || true
[ -d $docs_build_dir/asciidoc/html5 ] && cp -a $docs_build_dir/asciidoc/html5/* build/gh-pages/
[ -d $docs_build_dir/dokka ] && cp -a $docs_build_dir/dokka build/gh-pages/
mkdir -p build/gh-pages/maven2
[ -d "build/repo" ] && cp -a build/repo/* build/gh-pages/maven2/
ls -lad build/gh-pages
du -s build/gh-pages
- name: Upload - java${{ matrix.jvm }}-gradle${{ matrix.gradle }}-github-pages
uses: actions/upload-pages-artifact@main
if: false
with:
name: java${{ matrix.jvm }}-github-pages
path: build/gh-pages/
retention-days: 1
- name: Upload - perform
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: java${{ matrix.jvm }}-gradle${{ matrix.gradle }}-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts
path: dist/repo/*
if-no-files-found: warn