|
| 1 | +--- |
| 2 | +name: QEMU/KVM Integration tests |
| 3 | +on: # yamllint disable-line rule:truthy |
| 4 | + pull_request: |
| 5 | + merge_group: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + types: |
| 9 | + - checks_requested |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + # This is required for the ability to create/update the Pull request status |
| 18 | + statuses: write |
| 19 | +jobs: |
| 20 | + qemu_kvm: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + scenario: |
| 27 | + - { image: "centos-9", env: "qemu-ansible-core-2.16" } |
| 28 | + - { image: "centos-10", env: "qemu-ansible-core-2.17" } |
| 29 | + # ansible/libdnf5 bug: https://issues.redhat.com/browse/RHELMISC-10110 |
| 30 | + # - { image: "fedora-41", env: "qemu-ansible-core-2.17" } |
| 31 | + - { image: "fedora-42", env: "qemu-ansible-core-2.17" } |
| 32 | + steps: |
| 33 | + - name: Checkout repo |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Check if platform is supported |
| 37 | + id: check_platform |
| 38 | + run: | |
| 39 | + set -euxo pipefail |
| 40 | + image="${{ matrix.scenario.image }}" |
| 41 | +
|
| 42 | + # convert image to tag formats |
| 43 | + platform= |
| 44 | + platform_version= |
| 45 | + case "$image" in |
| 46 | + centos-*) platform=el; platform_version=el"${image#centos-}" ;; |
| 47 | + fedora-*) platform=fedora; platform_version="${image/-/}" ;; |
| 48 | + esac |
| 49 | + supported= |
| 50 | + if yq -e '.galaxy_info.galaxy_tags[] | select(. == "'${platform_version}'" or . == "'${platform}'")' meta/main.yml; then |
| 51 | + supported=true |
| 52 | + fi |
| 53 | +
|
| 54 | + echo "supported=$supported" >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + - name: Set up /dev/kvm |
| 57 | + if: steps.check_platform.outputs.supported |
| 58 | + run: | |
| 59 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm.rules |
| 60 | + sudo udevadm control --reload-rules |
| 61 | + sudo udevadm trigger --name-match=kvm --settle |
| 62 | + ls -l /dev/kvm |
| 63 | +
|
| 64 | + - name: Disable man-db to speed up package install |
| 65 | + if: steps.check_platform.outputs.supported |
| 66 | + run: | |
| 67 | + echo "set man-db/auto-update false" | sudo debconf-communicate |
| 68 | + sudo dpkg-reconfigure man-db |
| 69 | +
|
| 70 | + - name: Install test dependencies |
| 71 | + if: steps.check_platform.outputs.supported |
| 72 | + run: | |
| 73 | + set -euxo pipefail |
| 74 | + python3 -m pip install --upgrade pip |
| 75 | + sudo apt update |
| 76 | + sudo apt install -y --no-install-recommends git ansible-core genisoimage qemu-system-x86 |
| 77 | + pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.5.1" |
| 78 | +
|
| 79 | + - name: Configure tox-lsr |
| 80 | + if: steps.check_platform.outputs.supported |
| 81 | + run: >- |
| 82 | + curl -o ~/.config/linux-system-roles.json |
| 83 | + https://raw.githubusercontent.com/linux-system-roles/linux-system-roles.github.io/master/download/linux-system-roles.json |
| 84 | +
|
| 85 | + - name: Run qemu/kvm tox integration tests |
| 86 | + if: steps.check_platform.outputs.supported |
| 87 | + run: >- |
| 88 | + tox -e ${{ matrix.scenario.env }} -- --image-name ${{ matrix.scenario.image }} --make-batch |
| 89 | + --log-level=debug --skip-tags tests::infiniband -- |
| 90 | +
|
| 91 | + - name: Test result summary |
| 92 | + if: steps.check_platform.outputs.supported && always() |
| 93 | + run: | |
| 94 | + set -euo pipefail |
| 95 | + # some platforms may have setup/cleanup playbooks - need to find the |
| 96 | + # actual test playbook that starts with tests_ |
| 97 | + while read code start end test_files; do |
| 98 | + for f in $test_files; do |
| 99 | + f="$(basename $f)" |
| 100 | + if [[ "$f" =~ ^tests_ ]]; then |
| 101 | + break |
| 102 | + fi |
| 103 | + done |
| 104 | + if [ "$code" = "0" ]; then |
| 105 | + echo -n "PASS: " |
| 106 | + else |
| 107 | + echo -n "FAIL: " |
| 108 | + fi |
| 109 | + echo "$f" |
| 110 | + done < batch.report |
| 111 | +
|
| 112 | + - name: Show test logs on failure |
| 113 | + if: steps.check_platform.outputs.supported && failure() |
| 114 | + run: | |
| 115 | + set -euo pipefail |
| 116 | + for f in tests/*.log; do |
| 117 | + echo "::group::$(basename $f)" |
| 118 | + cat "$f" |
| 119 | + echo "::endgroup::" |
| 120 | + done |
| 121 | +
|
| 122 | + - name: Set commit status as success with a description that platform is skipped |
| 123 | + if: ${{ steps.check_platform.outputs.supported == '' }} |
| 124 | + uses: myrotvorets/set-commit-status-action@master |
| 125 | + with: |
| 126 | + status: success |
| 127 | + context: "${{ github.workflow }} / qemu_kvm (${{ matrix.scenario.image }}, ${{ matrix.scenario.env }}) (pull_request)" |
| 128 | + description: The role does not support this platform. Skipping. |
| 129 | + targetUrl: "" |
0 commit comments