-
Notifications
You must be signed in to change notification settings - Fork 146
230 lines (206 loc) · 8.42 KB
/
build_docker_images.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
---
name: Docker build
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
- 'feature/**'
workflow_dispatch:
# for each ref (branch/pr) run just the most recent, cancel
# other pending/running ones
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref }}"
cancel-in-progress: true
jobs:
docker_build:
name: Build images
runs-on: ubuntu-latest
steps:
- name: Upload Event File
# this step is required to publish test results from forks
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Filter changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
api:
- 'api_app/**/*'
api_version:
- 'api_app/_version.py'
resource_processor:
- 'resource_processor/**/*'
resource_processor_version:
- 'resource_processor/_version.py'
guacamole_server:
- 'templates/workspace_services/guacamole/guacamole-server/**/*'
guacamole_server_version:
- 'templates/workspace_services/guacamole/guacamole-server/docker/version.txt'
gitea:
- 'templates/shared_services/gitea/docker/**/*'
gitea_version:
- 'templates/shared_services/gitea/docker/version.txt'
airlock_processor:
- 'airlock_processor/**/*'
airlock_processor_version:
- 'airlock_processor/_version.py'
ui_app:
- 'ui/app/**/*'
ui_app_version:
- 'ui/app/package.json'
- name: "Stale version: api"
if: ${{ steps.filter.outputs.api == 'true' &&
steps.filter.outputs.api_version == 'false' }}
run: echo "::error::Code update without version change" && exit 1
- name: "Stale version: resource_processor"
if: ${{ steps.filter.outputs.resource_processor == 'true' &&
steps.filter.outputs.resource_processor_version == 'false' }}
run: echo "::error::Code update without version change" && exit 1
- name: "Stale version: guacamole_server"
if: ${{ steps.filter.outputs.guacamole_server == 'true' &&
steps.filter.outputs.guacamole_server_version == 'false' }}
run: echo "::error::Code update without version change" && exit 1
- name: "Stale version: gitea"
if: ${{ steps.filter.outputs.gitea == 'true' &&
steps.filter.outputs.gitea_version == 'false' }}
run: echo "::error::Code update without version change" && exit 1
- name: "Stale version: airlock_processor"
if: ${{ steps.filter.outputs.airlock_processor == 'true' &&
steps.filter.outputs.airlock_processor_version == 'false' }}
run: echo "::error::Code update without version change" && exit 1
- name: "Stale version: ui_app"
if: ${{ steps.filter.outputs.ui_app == 'true' &&
steps.filter.outputs.ui_app_version == 'false' }}
run: echo "::error::Code update without version change" && exit 1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# Unit Tests are executed by calling the 'test-results' target in the
# Dockerfile's. Test runner exit codes must be swallowed (and kept) so we
# can output the test results. This means we have to check for failure
# trigger files in later steps.
- name: "Test image: api"
# test should be before build since its docker target
# is prior to runtime
if: |
(steps.filter.outputs.api == 'true'
|| github.event_name == 'workflow_dispatch')
uses: docker/build-push-action@v5
with:
context: ./api_app/
file: ./api_app/Dockerfile
outputs: type=local,dest=test-results
target: test-results
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Check pytest failure file existence"
id: check_api_test_result
uses: andstor/file-existence-action@v3
with:
files: "test-results/pytest_api_unit_failed"
- name: "Build image: api"
if: |
(steps.filter.outputs.api == 'true'
|| github.event_name == 'workflow_dispatch')
&& steps.check_api_test_result.outputs.files_exists == 'false'
uses: docker/build-push-action@v5
with:
context: ./api_app/
file: ./api_app/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Build image: resource_processor"
if: |
(steps.filter.outputs.resource_processor == 'true'
|| github.event_name == 'workflow_dispatch')
uses: docker/build-push-action@v5
with:
context: ./resource_processor
file: ./resource_processor/vmss_porter/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Test image: guacamole_server"
if: |
(steps.filter.outputs.guacamole_server == 'true'
|| github.event_name == 'workflow_dispatch')
uses: docker/build-push-action@v5
with:
context: ./templates/workspace_services/guacamole/guacamole-server
file: ./templates/workspace_services/guacamole/guacamole-server/docker/Dockerfile
outputs: type=local,dest=test-results
target: test-results
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Check maven failure file existence"
id: check_maven_test_result
uses: andstor/file-existence-action@v3
with:
files: "test-results/guacamole_package_failed"
- name: "Build image: guacamole_server"
if: |
(steps.filter.outputs.guacamole_server == 'true'
|| github.event_name == 'workflow_dispatch')
&& steps.check_maven_test_result.outputs.files_exists == 'false'
uses: docker/build-push-action@v5
with:
context: ./templates/workspace_services/guacamole/guacamole-server
file: ./templates/workspace_services/guacamole/guacamole-server/docker/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Build image: gitea"
if: |
(steps.filter.outputs.gitea == 'true'
|| github.event_name == 'workflow_dispatch')
uses: docker/build-push-action@v5
with:
context: ./templates/shared_services/gitea/docker
file: ./templates/shared_services/gitea/docker/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
# Unit Tests are executed by calling the 'test-results' target in the
# Dockerfile's. Test runner exit codes must be swallowed (and kept) so we
# can output the test results. This means we have to check for failure
# trigger files in later steps.
- name: "Test image: airlock_processor"
# test should be before build since its docker target
# is prior to runtime
if: |
(steps.filter.outputs.airlock_processor == 'true'
|| github.event_name == 'workflow_dispatch')
uses: docker/build-push-action@v5
with:
context: ./airlock_processor/
file: ./airlock_processor/Dockerfile
outputs: type=local,dest=test-results
target: test-results
cache-from: type=gha
cache-to: type=gha,mode=max
- name: "Check pytest failure file existence"
id: check_airlock_processor_test_result
uses: andstor/file-existence-action@v3
with:
files: "test-results/pytest_airlock_processor_unit_failed"
- name: "Build image: airlock_processor"
if: |
(steps.filter.outputs.airlock_processor == 'true'
|| github.event_name == 'workflow_dispatch')
&& steps.check_airlock_processor_test_result.outputs.files_exists == 'false'
uses: docker/build-push-action@v5
with:
context: ./airlock_processor/
file: ./airlock_processor/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results