-
Notifications
You must be signed in to change notification settings - Fork 18
322 lines (312 loc) · 11.9 KB
/
container-image.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
name: Samba Container Image CI
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '0 2 * * *'
# Allow manually triggering a run in the github ui.
# See: https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow
workflow_dispatch: {}
env:
CONTAINER_CMD: docker
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# We need a newer version of shellcheck to avoid problems with the
# relative imports. Our scripts work on v0.7.2 and up but not the
# v0.7.0 preinstalled in the ubutnu image. We can force a local
# install by expliclity setting SHELLCHECK to `$ALT_BIN/shellcheck`
- name: Run static check tools
run: make check SHELLCHECK=$PWD/.bin/shellcheck
check-commits:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Ensure branches
run: git fetch
- name: Lint git commit messages
run: make check-gitlint
build-server:
# Reminder: the nightly-server images consume nightly samba rpm builds
# it is not *just* an image that gets built nightly
strategy:
matrix:
package_source: [default, nightly]
os: [centos, fedora, opensuse]
arch: [amd64]
exclude:
# there are no nightly packages for opensuse
- package_source: nightly
os: opensuse
include:
- package_source: devbuilds
os: centos
arch: amd64
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
IMG_TAG: ${{ matrix.package_source }}-${{ matrix.os }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Build the server image
run: make KIND=server PACKAGE_SOURCE=${{ matrix.package_source }} OS_NAME=${{ matrix.os}} BUILD_ARCH=${{ matrix.arch}} build-image
- name: Upload server image
uses: ishworkh/[email protected]
with:
image: "samba-server:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
retention_days: 1
build-ad-server:
strategy:
matrix:
package_source: [default, nightly]
os: [centos, fedora, opensuse]
arch: [amd64]
exclude:
# there are no nightly packages for opensuse
- package_source: nightly
os: opensuse
# the distro packages for centos do not include an ad-dc
- package_source: default
os: centos
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
IMG_TAG: ${{ matrix.package_source }}-${{ matrix.os }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Build the ad server image
run: make KIND=ad-server PACKAGE_SOURCE=${{ matrix.package_source }} OS_NAME=${{ matrix.os }} BUILD_ARCH=${{ matrix.arch }} build-image
- name: Upload ad server image
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
retention_days: 1
build-client:
strategy:
matrix:
os: [centos, fedora, opensuse]
arch: [amd64]
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
IMG_TAG: default-${{ matrix.os }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: build the client image
run: make KIND=client OS_NAME=${{ matrix.os }} BUILD_ARCH=${{ matrix.arch }} build-image
# The client image is used as a base for the samba-toolbox build process.
- name: Upload the client image
uses: ishworkh/[email protected]
with:
image: "samba-client:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
retention_days: 1
build-toolbox:
strategy:
matrix:
os: [centos, fedora, opensuse]
arch: [amd64]
needs: build-client
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
IMG_TAG: default-${{ matrix.os }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
# Download locally stored samba-client image to be used as base for building
# samba-toolbox.
- name: Download client image
uses: ishworkh/[email protected]
with:
image: "samba-client:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
# Workaround: retag the image so that the FQIN image matches the name in
# the toolbox containerfiles.
- name: Apply OS-latest tag to image (for centos)
run: ${{ env.CONTAINER_CMD }} tag samba-client:${{ env.IMG_TAG }} quay.io/samba.org/samba-client:${{ matrix.os }}-latest
- name: Apply latest tag to image (for fedora)
run: ${{ env.CONTAINER_CMD }} tag samba-client:${{ env.IMG_TAG }} quay.io/samba.org/samba-client:latest
- name: Build the toolbox image
run: make KIND=toolbox OS_NAME=${{ matrix.os }} BUILD_ARCH=${{ matrix.arch }} build-image
# Upload the toolbox image for reference and/or image push
- name: Upload the toolbox image
uses: ishworkh/[email protected]
with:
image: "samba-toolbox:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
retention_days: 1
test-server:
strategy:
matrix:
package_source: [default, nightly]
os: [centos, fedora, opensuse]
arch: [amd64]
exclude:
# there are no nightly packages for opensuse
- package_source: nightly
os: opensuse
include:
- package_source: devbuilds
os: centos
arch: amd64
needs: build-server
runs-on: ubuntu-latest
env:
BUILDAH_FORMAT: oci
IMG_TAG: ${{ matrix.package_source }}-${{ matrix.os }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Download server image
uses: ishworkh/[email protected]
with:
image: "samba-server:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Test the server image
run: LOCAL_TAG=samba-server:${{ env.IMG_TAG }} tests/test-samba-container.sh
test-ad-server-kubernetes:
strategy:
matrix:
package_source: [default, nightly]
os: [centos, fedora, opensuse]
arch: [amd64]
exclude:
# there are no nightly packages for opensuse
- package_source: nightly
os: opensuse
# the distro packages for centos do not include an ad-dc
- package_source: default
os: centos
needs:
- build-ad-server
- build-server
# need to explicitly use 20.04 to avoid problems with jq...
runs-on: ubuntu-20.04
env:
BUILDAH_FORMAT: oci
IMG_TAG: ${{ matrix.package_source }}-${{ matrix.os }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: nolar/setup-k3d-k3s@v1
- name: get nodes
run: kubectl get nodes
- name: Download ad server image
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Download file server image
uses: ishworkh/[email protected]
with:
image: "samba-server:${{ env.IMG_TAG }}"
container_engine: ${{ env.CONTAINER_CMD }}
- name: import images to k3d
run: k3d image import samba-server:${{ env.IMG_TAG }} samba-ad-server:${{ env.IMG_TAG }}
- name: run the ad-dc deployment test
run: ./tests/test-samba-ad-server-kubernetes.sh
push:
# verify it passes the test jobs first
needs:
- build-client
- build-toolbox
- test-server
- test-ad-server-kubernetes
runs-on: ubuntu-latest
env:
REPO_BASE: quay.io/samba.org
# NOTE: the fromJSON below is needed beause the syntax github uses
# doesn't actually understand JS/JSON style arrays (inline). When I left it
# out I just got an error. It is present in their example(s).
if: >
contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event_name)
&& github.repository == 'samba-in-kubernetes/samba-container'
steps:
- uses: actions/checkout@v4
- name: log in to quay.io
run: ${CONTAINER_CMD} login -u "${{ secrets.QUAY_USER }}" -p "${{ secrets.QUAY_PASS }}" quay.io
# pull in already built images we plan on pushing
# (server images)
- name: Fetch server default-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-server:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server nightly-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-server:nightly-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server nightly-centos-amd64
uses: ishworkh/[email protected]
with:
image: "samba-server:nightly-centos-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch server devbuilds-centos-amd64
uses: ishworkh/[email protected]
with:
image: "samba-server:devbuilds-centos-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
# (ad server images)
- name: Fetch ad-server default-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
- name: Fetch ad-server nightly-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-ad-server:nightly-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
# (client images)
- name: Fetch client default-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-client:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
# (toolbox images)
- name: Fetch toolbox default-fedora-amd64
uses: ishworkh/[email protected]
with:
image: "samba-toolbox:default-fedora-amd64"
container_engine: ${{ env.CONTAINER_CMD }}
# reapply missing tags
- name: Retag images
run: >
./hack/build-image
--retag
--container-engine=${CONTAINER_CMD}
--repo-base=${REPO_BASE}
--no-distro-qualified
-i samba-server:default-fedora-amd64
-i samba-server:nightly-fedora-amd64
-i samba-server:nightly-centos-amd64
-i samba-server:devbuilds-centos-amd64
-i samba-ad-server:default-fedora-amd64
-i samba-ad-server:nightly-fedora-amd64
-i samba-client:default-fedora-amd64
-i samba-toolbox:default-fedora-amd64
- name: Push images
run: >
./hack/build-image
--push
--container-engine=${CONTAINER_CMD}
--verbose
--push-state=exists
--push-selected-tags=mixed
-i ${REPO_BASE}/samba-server:default-fedora-amd64
-i ${REPO_BASE}/samba-server:nightly-fedora-amd64
-i ${REPO_BASE}/samba-server:nightly-centos-amd64
-i ${REPO_BASE}/samba-server:devbuilds-centos-amd64
-i ${REPO_BASE}/samba-ad-server:default-fedora-amd64
-i ${REPO_BASE}/samba-ad-server:nightly-fedora-amd64
-i ${REPO_BASE}/samba-client:default-fedora-amd64
-i ${REPO_BASE}/samba-toolbox:default-fedora-amd64