forked from freeipa/freeipa
-
Notifications
You must be signed in to change notification settings - Fork 0
411 lines (350 loc) · 13 KB
/
p10.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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
name: FreeIPA CI [p10]
on:
push:
branches:
- p10-ci
schedule:
# every day at 4 UTC
- cron: '0 7 * * *'
workflow_dispatch:
env:
# vars work only on steps level for now
IPA_TESTS_SCRIPTS: '.github/workflows/scripts'
SHELL_CMD: '/bin/bash --noprofile --norc -eux'
SHELL_CMD_NODEBUG: '/bin/bash --noprofile --norc -eu'
GHA_USER: gha_user
IPA_TESTS_DOCKERFILES: '.github/workflows/Dockerfiles'
# Docker image name built during CI and used for integration/base tests
IPA_DOCKER_IMAGE: 'freeipa-ci-builder'
MAX_CONTAINER_ENVS: 5
IPA_TESTS_ENV_WORKING_DIR: ${{ github.workspace }}/ipa_envs
# path to freeipa git repo inside container
IPA_TESTS_REPO_PATH: '/freeipa'
CI_RUNNER_LOGS_DIR: 'logs'
RUN_AS_GHA_USER: "runuser -u $GHA_USER -- "
# checkout branch for scheduled runs
GHA_TARGET_REF: "${{ github.event_name == 'schedule' && 'p10-ci' || github.sha }}"
jobs:
build:
name: Build packages and Docker image
runs-on: ubuntu-latest
container:
# job level is not supported by env, only step level
image: stanislavlevin/freeipa-build-altlinux:p10
options: --privileged --env container=docker
outputs:
tests_matrix: ${{ steps.tests_matrix.outputs.matrix }}
steps:
- name: Install git
# git is required for git clone otherwise there will be no .git dir
run: |
apt-get update
apt-get install -y git-core gzip
- name: Checkout sources
uses: actions/checkout@v2
with:
# fetch all tags
fetch-depth: 0
ref: ${{ env.GHA_TARGET_REF }}
- name: Print Host environment
run: env | sort
- name: Install base build environment
run: |
set -eu
useradd -m ${{ env.GHA_USER }}
# for build as unprivileged user
[ $(id -u) -eq 0 ] && chmod -R o+wrX .
${{ env.RUN_AS_GHA_USER }} \
git config --global --add safe.directory "$GITHUB_WORKSPACE"
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-build.sh
- name: Run autoconf
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/autoconf.sh
- name: Build packages
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/build-packages.sh
- name: Upload packages
uses: actions/upload-artifact@v2
with:
name: packages-${{ github.run_number }}-${{ github.run_attempt }}
if-no-files-found: error
path: ${{ github.workspace }}/dist/
- name: Create Docker image for tests
run: |
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}//build-docker-image.sh
- name: Upload Docker image
uses: actions/upload-artifact@v2
with:
name: docker-image-${{ github.run_number }}-${{ github.run_attempt }}
if-no-files-found: error
path: ${{ github.workspace }}/${{ env.IPA_DOCKER_IMAGE }}-image.tar.gz
- name: Generate Matrix for Base/Integration tests
id: tests_matrix
run: |
set -eu
python3 \
${{ env.IPA_TESTS_SCRIPTS }}/generate-matrix.py \
'ipatests/azure/azure_definitions/base.yml' \
'ipatests/azure/azure_definitions/gating.yml' \
'ipatests/azure/azure_definitions/nightly.yml' \
${{ env.MAX_CONTAINER_ENVS }}
- name: Check for consistency with PR-CI
run: |
python3 ${{ env.IPA_TESTS_SCRIPTS }}/gating_compare.py
lint:
name: Lint
runs-on: ubuntu-latest
container:
image: stanislavlevin/freeipa-build-altlinux:p10
options: --privileged --env container=docker
steps:
- name: Install git
# git is required for git clone otherwise there will be no .git dir
run: |
apt-get update
apt-get install -y git-core gzip
- name: Checkout sources
uses: actions/checkout@v2
with:
# fetch all tags
fetch-depth: 0
ref: ${{ env.GHA_TARGET_REF }}
- name: Install base build environment
run: |
set -eu
useradd -m ${{ env.GHA_USER }}
# for build as unprivileged user
[ $(id -u) -eq 0 ] && chmod -R o+wrX .
${{ env.RUN_AS_GHA_USER }} \
git config --global --add safe.directory "$GITHUB_WORKSPACE"
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-build.sh
- name: Install Lint dependencies
run: ${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-lint.sh
- name: Run autoconf
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/autoconf.sh
- name: Lint sources
run: ${{ env.RUN_AS_GHA_USER }} make V=0 lint
- name: Quick code style check
if: github.event_name == 'pull_request'
run: |
set -eu
${{ env.RUN_AS_GHA_USER }} git update-ref \
"refs/heads/${{ github.base_ref }}" "origin/${{ github.base_ref }}"
${{ env.RUN_AS_GHA_USER }} \
make V=0 "GIT_BRANCH=${{ github.base_ref }}" fastcodestyle
tests:
needs: [build, lint]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.build.outputs.tests_matrix) }}
fail-fast: false
name: ${{ matrix.ipa_tests_job_name }}
env: ${{ matrix.ipa_tests_env }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
# fetch all tags
fetch-depth: 0
ref: ${{ env.GHA_TARGET_REF }}
- uses: actions/download-artifact@v2
with:
name: packages-${{ github.run_number }}-${{ github.run_attempt }}
path: ${{ github.workspace }}/dist
- uses: actions/download-artifact@v2
with:
name: docker-image-${{ github.run_number }}-${{ github.run_attempt }}
path: ${{ github.workspace }}
- name: Print Host environment
run: env | sort
- name: Prepare Host
run: ${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-ci-host.sh
- name: Run tests
run: ${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/runner.sh
# hack: GHA doesn't provide browser for artifacts
# it is convenient to check runner's log without downloading of huge zip
# there is no loop in GHA atm, so it is assumed max env = 5
- name: Runners log ${{ matrix.ipa_tests_env_name_1 }}
if: always()
run: |
cat ${{ env.IPA_TESTS_ENV_WORKING_DIR }}/${{ matrix.ipa_tests_env_name_1 }}/runner_*.log ||:
- name: Runners log ${{ matrix.ipa_tests_env_name_2 }}
if: always()
run: |
cat ${{ env.IPA_TESTS_ENV_WORKING_DIR }}/${{ matrix.ipa_tests_env_name_2 }}/runner_*.log ||:
- name: Runners log ${{ matrix.ipa_tests_env_name_3 }}
if: always()
run: |
cat ${{ env.IPA_TESTS_ENV_WORKING_DIR }}/${{ matrix.ipa_tests_env_name_3 }}/runner_*.log ||:
- name: Runners log ${{ matrix.ipa_tests_env_name_4 }}
if: always()
run: |
cat ${{ env.IPA_TESTS_ENV_WORKING_DIR }}/${{ matrix.ipa_tests_env_name_4 }}/runner_*.log ||:
- name: Runners log ${{ matrix.ipa_tests_env_name_5 }}
if: always()
run: |
cat ${{ env.IPA_TESTS_ENV_WORKING_DIR }}/${{ matrix.ipa_tests_env_name_5 }}/runner_*.log ||:
# end of hack
- name: Host's memory statistics
if: always()
run: |
set -x
free -m
cat /sys/fs/cgroup/memory/memory.memsw.max_usage_in_bytes
cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes
cat /proc/sys/vm/swappiness
- name: Host's systemd journal
if: always()
run: |
set -eu
HOST_JOURNAL=host_journal.log
HOST_JOURNAL_PATH="${IPA_TESTS_ENV_WORKING_DIR}/${HOST_JOURNAL}.tar.gz"
sudo journalctl -b | tee "$HOST_JOURNAL"
function emit_warning() {
printf "::warning ::%s\n" "$1"
}
printf "AVC:\n"
grep 'AVC apparmor="DENIED"' "$HOST_JOURNAL" && \
emit_warning "There are Host's AVCs. Please, check the logs."
printf "SECCOMP:\n"
grep ' SECCOMP ' "$HOST_JOURNAL" && \
emit_warning "There are reported SECCOMP syscalls. Please, check the logs."
tar -czf "$HOST_JOURNAL_PATH" "$HOST_JOURNAL"
- name: Check for coredumps
if: always()
run:
${{ env.SHELL_CMD_NODEBUG }} ${{ env.IPA_TESTS_SCRIPTS }}/check-coredumps.sh
- name: Collect logs
if: always()
uses: actions/upload-artifact@v2
with:
name: logs-${{ matrix.ipa_tests_job_name }}-${{ github.run_number }}-${{ github.run_attempt }}
path: |
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/coredumps/*.core.tar.gz
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/coredumps/*.stacktrace.tar.gz
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*/logs/**
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*/*.yml
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*/*.yaml
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*/*.log
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*/systemd_boot_logs/*.log
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*/installed_packages/*.log
${{ env.IPA_TESTS_ENV_WORKING_DIR }}/*.tar.gz
docs:
name: Docs
runs-on: ubuntu-latest
container:
image: stanislavlevin/freeipa-build-altlinux:p10
options: --privileged --env container=docker
steps:
- name: Install git
# git is required for git clone otherwise there will be no .git dir
run: |
apt-get update
apt-get install -y git-core gzip
- name: Checkout sources
uses: actions/checkout@v2
with:
# fetch all tags
fetch-depth: 0
ref: ${{ env.GHA_TARGET_REF }}
- name: Install base build environment
run: |
set -eu
useradd -m ${{ env.GHA_USER }}
# for build as unprivileged user
[ $(id -u) -eq 0 ] && chmod -R o+wrX .
${{ env.RUN_AS_GHA_USER }} \
git config --global --add safe.directory "$GITHUB_WORKSPACE"
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-build.sh
- name: Run autoconf
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/autoconf.sh
- name: Build documentation
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/build-docs.sh
- name: Publish documentation
uses: actions/upload-artifact@v2
with:
name: docs-${{ github.run_number }}-${{ github.run_attempt }}
if-no-files-found: error
path: ${{ github.workspace }}/doc/_build/html/
tox:
name: Tox
runs-on: ubuntu-latest
container:
image: stanislavlevin/freeipa-build-altlinux:p10
options: --privileged --env container=docker
steps:
- name: Install git
# git is required for git clone otherwise there will be no .git dir
run: |
apt-get update
apt-get install -y git-core gzip
- name: Checkout sources
uses: actions/checkout@v2
with:
# fetch all tags
fetch-depth: 0
ref: ${{ env.GHA_TARGET_REF }}
- name: Install base build environment
run: |
set -eu
useradd -m ${{ env.GHA_USER }}
# for build as unprivileged user
[ $(id -u) -eq 0 ] && chmod -R o+wrX .
${{ env.RUN_AS_GHA_USER }} \
git config --global --add safe.directory "$GITHUB_WORKSPACE"
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-build.sh
- name: Install Tox prerequisites
run: ${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-tox.sh
- name: Run autoconf
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/autoconf.sh
- name: Tox
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/run-tox.sh
webui_unit_tests:
name: WebUI Unit Tests
runs-on: ubuntu-latest
container:
image: stanislavlevin/freeipa-build-altlinux:p10
options: --privileged --env container=docker
steps:
- name: Install git
# git is required for git clone otherwise there will be no .git dir
run: |
apt-get update
apt-get install -y git-core gzip
- name: Checkout sources
uses: actions/checkout@v2
with:
# fetch all tags
fetch-depth: 0
ref: ${{ env.GHA_TARGET_REF }}
- name: Install base build environment
run: |
set -eu
useradd -m ${{ env.GHA_USER }}
# for build as unprivileged user
[ $(id -u) -eq 0 ] && chmod -R o+wrX .
${{ env.RUN_AS_GHA_USER }} \
git config --global --add safe.directory "$GITHUB_WORKSPACE"
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-build.sh
- name: Install WebUI Unit tests prerequisites
run: ${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/prepare-webui.sh
- name: Run autoconf
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/autoconf.sh
- name: WebUI unit tests
run: |
${{ env.RUN_AS_GHA_USER }} \
${{ env.SHELL_CMD }} ${{ env.IPA_TESTS_SCRIPTS }}/run-webui.sh