-
Notifications
You must be signed in to change notification settings - Fork 226
127 lines (123 loc) · 3.62 KB
/
Copy pathtest.yml
File metadata and controls
127 lines (123 loc) · 3.62 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
name: Test
on:
push:
pull_request:
env:
REGISTRY: ghcr.io
jobs:
test-misc: # quick, simple checks
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install shellcheck
- run: ./test/check-scripts.sh
- run: ./test/check-dockerfiles.sh
test-envsub:
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- run: cd test/envsub && ./run-tests.sh
test-nginx:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: 22.12.0
- run: cd test/nginx && npm i
- run: cd test/nginx && npm run lint
- run: cd test/nginx && ./run-tests.sh
- if: always()
run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix nginx
- if: always()
run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix service
- if: always()
run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix enketo
test-images:
needs:
- test-misc
- test-envsub
- test-nginx
runs-on: ubuntu-latest # TODO matrix to run on all expected versions?
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- run: ./test/check-docker-context.sh --report
- run: ./test/test-images.sh
- if: always()
run: docker compose logs
check-image-references:
if: ${{ github.ref_type == 'tag' }}
needs:
- test-images
runs-on: ubuntu-latest
strategy:
matrix:
image: [nginx, service]
steps:
- name: Check tag format
run: '[[ "${{ github.ref_name }}" = v*.*.* ]]'
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/central-${{ matrix.image }}
- name: Check release image is referenced in docker-compose.yml
run: 'grep "${{ steps.meta.outputs.tags }}" docker-compose.yml'
build-push-image:
needs:
- check-image-references
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image: [nginx, service]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/central-${{ matrix.image }}
- name: Set up QEMU emulator for multi-arch images
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push ${{ matrix.image }} Docker image
uses: docker/build-push-action@v5
with:
file: ${{ matrix.image }}.dockerfile
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: 'linux/amd64,linux/arm64'