forked from AlmaLinux/compose-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
251 lines (207 loc) · 10.4 KB
/
almalinux-compose-test-x86_64.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
name: almalinux-compose-test-x86_64
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
default: true
jobs:
compose-test:
name: Testing AlmaLinux ${{ inputs.version_major }}
runs-on: ubuntu-latest
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
# Verify that CPU supports hardware virtualization
echo -n "Number of vmx|svm CPUs: " && grep -E -c '(vmx|svm)' /proc/cpuinfo
# Use proper Vagrantfile and set ENV variable of config.vm.box
cp -av ci/Vagrant/Vagrantfile ./
echo vm_box='almalinux/${{ inputs.version_major }}' > .env
# TMT tests run directory
echo "tmt_run_dir=/var/tmp/tmt/run-001" >> $GITHUB_ENV
- name: Install KVM Packages and Start libvirt
run: |
sudo apt-get -y update
sudo apt-get -y install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
sudo systemctl enable --now libvirtd
sudo adduser "$(id -un)" libvirt
sudo adduser "$(id -un)" kvm
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Tune libvirt
run: virsh list --all
- name: Install Vagrant
run: |
sudo apt-get -y install vagrant
sudo vagrant --version
sudo vagrant plugin install vagrant-reload
sudo vagrant plugin install vagrant-env
- name: Install the Vagrant libvirt Plugin
run: |
sudo cp /etc/apt/sources.list /etc/apt/sources.list."$(date +"%F")"
sudo sed -i -e '/^# deb-src.*universe$/s/# //g' /etc/apt/sources.list
sudo apt-get -y update
sudo apt-get -y install nfs-kernel-server
sudo systemctl enable --now nfs-server
sudo apt-get -y build-dep vagrant ruby-libvirt
sudo apt-get -y install ebtables dnsmasq-base
sudo apt-get -y install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
sudo vagrant plugin install vagrant-libvirt
sudo vagrant plugin install vagrant-scp
- name: Create AlmaLinux pungi repository
if: inputs.pungi_repository
run: |
cat <<'EOF'>./almalinux-pungi.repo
[almalinux-${{ inputs.version_major }}-appstream-pungi]
baseurl = http://$arch-pungi-${{ inputs.version_major }}.almalinux.dev/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.dev/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.dev/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'>./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: Create 'yq' script to get failed tests
run: |
cat <<'EOF'>./yq.sh
yq --no-doc '.[] | select(.result == "fail" or .result == "error") | .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
EOF
- name: Run vagrant up
run: sudo vagrant up almalinux
- name: Prepare test infrastructure
run: |
sudo vagrant ssh almalinux -c 'sudo dnf -y install epel-release'
enable_repo=${{ env.dnf_crb_repo }}
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo=${enable_repo,,} tmt"
- name: Get compose-tests
run: sudo vagrant ssh almalinux -c 'sudo cp -a /vagrant /compose-tests'
- name: Run tests
id: run-tests
continue-on-error: true
run: sudo vagrant ssh almalinux -c "sudo sh -c 'export pungi_repository=${{ inputs.pungi_repository }}; export pulp_repository=${{ inputs.pulp_repository }}; cd /compose-tests; tmt -vvv -c distro=centos-stream-${{ inputs.version_major }} run --all provision --how=local'"
- name: Print tests results
run: |
sudo vagrant ssh almalinux -c "sudo cat ${{ env.tmt_run_dir }}/plans/legacy/execute/results.yaml ${{ env.tmt_run_dir }}/plans/ng/execute/results.yaml"
sudo vagrant scp almalinux:${{ env.tmt_run_dir }}/plans/legacy/execute/results.yaml ${{github.action_path}}/legacy.results.yaml
sudo vagrant scp almalinux:${{ env.tmt_run_dir }}/plans/ng/execute/results.yaml ${{github.action_path}}/ng.results.yaml
- name: Print tests log
run: |
sudo vagrant ssh almalinux -c "sudo cat ${{ env.tmt_run_dir }}/log.txt"
sudo vagrant scp almalinux:${{ env.tmt_run_dir }}/log.txt ${{github.action_path}}/log.txt
- name: Collect tests output
run: |
sudo vagrant ssh almalinux -c 'sudo sh -c "cd ${{ env.tmt_run_dir }}/; tar cf output.tar plans/legacy/execute/data/guest/default-0/tests/legacy/*/output.txt plans/ng/execute/data/guest/default-0/tests/*/output.txt plans/ng/execute/data/guest/default-0/tests/*/*/output.txt plans/ng/execute/data/guest/default-0/tests/*/*/*/output.txt"'
sudo vagrant scp almalinux:${{ env.tmt_run_dir }}/output.tar ${{github.action_path}}/output.tar
- uses: actions/upload-artifact@v4
with:
name: Tests log
path: ${{github.action_path}}/log.txt
- uses: actions/upload-artifact@v4
with:
name: Tests results
path: ${{github.action_path}}/*.results.yaml
- uses: actions/upload-artifact@v4
with:
name: Tests output
path: ${{github.action_path}}/output.tar
- name: Get list of failed tests
if: job.steps.run-tests.status == failure()
run: |
# Install 'yq'
sudo vagrant ssh almalinux -c 'sudo dnf -y -q install wget'
sudo vagrant ssh almalinux -c 'sudo wget -q https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq'
sudo vagrant ssh almalinux -c 'sudo chmod +x /usr/bin/yq'
# Create failed tests list
sudo vagrant ssh almalinux -c "sudo sh -c 'chmod +x /vagrant/yq.sh; /vagrant/yq.sh'"
sudo vagrant scp almalinux:${{ env.tmt_run_dir }}/tests_failed.txt ${{github.action_path}}/tests_failed.txt
- name: Re-run failed tests, prepare tests summary
if: job.steps.run-tests.status == failure()
run: |
# Tests results and the step exit code
rerun_results=
exit_code=0
# Read failed tests list
while IFS= read -r test_failed ; do
# Include failed test name into resiults summary
test_result="${test_failed}"
# Re-run specific failed test
if [ "${{ inputs.rerun_failed }}" = "true" ]; then
if sudo vagrant ssh almalinux -c "sudo sh -c 'export pungi_repository=${{ inputs.pungi_repository }}; export pulp_repository=${{ inputs.pulp_repository }}; cd /compose-tests; 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
else
echo "[Debug]"
echo "If without re-run, fail this step as the '${test_failed}' test previously failed."
exit_code=1
fi
# Format test results in list format: 'item1', 'item2', ...
[ "x${rerun_results}" = "x" ] && rerun_results="'${test_result}'" || rerun_results="${rerun_results}, '${test_result}'"
done < ${{github.action_path}}/tests_failed.txt
# Export header and test results
[ "x${rerun_results}" = "x" ] && summary_header="✅ All tests pass." || summary_header="❌ Failed tests:"
echo "rerun_results=${rerun_results}" >> $GITHUB_ENV
echo "summary_header=${summary_header}" >> $GITHUB_ENV
exit $exit_code
- name: Print tests summary
if: job.steps.run-tests.status == failure() || failure()
uses: actions/github-script@v7
with:
result-encoding: string
script: |
core.summary
.addHeading('${{ env.summary_header }}', '4')
.addList([${{ env.rerun_results }}], true)
.write()