forked from AlmaLinux/compose-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
371 lines (326 loc) · 13.4 KB
/
almalinux-compose-test-arm64.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
name: almalinux-compose-test-arm64
on:
workflow_dispatch:
inputs:
version_major:
description: 'AlmaLinux major version'
required: true
default: '9'
type: choice
options:
- 9
- 8
pungi_repository:
description: 'Add AlmaLinux pungi repositories'
type: boolean
pulp_repository:
description: 'Add AlmaLinux pulp repositories'
type: boolean
rerun_failed:
description: 'Re-run failed tests'
type: boolean
jobs:
start-runner:
timeout-minutes: 10 # normally it only takes 1-2 minutes
name: Setup and start self-hosted EC2 runner
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Check inputs
run: |
# Fail tasts if both pungi and pulp repositories are used
if [ "x${{ inputs.pungi_repository }}" = "xtrue" -a "x${{ inputs.pulp_repository }}" = "xtrue" ]; then
echo "[Debug] Both pungi and pulp repositories can't be used."
exit 1
fi
exit 0
- name: Setup and start runner
id: start-ec2-runner
uses: NextChapterSoftware/[email protected]
with:
github_token: ${{ secrets.GIT_HUB_TOKEN }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
ec2_ami_id: ${{ inputs.version_major == '9' && secrets.EC2_AMI_ID_AL9 || secrets.EC2_AMI_ID_AL8 }}
ec2_subnet_id: ${{ secrets.EC2_SUBNET_ID}}
ec2_security_group_id: ${{ secrets.EC2_SECURITY_GROUP_ID }}
ec2_instance_type: t4g.small # 2 vCPU and 2 GiM Memory are enought to run tests
ec2_root_disk_size_gb: "16" # override default size which is too small for actions and tests stuff
ec2_root_disk_ebs_class: "gp3" # use faster and cheeper storage instead of default 'gp2'
ec2_instance_ttl: 60 # Optional (default is 60 minutes)
ec2_spot_instance_strategy: None # Other options are: SpotOnly, BestEffort, MaxPerformance
ec2_instance_tags: > # Required for IAM role resource permission scoping
[
{"Key": "Project", "Value": "GitHub Actions Self-hosted Runners"}
]
compose-test:
name: Testing AlmaLinux ${{ inputs.version_major }}
runs-on: ${{ github.run_id }}
# continue-on-error: true
needs: start-runner # required to start the main job when the runner is ready
steps:
- uses: actions/checkout@v4
- name: Prepare stuff
run: |
# Name of repository to enable (PowerTools/CRB)
dnf_crb_repo='PowerTools'
if [ "${{ inputs.version_major }}" = "9" ]; then
dnf_crb_repo='CRB'
fi
if [ "x${{ inputs.pulp_repository }}" = "xtrue" ]; then
# Lowercase the name for path in pulp's URL
dnf_crb_repo="${dnf_crb_repo,,}"
fi
echo "dnf_crb_repo=${dnf_crb_repo}" >> $GITHUB_ENV
# TMT tests run directory
echo "tmt_run_dir=/var/tmp/tmt/run-001" >> $GITHUB_ENV
- name: Create AlmaLinux pungi repository
if: inputs.pungi_repository
run: |
cat <<'EOF'>/etc/yum.repos.d/almalinux-pungi.repo
[almalinux-${{ inputs.version_major }}-appstream-pungi]
baseurl = http://$arch-pungi-${{ inputs.version_major }}.almalinux.org/almalinux/${{ inputs.version_major }}/$arch/latest_result/compose/AppStream/$arch/os/
enabled = 1
name = almalinux-${{ inputs.version_major }}-appstream-pungi
[almalinux-${{ inputs.version_major }}-baseos-pungi]
baseurl = http://$arch-pungi-${{ inputs.version_major }}.almalinux.org/almalinux/${{ inputs.version_major }}/$arch/latest_result/compose/BaseOS/$arch/os/
enabled = 1
name = almalinux-${{ inputs.version_major }}-baseos-pungi
[almalinux-${{ inputs.version_major }}-${{ env.dnf_crb_repo }}-pungi]
baseurl = http://$arch-pungi-${{ inputs.version_major }}.almalinux.org/almalinux/${{ inputs.version_major }}/$arch/latest_result/compose/${{ env.dnf_crb_repo }}/$arch/os/
enabled = 1
name = almalinux-${{ inputs.version_major }}-${{ env.dnf_crb_repo }}-pungi
EOF
- name: Create AlmaLinux pulp repository
if: inputs.pulp_repository
run: |
cat <<'EOF'>/etc/yum.repos.d/almalinux-pulp.repo
[almalinux-${{ inputs.version_major }}-appstream-pulp]
baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ inputs.version_major }}-appstream-$arch/
enabled = 1
name = almalinux-${{ inputs.version_major }}-appstream-pulp
[almalinux-${{ inputs.version_major }}-baseos-pulp]
baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ inputs.version_major }}-baseos-$arch/
enabled = 1
name = almalinux-${{ inputs.version_major }}-baseos-pulp
[almalinux-${{ inputs.version_major }}-${{ env.dnf_crb_repo }}-pulp]
baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ inputs.version_major }}-${{ env.dnf_crb_repo }}-$arch/
enabled = 1
name = almalinux-${{ inputs.version_major }}-${{ env.dnf_crb_repo }}-pulp
EOF
# - name: Update the system
# run: |
# sudo dnf -y clean all
# sudo dnf -y update
- name: Prepare test infrastructure
run: |
sudo dnf -y install epel-release wget
enable_repo=${{ env.dnf_crb_repo }}
sudo dnf install -y --enablerepo=${enable_repo,,} tmt
# - name: Run tests
# id: run-tests
# run: |
# # If re-run, do not fail the step even some tests fail
# exit_with=false
# [ "${{ inputs.rerun_failed }}" = "true" ] && exit_with=true
# # Use envirounment variable to idicate tests state
# echo "run_tests=fail" >> $GITHUB_ENV
# sudo sh -c 'export pungi_repository=${{ inputs.pungi_repository }}; export pulp_repository=${{ inputs.pulp_repository }}; tmt -vvv -c distro=centos-stream-${{ inputs.version_major }} run --all provision --how=local' \
# || $exit_with
# echo "run_tests=success" >> $GITHUB_ENV
# - name: Print tests results
# # if: success() || failure()
# run: |
# #[Debug]
# sudo cat ${{ env.tmt_run_dir }}/plans/legacy/execute/results.yaml ${{ env.tmt_run_dir }}/plans/ng/execute/results.yaml
# sudo /bin/cp -av ${{ env.tmt_run_dir }}/plans/legacy/execute/results.yaml ${{github.action_path}}/legacy.results.yaml
# sudo /bin/cp -av ${{ env.tmt_run_dir }}/plans/ng/execute/results.yaml ${{github.action_path}}/ng.results.yaml
# - name: Print tests log
# # if: success() || failure()
# run: |
# #[Debug]
# sudo cat ${{ env.tmt_run_dir }}/log.txt
# sudo /bin/cp -av ${{ env.tmt_run_dir }}/log.txt ${{github.action_path}}/log.txt
# - name: Collect tests output
# # if: success() || failure()
# run: |
# cd ${{ env.tmt_run_dir }}/
# tar cf ${{github.action_path}}/output.tar $( find . -name output.txt ) || true
# - uses: actions/upload-artifact@v4
# # if: success() || failure()
# with:
# name: Tests log
# path: ${{github.action_path}}/log.txt
# - uses: actions/upload-artifact@v4
# # if: success() || failure()
# with:
# name: Tests results
# path: ${{github.action_path}}/*.results.yaml
# - uses: actions/upload-artifact@v4
# # if: success() || failure()
# with:
# name: Tests output
# path: ${{github.action_path}}/output.tar
- name: Create .yaml
run: |
mkdir -p ${{ env.tmt_run_dir }}/plans/legacy/execute/ ${{ env.tmt_run_dir }}/plans/ng/execute/
cat <<'EOF'>${{ env.tmt_run_dir }}/plans/legacy/execute/results.yaml
- name: /tests/legacy/p_osbuild
serialnumber: 73
fmf_id:
url: https://github.com/AlmaLinux/compose-tests.git
ref: almalinux
name: /tests/legacy/p_osbuild
result: pass
note:
ids:
id:
extra-nitrate:
extra-task:
log:
- data/guest/default-0/tests/legacy/p_osbuild-73/output.txt
guest:
name: default-0
role:
__class__:
module: tmt.result
name: ResultGuestData
starttime: '2024-06-12T13:02:56.919857+00:00'
endtime: '2024-06-12T13:10:59.855935+00:00'
duration: 00:08:02
__class__:
module: tmt.result
name: Result
- name: /tests/legacy/p_passwd
serialnumber: 74
fmf_id:
url: https://github.com/AlmaLinux/compose-tests.git
ref: almalinux
name: /tests/legacy/p_passwd
result: fail
note:
ids:
id:
extra-nitrate:
extra-task:
log:
- data/guest/default-0/tests/legacy/p_passwd-74/output.txt
guest:
name: default-0
role:
__class__:
module: tmt.result
name: ResultGuestData
starttime: '2024-06-12T13:10:59.928800+00:00'
endtime: '2024-06-12T13:11:12.358420+00:00'
duration: 00:00:12
__class__:
module: tmt.result
name: Result
EOF
cat <<'EOF'>${{ env.tmt_run_dir }}/plans/ng/execute/results.yaml
- name: /tests/acl
serialnumber: 73
fmf_id:
url: https://github.com/AlmaLinux/compose-tests.git
ref: almalinux
name: /tests/legacy/p_osbuild
result: fail
note:
ids:
id:
extra-nitrate:
extra-task:
log:
- data/guest/default-0/tests/legacy/p_osbuild-73/output.txt
guest:
name: default-0
role:
__class__:
module: tmt.result
name: ResultGuestData
starttime: '2024-06-12T13:02:56.919857+00:00'
endtime: '2024-06-12T13:10:59.855935+00:00'
duration: 00:08:02
__class__:
module: tmt.result
name: Result
- name: /tests/curl
serialnumber: 74
fmf_id:
url: https://github.com/AlmaLinux/compose-tests.git
ref: almalinux
name: /tests/legacy/p_passwd
result: pass
note:
ids:
id:
extra-nitrate:
extra-task:
log:
- data/guest/default-0/tests/legacy/p_passwd-74/output.txt
guest:
name: default-0
role:
__class__:
module: tmt.result
name: ResultGuestData
starttime: '2024-06-12T13:10:59.928800+00:00'
endtime: '2024-06-12T13:11:12.358420+00:00'
duration: 00:00:12
__class__:
module: tmt.result
name: Result
EOF
- name: Run tests
id: run-tests
run: |
# If re-run, do not fail the step even some tests fail
exit_with=false
[ "${{ inputs.rerun_failed }}" = "true" ] && exit_with=true
false \
|| $exit_with
- name: Get list of failed tests
if: success() || failure()
# if: ${{ env.run_tests }} == 'fail' && ( success() || failure() )
id: get-failed
run: |
# Install 'yq'
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 -O /usr/bin/yq
chmod +x /usr/bin/yq
# Get failed tests list
yq --no-doc '.[] | select(.result == "fail") | .name' ${{ env.tmt_run_dir }}/plans/legacy/execute/results.yaml ${{ env.tmt_run_dir }}/plans/ng/execute/results.yaml > ${{ env.tmt_run_dir }}/tests_failed.txt
- name: Re-run failed tests or prepare results summary
if: success() || failure()
# if: ${{ env.run_tests }} == 'fail' && ( success() || failure() )
run: |
rerun_results=
exit_code=0
while IFS= read -r test_failed ; do
# Include failed test name into resiults summary
test_result="${test_failed}"
if [ "${{ inputs.rerun_failed }}" = "true" ]; then
if sudo sh -c "export pungi_repository=${{ inputs.pungi_repository }}; export pulp_repository=${{ inputs.pulp_repository }}; tmt -vvv -c distro=centos-stream-${{ inputs.version_major }} run --all provision --how=local test --name $test_failed"; then
test_result="${test_failed} [re-run ✅]"
else
test_result="${test_failed} [re-run ❌]"
exit_code=1
fi
fi
# Format re-run results in list format: 'item1', 'item2', ...
[ "x${rerun_results}" = "x" ] && rerun_results="'${test_result}'" || rerun_results="${rerun_results}, '${test_result}'"
done < ${{ env.tmt_run_dir }}/tests_failed.txt
echo "rerun_results=${rerun_results}" >> $GITHUB_ENV
exit $exit_code
- name: Print failed tests
if: ${{ env.rerun_results != '' || failure() }}
uses: actions/github-script@v7
with:
result-encoding: string
script: |
core.summary
.addHeading('Failed tests:', '4')
.addList([${{ env.rerun_results }}], true)
.write()