-
Notifications
You must be signed in to change notification settings - Fork 6
452 lines (387 loc) · 16.4 KB
/
apache-causeway-ci-nightly.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
name: Apache Causeway Framework (CI Nightly)
on:
workflow_dispatch:
schedule:
## daily 02:00 (UTC) in the morning
- cron: '0 2 * * *'
jobs:
build:
name: build, site, push
runs-on: ubuntu-latest
env:
# to be shared among all steps of this job
BASELINE_MAIN: 2.0.0-RC4
BASELINE_EDGE: 3.0.0-M1
ROOT_PATH_MAIN: ${{ github.workspace }}/causeway
ROOT_PATH_EDGE: ${{ github.workspace }}/edge
ROOT_PATH_LEGACY: ${{ github.workspace }}/isis
ROOT_PATH_NIGHTLY: ${{ github.workspace }}/causeway-nightly
MVN_SNAPSHOTS_PATH: ${{ github.workspace }}/causeway-nightly/mvn-snapshots
# options
SKIP_EDGE: false
SKIP_SITE: false
SKIP_SONAR: false
steps:
# ------------------------------
# -- check out self (nightly) --
# ------------------------------
- name: Checkout nightly repo
uses: actions/checkout@v4
with:
path: causeway-nightly
# -------------------------
# -- calculate revisions --
# -------------------------
- name: Calculate new $REVISION_* (if changed since last published, else skip)
id: revision
working-directory: ${{ env.ROOT_PATH_NIGHTLY }}
shell: bash
run: |
bash scripts/nightly/new-revision.sh main apache/causeway/git/ref/heads/master $BASELINE_MAIN ${{ secrets.GITHUB_TOKEN }} | tail -1 >> $GITHUB_OUTPUT
bash scripts/nightly/new-revision.sh edge apache/causeway/git/ref/heads/spring6 $BASELINE_EDGE ${{ secrets.GITHUB_TOKEN }} | tail -1 >> $GITHUB_OUTPUT
- name: Calculate whether to skip any further jobs, based on revisions
if: steps.revision.outputs.main == 'skip' && steps.revision.outputs.edge == 'skip'
run: |
echo "SKIP_ALL=true" >> $GITHUB_ENV
- name: Share $REVISION_* as Environment Variables
run: |
echo "REVISION_MAIN=${{ steps.revision.outputs.main }}" >> $GITHUB_ENV
echo "REVISION_EDGE=${{ steps.revision.outputs.edge }}" >> $GITHUB_ENV
# ------------------------
# -- prune git history --
# ------------------------
- name: Prune Git History
if: env.SKIP_ALL != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_NIGHTLY }}
# will noop if git tree has not changed (see diff commands below)
run: bash scripts/nightly/prune-git-history.sh
- name: Force Push Pruned Git History
if: env.SKIP_ALL != 'true'
# uses a predefined action that does exactly this; will noop if git tree has not changed
uses: ad-m/github-push-action@master
with:
directory: ${{ env.ROOT_PATH_NIGHTLY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
# -------------------------------
# -- check out repos for build --
# -------------------------------
- name: Checkout Apache Causeway MAIN
# if either main or edge are to be built, we need main checked out to have the ci scripts
if: steps.revision.outputs.main != 'skip' || steps.revision.outputs.edge != 'skip'
uses: actions/checkout@v4
with:
repository: apache/causeway
ref: refs/heads/master
path: causeway
- name: Checkout Apache Causeway EDGE
if: steps.revision.outputs.edge != 'skip' && env.SKIP_EDGE != 'true'
uses: actions/checkout@v4
with:
repository: apache/causeway
ref: refs/heads/spring6
path: edge
- name: Clone Sources for Apache Isis LEGACY
if: steps.revision.outputs.main != 'skip'
shell: bash
working-directory: ${{ github.workspace }}
run: cp -r causeway isis
#- name: Dump workshape (debug)
# run: find /home/runner/work/causeway-nightly -print
# ----------------------
# -- install software --
# ----------------------
- name: Set up JDK 21
if: env.SKIP_ALL != 'true'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 21
- name: Install NVM
if: env.SKIP_ALL != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_MAIN }}
run: bash scripts/ci/install-nvm.sh -x
- name: Install Antora
if: env.SKIP_ALL != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_MAIN }}
# we install the 'node' modules into the project root under 'node_modules',
# because we have no privileges to install them globally with -g option
run: npm i @antora/cli@^3.1.1 @antora/site-generator-default@^3.1.1 asciidoctor-kroki
- name: Setup Groovy
if: env.SKIP_ALL != 'true'
run: |
sudo apt-get update
sudo apt-get -f install groovy
- name: Setup Pandoc
if: env.SKIP_ALL != 'true'
run: sudo apt-get -f install pandoc
# ------------------------
# -- print out env --
# ------------------------
- name: Print Software Versions
if: env.SKIP_ALL != 'true'
working-directory: ${{ env.ROOT_PATH_MAIN }}
shell: bash
run: |
echo ============== Software versions =================
java --version
mvn --version
node --version
npm list
groovy --version
pandoc --version
echo ====================================================
- name: Print Environment Variables
if: env.SKIP_ALL != 'true'
shell: bash
# prints all the (non-secret) variables as used by the build scripts to the console
run: |
echo =================== ENV ======================
echo BASELINE_MAIN \: $BASELINE_MAIN
echo BASELINE_EDGE \: $BASELINE_EDGE
echo ROOT_PATH_MAIN \: $ROOT_PATH_MAIN
echo ROOT_PATH_EDGE \: $ROOT_PATH_EDGE
echo ROOT_PATH_LEGACY \: $ROOT_PATH_LEGACY
echo ROOT_PATH_NIGHTLY \: $ROOT_PATH_NIGHTLY
echo REVISION_MAIN \: $REVISION_MAIN
echo REVISION_EDGE \: $REVISION_EDGE
echo ================================================
# ---------------------------
# -- build maven artifacts --
# ---------------------------
- name: Activate Cache for Maven Downloads
if: env.SKIP_ALL != 'true'
uses: actions/cache@v4
env:
# change the cache-name if we want to rebuild the cache
# can be reset via github action page
cache-name: maven-shared
with:
path: ~/.m2/repository
key: ${{ runner.os }}-${{ env.cache-name }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}
${{ runner.os }}-
# -- CAUSEWAY MAIN
- name: Build MAIN Artifacts and Deploy to Local Filesystem
if: steps.revision.outputs.main != 'skip'
shell: bash
working-directory: ${{ env.ROOT_PATH_MAIN }}
run: |
bash scripts/ci/build-artifacts.sh
env:
PROJECT_ROOT_PATH: ${{ env.ROOT_PATH_MAIN }}
REVISION: ${{ env.REVISION_MAIN }}
# -Dmodule-all ... build all modules
# -Denforcer.failFast=true ... fail fast on convergence issues (enforcer plugin)
# -T 1C ... 1 build thread per core
MVN_ADDITIONAL_OPTS: >-
-Dmodule-examples-demo-wicket
-Dnightly-localfs-repo
-Djacoco-report-xml
-Denforcer.failFast=true
-DskipTests=false
-Dproject.build.outputTimestamp=2023-01-01T00:00:00Z
# (used by build-artifacts.sh)
MVN_STAGES: deploy
# when 'off' keep unique REVISION that has SHA checksum - don't revert at end of script
REV_REVERT_FLAG: off
# used to skip building incubator docker images (demo vaadin)
INCUBATOR: skip
# possible modes are
# attach ... enables the 'source' profile, which brings in the maven-source-plugin
# (else) ... explicitly ensure that maven-source-plugin is disabled
SOURCE_MODE: attach
SETTINGS_XML: ${{ env.ROOT_PATH_MAIN }}/.m2/settings.xml
## hub.docker.com
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
DOCKER_REGISTRY_URL: 'https://index.docker.io/v2/'
# possible modes are
# push ... push docker images to dockerhub
# tar ... build docker images and save them locally as tar files
# skip ... skip docker image build steps
JIB_MODE: push
# -- CAUSEWAY EDGE
- name: Build EDGE Artifacts and Deploy to Local Filesystem
if: steps.revision.outputs.edge != 'skip' && env.SKIP_EDGE != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_EDGE }}
run: |
bash scripts/ci/build-artifacts.sh
env:
PROJECT_ROOT_PATH: ${{ env.ROOT_PATH_EDGE }}
REVISION: ${{ env.REVISION_EDGE }}
# -Dmodule-all ... build all modules
# -Denforcer.failFast=true ... fail fast on convergence issues (enforcer plugin)
# -T 1C ... 1 build thread per core
MVN_ADDITIONAL_OPTS: >-
-Dnightly-localfs-repo
-Denforcer.failFast=true
-DskipTests=false
-Dproject.build.outputTimestamp=2023-01-01T00:00:00Z
# (used by build-artifacts.sh)
MVN_STAGES: deploy
# when 'off' keep unique REVISION that has SHA checksum - don't revert at end of script
REV_REVERT_FLAG: off
# used to skip building incubator docker images (demo vaadin)
INCUBATOR: skip
# possible modes are
# attach ... enables the 'source' profile, which brings in the maven-source-plugin
# (else) ... explicitly ensure that maven-source-plugin is disabled
SOURCE_MODE: attach
SETTINGS_XML: ${{ env.ROOT_PATH_EDGE }}/.m2/settings.xml
# possible modes are
# push ... push docker images to dockerhub
# tar ... build docker images and save them locally as tar files
# skip ... skip docker image build steps
JIB_MODE: skip
# -- ISIS LEGACY - INFERRED FROM MAIN
- name: Build LEGACY Artifacts and Deploy to Local Filesystem
if: steps.revision.outputs.main != 'skip'
shell: bash
working-directory: ${{ env.ROOT_PATH_LEGACY }}
run: |
jshell scripts/ci/rename-all-published-sources.jsh
bash scripts/ci/build-artifacts.sh
env:
PROJECT_ROOT_PATH: ${{ env.ROOT_PATH_LEGACY }}
REVISION: ${{ env.REVISION_MAIN }}
# -Dmodule-all ... build all modules
# -Denforcer.failFast=true ... fail fast on convergence issues (enforcer plugin)
# -T 1C ... 1 build thread per core
MVN_ADDITIONAL_OPTS: >-
-Dnightly-localfs-repo
-Denforcer.failFast=true
-DskipTests=false
-Dproject.build.outputTimestamp=2023-01-01T00:00:00Z
# (used by build-artifacts.sh)
MVN_STAGES: deploy
# when 'off' keep unique REVISION that has SHA checksum - don't revert at end of script
REV_REVERT_FLAG: off
# used to skip building incubator docker images (demo vaadin)
INCUBATOR: skip
# possible modes are
# attach ... enables the 'source' profile, which brings in the maven-source-plugin
# (else) ... explicitly ensure that maven-source-plugin is disabled
SOURCE_MODE: attach
SETTINGS_XML: ${{ env.ROOT_PATH_LEGACY }}/.m2/settings.xml
# possible modes are
# push ... push docker images to dockerhub
# tar ... build docker images and save them locally as tar files
# skip ... skip docker image build steps
JIB_MODE: skip
- name: Code Quality Analysis (MAIN)
if: steps.revision.outputs.main != 'skip' && env.SKIP_SONAR != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_MAIN }}
# -Dreleased ... process only released modules
run: |
mvn verify sonar:sonar \
-Dreleased \
-Dsonar.projectKey=apache_causeway \
-Dsonar.organization=apache \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.branch.name=master \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \
-DskipTests=true \
-Denforcer.skip
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# ------------------------
# -- build the site --
# ------------------------
- name: Build Apache Causeway Site (MAIN)
if: steps.revision.outputs.main != 'skip' && env.SKIP_SITE != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_MAIN }}
# builds static web content into ${ROOT_PATH_MAIN}/antora/target/site,
# as specified in the site.yml file
run: |
bash $ROOT_PATH_NIGHTLY/scripts/nightly/patch-site-config.sh $ROOT_PATH_MAIN/antora/playbooks/site.yml
bash -x scripts/ci/build-site.sh $ROOT_PATH_MAIN/antora/playbooks/site.yml
env:
PROJECT_ROOT_PATH: ${{ env.ROOT_PATH_MAIN }}
REVISION: ${{ steps.revision.outputs.main }}
SKIP_PROJDOC_GENERATION: true
- name: Rsync Site Content to Nightly Working Tree
# only sync if we have MAIN ... will of course otherwise fail
if: steps.revision.outputs.main != 'skip' && env.SKIP_ALL != 'true' && env.SKIP_SITE != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_NIGHTLY }}
env:
SITE_SOURCE: ${{ env.ROOT_PATH_MAIN }}/antora/target/site/
SITE_DEST: ${{ env.ROOT_PATH_NIGHTLY }}/docs
run: |
bash scripts/nightly/rsync-site.sh
- name: Remove Outdated Binaries
if: env.SKIP_ALL != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_NIGHTLY }}
run: jshell scripts/nightly/remove-binaries-older-than.jsh
- name: Commit Site/Snapshot Updates (/docs, /mvn-snapshots)
if: env.SKIP_ALL != 'true'
shell: bash
working-directory: ${{ env.ROOT_PATH_NIGHTLY }}
# will noop if git tree has not changed (see diff commands below)
run: |
git config --local user.email "action@github.com"
git config --local user.name "Apache Causeway Committers (Bot)"
git add ./mvn-snapshots
git add ./docs
git diff --quiet && git diff --staged --quiet || git commit -m "CI automated site update" -a
- name: Push Site Update
# uses a predefined action that does exactly this; will noop if git tree has not changed
uses: ad-m/github-push-action@master
with:
directory: ${{ env.ROOT_PATH_NIGHTLY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# FOR DEBUG USE
# - name: deliberate exit (debug)
# shell: bash
# run: |
# exit 1
# - name: Dump workshape
# run: find . -print
# - name: Dump Env context
# env:
# ENV_CONTEXT: ${{ toJson(env) }}
# run: echo "$ENV_CONTEXT"
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
# - name: Dump job context
# env:
# JOB_CONTEXT: ${{ toJson(job) }}
# run: echo "$JOB_CONTEXT"
# - name: Dump steps context
# env:
# STEPS_CONTEXT: ${{ toJson(steps) }}
# run: echo "$STEPS_CONTEXT"
# - name: Dump runner context
# env:
# RUNNER_CONTEXT: ${{ toJson(runner) }}
# run: echo "$RUNNER_CONTEXT"
# - name: Dump strategy context
# env:
# STRATEGY_CONTEXT: ${{ toJson(strategy) }}
# run: echo "$STRATEGY_CONTEXT"
# - name: Dump matrix context
# env:
# MATRIX_CONTEXT: ${{ toJson(matrix) }}
# run: echo "$MATRIX_CONTEXT"
# - name: Create issue using REST API (example)
# run: |
# curl --request POST \
# --url https://api.github.com/repos/${{ github.repository }}/issues \
# --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
# --header 'content-type: application/json' \
# --data '{
# "title": "Automated issue for commit: ${{ github.sha }}",
# "body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_."
# }'