-
Notifications
You must be signed in to change notification settings - Fork 2
293 lines (265 loc) · 9.83 KB
/
ci-java21.yml
File metadata and controls
293 lines (265 loc) · 9.83 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
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
name: Java 21 :latest
on:
push:
pull_request:
schedule:
- cron: "11 */8 * * *"
env:
TEST_TAG: ${{ secrets.DOCKER_USERNAME }}/existdb:exist-ci
IMAGE_TAG: latest
IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/existdb
# EXIST_VER: 6.2.0
jobs:
build:
name: Build and Test Images
runs-on: ubuntu-latest
# NOTE (DP): Test on PRs and pushes
if: github.ref == 'refs/heads/main' || github.base_ref == 'main'
steps:
# SETUP
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
# platforms: all
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Make buildkit default
uses: docker/setup-buildx-action@v3
id: buildx
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
- name: Install bats
# run: sudo apt-get install bats libsaxonb-java
run: sudo apt-get install bats
- name: Check local images
run: docker image ls
# TODO(DP) needs adjusting for multi-stage see #5
# - name: Modify logging config
# run: saxonb-xslt -s:dump/exist-distribution-${{ env.EXIST_VER }}/etc/log4j2.xml -xsl:log4j2-docker.xslt -o:log4j2.xml
# BUILD
- name: Build default images for testing on CI
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
build-args: |
GITHUB_USERNAME=${{ github.actor }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
- name: Build debug images for testing on CI
uses: docker/build-push-action@v6
with:
context: .
build-args: |
DISTRO_TAG=debug
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
file: ./Dockerfile
load: true
tags: ${{ env.TEST_TAG }}-debug
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
- name: Build nonroot images for testing on CI
uses: docker/build-push-action@v6
with:
context: .
build-args: |
DISTRO_TAG=nonroot
USR=nonroot:nonroot
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
file: ./Dockerfile
load: true
tags: ${{ env.TEST_TAG }}-nonroot
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
- name: Build debug-slim images for testing on CI
uses: docker/build-push-action@v6
with:
context: .
build-args: |
DISTRO_TAG=debug
FLAVOR=slim
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
file: ./Dockerfile
load: true
tags: ${{ env.TEST_TAG }}-debug-slim
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
# TEST
- name: Start exist-ci containers
run: |
docker run -dit -p 8080:8080 --name exist-ci --rm ${{ env.TEST_TAG }}
docker run -dit -p 8181:8080 -v $pwd/exist/autodeploy:/exist/autodeploy --name nonroot --rm ${{ env.TEST_TAG }}-nonroot
sleep 35s
# - name: Wait for exist-ci to boot
# run: |
# timeout 60 sh -c 'until docker logs exist-ci | grep -qe "Server has started"; do sleep 3; done' localhost 8080
- name: Check mem and cgroup config
run: |
docker logs exist-ci | grep -w "Approximate maximum amount of memory for JVM:"
docker logs exist-ci | grep -w "Number of processors available to JVM:"
- name: Run tests
run: bats --tap test/bats/0*.bats
# DP: this dynamically set the version from develop
# no longer necessary
# - name: Get SemVer string from test image
# run: |
# echo "EXIST_VER=$(docker exec exist-ci java org.exist.start.Main client --no-gui --xpath 'system:get-version()' | grep -i 'eXist version' | cut -d ' ' -f 3)" >> $GITHUB_ENV
# - name: Test GHA output
# run: echo $EXIST_VER
# PUSH
# Latest
- name: Push :latest to Dockerhub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
BRANCH=develop
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
push: true
sbom: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
- name: Push :debug (latest) to Dockerhub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
DISTRO_TAG=debug
BRANCH=develop
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
push: true
sbom: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.IMAGE_NAME }}:debug
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-debug
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
- name: push :nonroot (latest) to Dockerhub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
DISTRO_TAG=nonroot
USR=nonroot:nonroot
BRANCH=develop
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
push: true
sbom: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.IMAGE_NAME }}:nonroot
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-nonroot
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
# SLIM
- name: Push :latest-slim to Dockerhub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
FLAVOR=slim
BRANCH=develop
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
push: true
sbom: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-slim
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
- name: Push :debug-slim (latest) to Dockerhub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
DISTRO_TAG=debug
FLAVOR=slim
BRANCH=develop
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
push: true
sbom: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.IMAGE_NAME }}:debug-slim
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-debug-slim
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
- name: push :nonroot-slim (latest) to Dockerhub
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: ./
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
build-args: |
DISTRO_TAG=nonroot
FLAVOR=slim
USR=nonroot:nonroot
BRANCH=develop
GITHUB_USERNAME=${{ github.actor }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
push: true
sbom: true
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.IMAGE_NAME }}:nonroot-slim
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}-nonroot-slim
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max