almalinux-compose-test-x86_64 #140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: almalinux-compose-test-x86_64 | |
on: | |
workflow_dispatch: | |
inputs: | |
version_major: | |
description: 'AlmaLinux major version' | |
required: true | |
default: '10' | |
type: choice | |
options: | |
- 10-kitten | |
- 10 | |
- 9 | |
- 8 | |
pungi_repository: | |
description: 'Add pungi repositories' | |
type: boolean | |
pulp_repository: | |
description: 'Add pulp repositories' | |
type: boolean | |
rerun_failed: | |
description: 'Re-run failed tests' | |
type: boolean | |
default: true | |
jobs: | |
compose-test: | |
name: AlmaLinux ${{ matrix.variant }} | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
variant: ${{ fromJSON(format('["{0}"]', ( inputs.version_major == '10-kitten' && '10-kitten", "10-kitten-x86_64_v2' || ( inputs.version_major == '10' && '10", "10-x86_64_v2' || inputs.version_major ) ) )) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare stuff | |
run: | | |
# Environment variables | |
pungi_latest_result=latest_result | |
pulp_root=${{ inputs.version_major }} | |
tmt_options= | |
rpm_gpg_key=/etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux | |
vm_box=almalinux/${{ inputs.version_major }} | |
release_version=${{ inputs.version_major }} | |
dnf_crb_repo='CRB' | |
case ${{ matrix.variant }} in | |
8) | |
dnf_crb_repo='PowerTools' | |
;; | |
9) | |
tmt_options='--feeling-safe' | |
rpm_gpg_key="${rpm_gpg_key}-9" | |
;; | |
10) | |
vm_box=lkhn/almalinux-10 | |
tmt_options='--feeling-safe' | |
rpm_gpg_key="${rpm_gpg_key}-10" | |
;; | |
10-x86_64_v2) | |
vm_box=yuravk/almalinux-10-x86-64-v2 | |
tmt_options='--feeling-safe' | |
rpm_gpg_key="${rpm_gpg_key}-10" | |
;; | |
10-kitten) | |
vm_box=lkhn/almalinux-kitten | |
release_version=10 | |
pulp_root=kitten-10 | |
pungi_latest_result="${pungi_latest_result}_almalinux-kitten" | |
tmt_options='--feeling-safe' | |
rpm_gpg_key="${rpm_gpg_key}-10" | |
;; | |
10-kitten-x86_64_v2) | |
vm_box=lkhn/almalinux-kitten-x86-64-v2 | |
release_version=10 | |
pulp_root=kitten-10 | |
pungi_latest_result="${pungi_latest_result}_almalinux-kitten" | |
tmt_options='--feeling-safe' | |
rpm_gpg_key="${rpm_gpg_key}-10" | |
;; | |
esac | |
# Release major version | |
echo "release_version=${release_version}" >> $GITHUB_ENV | |
# Pulp repository root of the release | |
echo "pulp_root=${pulp_root}" >> $GITHUB_ENV | |
# Pungi repository latest results directory | |
echo "pungi_latest_result=${pungi_latest_result}" >> $GITHUB_ENV | |
# Name of repository to enable (PowerTools/CRB) | |
if [ "x${{ inputs.pulp_repository }}" = "xtrue" ]; then | |
# Lowercase the name for path in pulp's URL | |
pulp_crb_repo="${dnf_crb_repo,,}" | |
fi | |
echo "dnf_crb_repo=${dnf_crb_repo}" >> $GITHUB_ENV | |
echo "pulp_crb_repo=${pulp_crb_repo}" >> $GITHUB_ENV | |
# TMT extra options | |
echo "tmt_options=${tmt_options}" >> $GITHUB_ENV | |
# RPM_GPG_KEY file | |
echo "rpm_gpg_key=${rpm_gpg_key}" >> $GITHUB_ENV | |
# Use proper Vagrantfile and set ENV variable of config.vm.box | |
cp -av ci/Vagrant/Vagrantfile ./ | |
echo vm_box=${vm_box} > .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: | | |
# Use Vagrant packages provided by Hashicorp as ubuntu-24.04 doesn't build ones | |
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list | |
sudo apt-get -y update | |
sudo apt-get -y install vagrant | |
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.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources."$(date +"%F")" | |
sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources | |
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 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-${{ env.release_version }}-appstream-pungi] | |
baseurl = http://x86-64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/AppStream/$arch/os/ | |
enabled = 1 | |
name = almalinux-${{ env.release_version }}-appstream-pungi | |
gpgkey=file://${{ env.rpm_gpg_key }} | |
[almalinux-${{ env.release_version }}-baseos-pungi] | |
baseurl = http://x86-64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/BaseOS/$arch/os/ | |
enabled = 1 | |
name = almalinux-${{ env.release_version }}-baseos-pungi | |
gpgkey=file://${{ env.rpm_gpg_key }} | |
[almalinux-${{ env.release_version }}-${{ env.dnf_crb_repo }}-pungi] | |
baseurl = http://x86-64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/${{ env.dnf_crb_repo }}/$arch/os/ | |
enabled = 1 | |
name = almalinux-${{ env.release_version }}-${{ env.dnf_crb_repo }}-pungi | |
gpgkey=file://${{ env.rpm_gpg_key }} | |
EOF | |
- name: Create AlmaLinux pulp repository | |
if: inputs.pulp_repository | |
run: | | |
cat <<'EOF'>./almalinux-pulp.repo | |
[almalinux-${{ env.pulp_root }}-appstream-pulp] | |
baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-appstream-$arch/ | |
enabled = 1 | |
name = almalinux-${{ env.pulp_root }}-appstream-pulp | |
gpgkey=file://${{ env.rpm_gpg_key }} | |
[almalinux-${{ env.pulp_root }}-baseos-pulp] | |
baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-baseos-$arch/ | |
enabled = 1 | |
name = almalinux-${{ env.pulp_root }}-baseos-pulp | |
gpgkey=file://${{ env.rpm_gpg_key }} | |
[almalinux-${{ env.pulp_root }}-${{ env.pulp_crb_repo }}-pulp] | |
baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-${{ env.pulp_crb_repo }}-$arch/ | |
enabled = 1 | |
name = almalinux-${{ env.pulp_root }}-${{ env.pulp_crb_repo }}-pulp | |
gpgkey=file://${{ env.rpm_gpg_key }} | |
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 | |
echo "[Debug] failed tests:" | |
echo "$(cat ${{ env.tmt_run_dir }}/tests_failed.txt)" | |
EOF | |
- name: Run vagrant up | |
run: | | |
# TODO to solve "undefined method `exists?'" error | |
sudo sed -i 's/exists?/exist?/g' /root/.vagrant.d/gems/3.3.6/gems/dotenv-0.11.1/lib/dotenv.rb | |
sudo vagrant up --no-tty almalinux | |
- name: Get system release | |
run: | | |
system_release=$(sudo vagrant ssh almalinux -c "cat /etc/almalinux-release") | |
echo "system_release=${system_release}" >> $GITHUB_ENV | |
- name: Prepare test infrastructure | |
run: | | |
enable_repo=${{ env.dnf_crb_repo }} | |
case ${{ matrix.variant }} in | |
10-kitten*) | |
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo='extras-common' almalinux-kitten-release-devel" | |
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo='${enable_repo,,} devel' python3-pip beakerlib" | |
sudo vagrant ssh almalinux -c "sudo sh -c 'export PATH=$PATH:/usr/local/bin; pip install flexparser==0.3.1 tmt'" | |
;; | |
10) | |
sudo vagrant ssh almalinux -c "sudo dnf config-manager --add-repo https://build.almalinux.org/pulp/content/builds/AlmaLinux-Kitten-10-x86_64-20670-br/" | |
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo='${enable_repo,,} extras' python3-pip beakerlib" | |
sudo vagrant ssh almalinux -c "sudo sh -c 'export PATH=$PATH:/usr/local/bin; pip install flexparser==0.3.1 tmt'" | |
;; | |
10-x86_64_v2) | |
sudo vagrant ssh almalinux -c "sudo dnf config-manager --add-repo https://build.almalinux.org/pulp/content/builds/AlmaLinux-Kitten-10-x86_64_v2-20670-br/" | |
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo='${enable_repo,,} extras' python3-pip beakerlib" | |
sudo vagrant ssh almalinux -c "sudo sh -c 'export PATH=$PATH:/usr/local/bin; pip install flexparser==0.3.1 tmt'" | |
;; | |
9) | |
sudo vagrant ssh almalinux -c "sudo dnf -y install epel-release" | |
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo=${enable_repo,,} tmt initscripts-service" | |
;; | |
*) | |
sudo vagrant ssh almalinux -c "sudo dnf -y install epel-release" | |
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo=${enable_repo,,} tmt" | |
;; | |
esac | |
echo "[Debug] $(sudo vagrant ssh almalinux -c 'export PATH=$PATH:/usr/local/bin; tmt --version')" | |
- 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 }}; export PATH=$PATH:/usr/local/bin; cd /compose-tests; tmt -vvv -c distro=centos-stream-${{ env.release_version }} run --all provision --how=local ${{ env.tmt_options }}'" | |
- 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: ${{ matrix.variant }} tests log | |
path: ${{github.action_path}}/log.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.variant }} tests results | |
path: ${{github.action_path}}/*.results.yaml | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.variant }} 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 | |
sudo chmod a+r ${{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 | |
for test_failed in $(cat ${{github.action_path}}/tests_failed.txt | xargs); do | |
echo "[Debug] Re-run '${test_failed}'" | |
# 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 }}; export PATH=$PATH:/usr/local/bin; cd /compose-tests; tmt -vvv -c distro=centos-stream-${{ env.release_version }} run --all provision --how=local ${{ env.tmt_options }} 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 | |
# 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.system_release }}', '4') | |
.addHeading('Used repositories:', '4') | |
.addList(['pulp - ${{ inputs.pulp_repository && '✅' || '❌'}}','pungi - ${{ inputs.pungi_repository && '✅' || '❌'}}'], true) | |
.addHeading('${{ env.summary_header }}', '4') | |
.addList([${{ env.rerun_results }}], true) | |
.write() |