-
Notifications
You must be signed in to change notification settings - Fork 28
370 lines (293 loc) · 12.3 KB
/
main.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
name: Docker - Debian
on:
push:
branches:
- master
tags:
- r*
jobs:
build-docker-debian:
name: Build Debian Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Docker build
run: docker build -t libki-server -f docker/Dockerfile .
- name: Export image to file
run: docker save libki-server > ${{ github.sha }}.debian.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}.debian.tar
path: ${{ github.sha }}.debian.tar
test-docker-debian:
name: Debian Docker image unit tests
needs: build-docker-debian
runs-on: ubuntu-latest
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.debian.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.debian.tar
- name: Create docker network
run: docker network create libki-net
- name: Start database container
run: docker run --name libki-mariadb --network libki-net -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=libki --rm -d mariadb:10.3.5
- name: Sleep to give database container time to launch
run: sleep 30
- name: Start Libki container
run: docker run --name libki-test-server --network libki-net -e 'LIBKI_INSTANCE=demo' -e 'LIBKI_DB_DSN=dbi:mysql:libki;host=libki-mariadb;port=3306' -e 'LIBKI_DB_USER=root' -e 'LIBKI_DB_PASSWORD=password' -e 'LIBKI_DB_HOST=libki-mariadb' -e 'LIBKI_DB_PORT=3306' -e 'LIBKI_DB_DATABASE=libki' -d libki-server
- name: Sleep to give Libki container time to launch
run: sleep 30
- name: List docker containers
run: docker ps && docker logs libki-test-server
- name: Set up the Libki database
run: docker exec -t libki-test-server /app/installer/update_db.pl
- name: Run unit tests
run: |
docker exec -t libki-test-server prove /app/t/01app.t
docker exec -t libki-test-server prove /app/t/stdout.t
docker exec -t -e TEST_POD=1 libki-test-server prove /app/t/02pod.t
docker exec -t -e TEST_POD=1 libki-test-server prove /app/t/03podcoverage.t
docker exec -t libki-test-server prove t/controller_API-Client-v1_0.t
publish-docker-io-debian:
name: Push Debian image (docker.io)
needs: test-docker-debian
runs-on: ubuntu-latest
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.debian.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.debian.tar
- name: Log in to docker.io
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u kylemhall --password-stdin
- name: Tag image for docker.io
run: docker tag libki-server:latest libki/libki-server:latest
- name: Push image to docker.io
run: docker push libki/libki-server
publish-quay-io-debian:
name: Push Debian image (quay.io)
needs: test-docker-debian
runs-on: ubuntu-latest
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.debian.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.debian.tar
- name: Log in to quay.io
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u kylemhall --password-stdin
- name: Tag image for quay.io
run: docker tag libki-server:latest quay.io/libki/libki-server:latest
- name: Push image to quay.io
run: docker push quay.io/libki/libki-server
release-docker-io-debian:
name: Release Debian image (docker.io)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/r')
needs: [publish-docker-io-debian, publish-quay-io-debian, publish-docker-io-alpine, publish-quay-io-alpine]
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.debian.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.debian.tar
- name: Log in to docker.io
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u kylemhall --password-stdin
- name: Tag image for docker.io
run: docker tag libki-server:latest libki/libki-server:${GITHUB_REF##*/}
- name: Push image to docker.io
run: docker push libki/libki-server:${GITHUB_REF##*/}
release-quay-io-debian:
name: Release Debian image (quay.io)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/r')
needs: [publish-docker-io-debian, publish-quay-io-debian, publish-docker-io-alpine, publish-quay-io-alpine]
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.debian.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.debian.tar
- name: Log in to quay.io
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u kylemhall --password-stdin
- name: Tag image for quay.io
run: docker tag libki-server:latest quay.io/libki/libki-server:${GITHUB_REF##*/}
- name: Push image to quay.io
run: docker push quay.io/libki/libki-server:${GITHUB_REF##*/}
build-docker-alpine:
name: Build Docker Alpine image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Docker build
run: docker build -t libki-server -f docker/Dockerfile.alpine .
- name: Export image to file
run: docker save libki-server > ${{ github.sha }}.alpine.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}.alpine.tar
path: ${{ github.sha }}.alpine.tar
test-docker-alpine:
name: Alpine Docker image unit tests
needs: build-docker-alpine
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.alpine.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.alpine.tar
- name: Create docker network
run: docker network create libki-net
- name: Start database container
run: docker run --name libki-mariadb --network libki-net -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=libki --rm -d mariadb:10.3.5
- name: Sleep to give database container time to launch
run: sleep 30
- name: Load database schema
run: cat installer/schema.sql | docker exec -i libki-mariadb /usr/bin/mysql -u root --password=password libki
- name: Load database default data
run: cat installer/data.sql | docker exec -i libki-mariadb /usr/bin/mysql -u root --password=password libki
- name: Start Libki container
run: docker run --name libki-test-server --network libki-net -e 'LIBKI_INSTANCE=demo' -e 'LIBKI_DB_DSN=dbi:mysql:libki;host=libki-mariadb;port=3306' -e 'LIBKI_DB_USER=root' -e 'LIBKI_DB_PASSWORD=password' -e 'LIBKI_DB_HOST=libki-mariadb' -e 'LIBKI_DB_PORT=3306' -e 'LIBKI_DB_DATABASE=libki' -e 'LIBKI_TZ=America/New_York' -d libki-server
- name: Sleep to give Libki container time to launch
run: sleep 30
- name: List docker containers
run: docker ps && docker logs libki-test-server
- name: Set up the Libki database
run: docker exec -t libki-test-server /app/installer/update_db.pl
- name: Run unit tests
run: |
docker exec -t libki-test-server prove /app/t/01app.t
docker exec -t libki-test-server prove /app/t/stdout.t
docker exec -t -e TEST_POD=1 libki-test-server prove /app/t/02pod.t
docker exec -t -e TEST_POD=1 libki-test-server prove /app/t/03podcoverage.t
docker exec -t libki-test-server prove t/controller_API-Client-v1_0.t
publish-docker-io-alpine:
name: Push Alpine image (docker.io)
needs: test-docker-alpine
runs-on: ubuntu-latest
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.alpine.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.alpine.tar
- name: Log in to docker.io
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u kylemhall --password-stdin
- name: Tag image for docker.io
run: docker tag libki-server:latest libki/libki-server:alpine-latest
- name: List available docker images
run: docker image ls
- name: Push image to docker.io
run: docker push libki/libki-server:alpine-latest
publish-quay-io-alpine:
name: Push Alpine image (quay.io)
needs: test-docker-alpine
runs-on: ubuntu-latest
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.alpine.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.alpine.tar
- name: Log in to quay.io
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u kylemhall --password-stdin
- name: Tag image for quay.io
run: docker tag libki-server:latest quay.io/libki/libki-server:alpine-latest
- name: List available docker images
run: docker image ls
- name: Push image to quay.io
run: docker push quay.io/libki/libki-server:alpine-latest
release-docker-io-alpine:
name: Release Alpine image (docker.io)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/r')
needs: [publish-docker-io-debian, publish-quay-io-debian, publish-docker-io-alpine, publish-quay-io-alpine]
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.alpine.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.alpine.tar
- name: Log in to docker.io
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u kylemhall --password-stdin
- name: Tag image for docker.io
run: docker tag libki-server:latest libki/libki-server:alpine-${GITHUB_REF##*/}
- name: List available docker images
run: docker image ls
- name: Push image to docker.io
run: docker push libki/libki-server:alpine-${GITHUB_REF##*/}
release-quay-io-alpine:
name: Release Alpine image (quay.io)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/r')
needs: [publish-docker-io-debian, publish-quay-io-debian, publish-docker-io-alpine, publish-quay-io-alpine]
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.alpine.tar
path: /tmp
- name: Import image from file
run: docker load --input /tmp/${{ github.sha }}.alpine.tar
- name: Log in to quay.io
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u kylemhall --password-stdin
- name: Tag image for quay.io
run: docker tag libki-server:latest quay.io/libki/libki-server:alpine-${GITHUB_REF##*/}
- name: List available docker images
run: docker image ls
- name: Push image to quay.io
run: docker push quay.io/libki/libki-server:alpine-${GITHUB_REF##*/}
release-server-github:
name: Create server release on GitHub
if: startsWith(github.ref, 'refs/tags/r')
runs-on: ubuntu-latest
needs: [release-docker-io-debian, release-quay-io-debian, release-docker-io-alpine, release-quay-io-alpine]
steps:
- name: Create server release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
release-client-github:
name: Create client release on GitHub
if: startsWith(github.ref, 'refs/tags/r')
runs-on: ubuntu-latest
needs: [release-docker-io-debian, release-quay-io-debian, release-docker-io-alpine, release-quay-io-alpine]
steps:
- name: Create client release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
repository: Libki/libki-client