network/.github/workflows/qemu-kvm-integration-tests.yml
Rich Megginson c0b8196731 ci: Add Fedora 42; use tox-lsr 3.9.0; use lsr-report-errors for qemu tests
Add Fedora 42 to testing farm test matrix, drop Fedora 40

Use tox-lsr 3.9.0 for the `--lsr-report-errors-url` argument.

Add the argument `--lsr-report-errors-url DEFAULT` to the qemu test so that
the errors will be written to the output log.  This uses the output callback
https://github.com/linux-system-roles/auto-maintenance/blob/main/callback_plugins/lsr_report_errors.py

Use the check_logs.py script
https://github.com/linux-system-roles/auto-maintenance/blob/main/check_logs.py
with the `--github-action-format` argument to format the errors
in a github action friendly manner.

Rename the log files `-FAIL.log` or `-SUCCESS.log` depending on status.
This is compatible with the way the testing farm log files are named, and
makes it easy to tell if a test passed or failed from the log file name.

Upload README.html as artifacts of the build_docs job for debugging

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2025-05-19 14:28:25 -06:00

200 lines
7.6 KiB
YAML

---
name: Test
on: # yamllint disable-line rule:truthy
pull_request:
merge_group:
branches:
- main
types:
- checks_requested
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
# This is required for the ability to create/update the Pull request status
statuses: write
jobs:
scenario:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scenario:
# QEMU
- { image: "centos-9", env: "qemu-ansible-core-2.16" }
- { image: "centos-10", env: "qemu-ansible-core-2.17" }
# ansible/libdnf5 bug: https://issues.redhat.com/browse/RHELMISC-10110
# - { image: "fedora-41", env: "qemu-ansible-core-2.17" }
- { image: "fedora-42", env: "qemu-ansible-core-2.17" }
# container
- { image: "centos-9", env: "container-ansible-core-2.16" }
- { image: "centos-9-bootc", env: "container-ansible-core-2.16" }
# broken on non-running dbus
# - { image: "centos-10", env: "container-ansible-core-2.17" }
- { image: "centos-10-bootc", env: "container-ansible-core-2.17" }
- { image: "fedora-41", env: "container-ansible-core-2.17" }
- { image: "fedora-42", env: "container-ansible-core-2.17" }
- { image: "fedora-41-bootc", env: "container-ansible-core-2.17" }
- { image: "fedora-42-bootc", env: "container-ansible-core-2.17" }
env:
TOX_ARGS: "--skip-tags tests::infiniband,tests::nvme,tests::scsi"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check if platform is supported
id: check_platform
run: |
set -euxo pipefail
image="${{ matrix.scenario.image }}"
image="${image%-bootc}"
# convert image to tag formats
platform=
platform_version=
case "$image" in
centos-*) platform=el; platform_version=el"${image#centos-}" ;;
fedora-*) platform=fedora; platform_version="${image/-/}" ;;
esac
supported=
if yq -e '.galaxy_info.galaxy_tags[] | select(. == "'${platform_version}'" or . == "'${platform}'")' meta/main.yml; then
supported=true
fi
# bootc build support (in buildah) has a separate flag
if [ "${{ matrix.scenario.image }}" != "$image" ]; then
if ! yq -e '.galaxy_info.galaxy_tags[] | select(. == "containerbuild")' meta/main.yml; then
supported=
fi
else
# roles need to opt into support for running in a system container
env="${{ matrix.scenario.env }}"
if [ "${env#container}" != "$env" ] &&
! yq -e '.galaxy_info.galaxy_tags[] | select(. == "container")' meta/main.yml; then
supported=
fi
fi
echo "supported=$supported" >> "$GITHUB_OUTPUT"
- name: Set up /dev/kvm
if: steps.check_platform.outputs.supported
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm --settle
ls -l /dev/kvm
- name: Disable man-db to speed up package install
if: steps.check_platform.outputs.supported
run: |
echo "set man-db/auto-update false" | sudo debconf-communicate
sudo dpkg-reconfigure man-db
- name: Install test dependencies
if: steps.check_platform.outputs.supported
run: |
set -euxo pipefail
python3 -m pip install --upgrade pip
sudo apt update
sudo apt install -y --no-install-recommends git ansible-core genisoimage qemu-system-x86
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.9.0"
- name: Configure tox-lsr
if: steps.check_platform.outputs.supported
run: >-
curl -o ~/.config/linux-system-roles.json
https://raw.githubusercontent.com/linux-system-roles/linux-system-roles.github.io/master/download/linux-system-roles.json
- name: Run qemu integration tests
if: steps.check_platform.outputs.supported && startsWith(matrix.scenario.env, 'qemu')
run: >-
tox -e ${{ matrix.scenario.env }} -- --image-name ${{ matrix.scenario.image }} --make-batch
--log-level debug --skip-tags tests::infiniband,tests::nvme,tests::scsi
--lsr-report-errors-url DEFAULT --
- name: Qemu result summary
if: steps.check_platform.outputs.supported && startsWith(matrix.scenario.env, 'qemu') && always()
run: |
set -euo pipefail
# some platforms may have setup/cleanup playbooks - need to find the
# actual test playbook that starts with tests_
while read code start end test_files; do
for f in $test_files; do
test_file="$f"
f="$(basename $test_file)"
if [[ "$f" =~ ^tests_ ]]; then
break
fi
done
if [ "$code" = "0" ]; then
echo -n "PASS: "
mv "$test_file.log" "${test_file}-SUCCESS.log"
else
echo -n "FAIL: "
mv "$test_file.log" "${test_file}-FAIL.log"
fi
echo "$f"
done < batch.report
- name: Run container tox integration tests
if: steps.check_platform.outputs.supported && startsWith(matrix.scenario.env, 'container')
run: |
set -euo pipefail
# HACK: debug.py/profile.py setup is broken
export LSR_CONTAINER_PROFILE=false
export LSR_CONTAINER_PRETTY=false
rc=0
for t in tests/tests_*.yml; do
if tox -e ${{ matrix.scenario.env }} -- --image-name ${{ matrix.scenario.image }} $t > ${t}.log 2>&1; then
echo "PASS: $(basename $t)"
mv "${t}.log" "${t}-SUCCESS.log"
else
echo "FAIL: $(basename $t)"
mv "${t}.log" "${t}-FAIL.log"
rc=1
fi
done
exit $rc
- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: "logs-${{ matrix.scenario.image }}-${{ matrix.scenario.env }}"
path: |
tests/*.log
artifacts/default_provisioners.log
artifacts/*.qcow2.*.log
batch.txt
batch.report
retention-days: 30
- name: Show test log failures
if: steps.check_platform.outputs.supported && failure()
run: |
set -euo pipefail
# grab check_logs.py script
curl -s -L -o check_logs.py https://raw.githubusercontent.com/linux-system-roles/auto-maintenance/refs/heads/main/check_logs.py
chmod +x check_logs.py
declare -a cmdline=(./check_logs.py --github-action-format)
for log in tests/*-FAIL.log; do
cmdline+=(--lsr-error-log "$log")
done
"${cmdline[@]}"
- name: Set commit status as success with a description that platform is skipped
if: ${{ steps.check_platform.outputs.supported == '' }}
uses: myrotvorets/set-commit-status-action@master
with:
status: success
context: "${{ github.workflow }} / scenario (${{ matrix.scenario.image }}, ${{ matrix.scenario.env }}) (pull_request)"
description: The role does not support this platform. Skipping.
targetUrl: ""