From 0a5dd6c9552835a3667e0864813e979463f42cd1 Mon Sep 17 00:00:00 2001 From: abikouo Date: Wed, 29 May 2024 14:05:54 +0200 Subject: [PATCH 1/7] Initial --- .../workflows/integration-tests-kubevirt.yaml | 140 ++++++++++++++++++ tools/kubevirt_list_targets.py | 22 +++ 2 files changed, 162 insertions(+) create mode 100644 .github/workflows/integration-tests-kubevirt.yaml create mode 100644 tools/kubevirt_list_targets.py diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml new file mode 100644 index 0000000000..df678f3c01 --- /dev/null +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -0,0 +1,140 @@ +name: Integration tests Kubevirt +on: + pull_request: + types: + - opened + - reopened + - synchronize + branches: + - main + - stable-* + +jobs: + splitter: + env: + source_dir: "./source" + py_version: 3.10 + runs-on: ubuntu-latest + outputs: + test_targets: ${{ steps.splitter.outputs.kubevirt_targets }} + steps: + - name: Checkout the kubevirt.core collection + uses: actions/checkout@v3 + with: + repository: kubevirt/kubevirt.core + path: ${{ env.source_dir }} + + - name: Set up Python ${{ env.py_version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ env.py_version }} + + - name: List targets from kubevirt.core collection + id: splitter + run: python tools/kubevirt_list_targets.py ${{ env.source_dir }} + shell: bash + + integration: + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: + - splitter + if: ${{ needs.splitter.outputs.test_targets != '' }} + env: + source: "./source" + cloud_common: "./cloudcommon" + ansible_posix: "./ansible_posix" + strategy: + fail-fast: false + matrix: + ansible-version: + - milestone + python-version: + - "3.12" + enable-turbo-mode: + - true + - false + workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }} + name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}" + steps: + - name: Read target + id: read-targets + run: | + import json, os + with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh: + fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n') + shell: python + env: + ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }} + WORKFLOW_ID: ${{ matrix.workflow-id }} + + - name: Display ansible test targets + run: | + echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}" + + - name: Checkout kubernetes.core repository + uses: actions/checkout@v3 + with: + path: ${{ env.source }} + ref: ${{ github.event.pull_request.head.sha }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + # install ansible + - name: Install ansible-core (${{ matrix.ansible-version }}) + run: >- + python3 -m pip install + https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz + --disable-pip-version-check + shell: bash + + - name: Build and install collection + id: install-src + uses: ansible-network/github_actions/.github/actions/build_install_collection@main + with: + install_python_dependencies: true + source_path: ${{ env.source }} + + - name: checkout ansible-collections/cloud.common + uses: ansible-network/github_actions/.github/actions/checkout_dependency@main + with: + repository: ansible-collections/cloud.common + path: ${{ env.cloud_common }} + ref: main + + - name: checkout ansible-collections/ansible.posix + uses: ansible-network/github_actions/.github/actions/checkout_dependency@main + with: + repository: ansible-collections/ansible.posix + path: ${{ env.ansible_posix }} + ref: main + + - name: install cloud.common collection + uses: ansible-network/github_actions/.github/actions/build_install_collection@main + with: + install_python_dependencies: true + source_path: ${{ env.cloud_common }} + + - name: install ansible.posix collection + uses: ansible-network/github_actions/.github/actions/build_install_collection@main + with: + install_python_dependencies: true + source_path: ${{ env.ansible_posix }} + + - name: create kubernetes cluster + uses: helm/kind-action@v1.8.0 + with: + node_image: "kindest/node:v1.29.2" + + - name: Run integration tests + uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main + with: + collection_path: ${{ steps.install-src.outputs.collection_path }} + python_version: ${{ matrix.python-version }} + ansible_version: ${{ matrix.ansible-version }} + ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }} + ansible_test_environment: | + ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }} diff --git a/tools/kubevirt_list_targets.py b/tools/kubevirt_list_targets.py new file mode 100644 index 0000000000..0692cc3488 --- /dev/null +++ b/tools/kubevirt_list_targets.py @@ -0,0 +1,22 @@ +import os +import sys +from pathlib import PosixPath + + +def main(): + + src = sys.argv[1] + path = PosixPath(src) / PosixPath("tests/integration/targets/") + + def _is_disable(path): + flags = ("unsupported", "disabled", "unstable", "hidden") + aliases_path = path / PosixPath("aliases") + return (aliases_path.exists() and any((d.startswith(flags) for d in aliases_path.read_text().split("\n")))) + + targets = [i.stem for i in path.glob("*") if i.is_dir() and not _is_disable(i)] + with open(os.environ.get("GITHUB_OUTPUT"), "a", encoding="utf-8") as fw: + fw.write(f"kubevirt_targets={targets}\n") + + +if __name__ == "__main__": + main() From 1aa0114758e0475b79055730922968685d696195 Mon Sep 17 00:00:00 2001 From: abikouo Date: Wed, 29 May 2024 14:09:50 +0200 Subject: [PATCH 2/7] update python version --- .github/workflows/integration-tests-kubevirt.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml index df678f3c01..cb8a081e21 100644 --- a/.github/workflows/integration-tests-kubevirt.yaml +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -24,10 +24,10 @@ jobs: repository: kubevirt/kubevirt.core path: ${{ env.source_dir }} - - name: Set up Python ${{ env.py_version }} + - name: "Set up Python ${{ env.py_version }}" uses: actions/setup-python@v4 with: - python-version: ${{ env.py_version }} + python-version: "${{ env.py_version }}" - name: List targets from kubevirt.core collection id: splitter From 03bb394efd0126ea5853e27343682ed406f26210 Mon Sep 17 00:00:00 2001 From: abikouo Date: Wed, 29 May 2024 14:10:37 +0200 Subject: [PATCH 3/7] update python version --- .github/workflows/integration-tests-kubevirt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml index cb8a081e21..806ad99bf9 100644 --- a/.github/workflows/integration-tests-kubevirt.yaml +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -13,7 +13,7 @@ jobs: splitter: env: source_dir: "./source" - py_version: 3.10 + py_version: 3.9 runs-on: ubuntu-latest outputs: test_targets: ${{ steps.splitter.outputs.kubevirt_targets }} From b0041c876d68a71579a63a29641ee566a8c5813f Mon Sep 17 00:00:00 2001 From: abikouo Date: Wed, 29 May 2024 14:14:50 +0200 Subject: [PATCH 4/7] checkout local version of collection --- .github/workflows/integration-tests-kubevirt.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml index 806ad99bf9..acd59d5101 100644 --- a/.github/workflows/integration-tests-kubevirt.yaml +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -12,18 +12,25 @@ on: jobs: splitter: env: - source_dir: "./source" + kubernetes: "./kubernetes" + kubevirt: "./kubevirt" py_version: 3.9 runs-on: ubuntu-latest outputs: test_targets: ${{ steps.splitter.outputs.kubevirt_targets }} steps: + - name: Checkout kubernetes.core repository + uses: actions/checkout@v3 + with: + path: ${{ env.kubernetes }} + ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout the kubevirt.core collection uses: actions/checkout@v3 with: repository: kubevirt/kubevirt.core - path: ${{ env.source_dir }} - + path: ${{ env.kubevirt }} + - name: "Set up Python ${{ env.py_version }}" uses: actions/setup-python@v4 with: @@ -31,7 +38,7 @@ jobs: - name: List targets from kubevirt.core collection id: splitter - run: python tools/kubevirt_list_targets.py ${{ env.source_dir }} + run: python ${{ env.kubernetes }}/tools/kubevirt_list_targets.py ${{ env.kubevirt }} shell: bash integration: From 3f0d10b726d8dc76dfd1561d02393b99ad0d3065 Mon Sep 17 00:00:00 2001 From: abikouo Date: Wed, 29 May 2024 14:40:06 +0200 Subject: [PATCH 5/7] add integration job --- .../workflows/integration-tests-kubevirt.yaml | 118 +++++++----------- 1 file changed, 48 insertions(+), 70 deletions(-) diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml index acd59d5101..368633f8ab 100644 --- a/.github/workflows/integration-tests-kubevirt.yaml +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -42,106 +42,84 @@ jobs: shell: bash integration: + if: ${{ needs.splitter.outputs.test_targets != '' }} + name: "integration-kubevirt-${{ matrix.test-target }}" runs-on: ubuntu-latest - timeout-minutes: 60 needs: - splitter - if: ${{ needs.splitter.outputs.test_targets != '' }} env: - source: "./source" - cloud_common: "./cloudcommon" - ansible_posix: "./ansible_posix" + kubernetes: "./kubernetes" + kubevirt: "./kubevirt" + ansible_version: milestone + python_version: 3.12 strategy: fail-fast: false matrix: - ansible-version: - - milestone - python-version: - - "3.12" - enable-turbo-mode: - - true - - false - workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }} - name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}" + test-target: ${{ fromJson(needs.splitter.outputs.test_targets) }} steps: - - name: Read target - id: read-targets - run: | - import json, os - with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh: - fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n') - shell: python - env: - ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }} - WORKFLOW_ID: ${{ matrix.workflow-id }} - - - name: Display ansible test targets - run: | - echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}" - - name: Checkout kubernetes.core repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: ${{ env.source }} + path: ${{ env.kubernetes }} ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Checkout kubevirt.core repository + uses: actions/checkout@v4 with: - python-version: ${{ matrix.python-version }} + repository: kubevirt/kubevirt.core + path: ${{ env.kubevirt }} + ref: main - # install ansible - - name: Install ansible-core (${{ matrix.ansible-version }}) + # Install ansible + - name: Install ansible-core (${{ env.ansible_version }}) run: >- python3 -m pip install - https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz + https://github.com/ansible/ansible/archive/${{ env.ansible_version }}.tar.gz --disable-pip-version-check shell: bash - - name: Build and install collection - id: install-src + - name: Build and install kubevirt.core collection + id: install-kubevirt uses: ansible-network/github_actions/.github/actions/build_install_collection@main with: install_python_dependencies: true - source_path: ${{ env.source }} + source_path: ${{ env.kubevirt }} - - name: checkout ansible-collections/cloud.common - uses: ansible-network/github_actions/.github/actions/checkout_dependency@main - with: - repository: ansible-collections/cloud.common - path: ${{ env.cloud_common }} - ref: main - - - name: checkout ansible-collections/ansible.posix - uses: ansible-network/github_actions/.github/actions/checkout_dependency@main - with: - repository: ansible-collections/ansible.posix - path: ${{ env.ansible_posix }} - ref: main - - - name: install cloud.common collection + - name: Build and install kubernetes.core collection + id: install-kubernetes uses: ansible-network/github_actions/.github/actions/build_install_collection@main with: install_python_dependencies: true - source_path: ${{ env.cloud_common }} + source_path: ${{ env.kubernetes }} - - name: install ansible.posix collection - uses: ansible-network/github_actions/.github/actions/build_install_collection@main + - name: Install kind / kubectl + uses: helm/kind-action@v1.9.0 with: - install_python_dependencies: true - source_path: ${{ env.ansible_posix }} + version: v0.22.0 + install_only: true - - name: create kubernetes cluster - uses: helm/kind-action@v1.8.0 - with: - node_image: "kindest/node:v1.29.2" + - name: Deploy kubevirt + run: >- + ${{ env.kubevirt }}/hack/e2e-setup.sh \ + -v \ + --configure-inotify-limits \ + --configure-secondary-network \ + --deploy-kubevirt \ + --deploy-kubevirt-cdi \ + --deploy-kubevirt-common-instancetypes \ + --deploy-cnao \ + --create-cluster \ + --create-nad + env: + KIND: kind + KUBECTL: kubectl - name: Run integration tests uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main with: - collection_path: ${{ steps.install-src.outputs.collection_path }} - python_version: ${{ matrix.python-version }} - ansible_version: ${{ matrix.ansible-version }} - ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }} - ansible_test_environment: | - ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }} + collection_path: ${{ steps.install-kubevirt.outputs.collection_path }} + python_version: ${{ env.python_version }} + ansible_version: ${{ env.ansible_version }} + ansible_test_targets: ${{ matrix.test-target }} + env: + ANSIBLE_COLLECTIONS_PATHS: /home/runner/collections From acd23d41f806393ecb22e923b0ef16f9252eb9e4 Mon Sep 17 00:00:00 2001 From: abikouo Date: Wed, 29 May 2024 15:41:54 +0200 Subject: [PATCH 6/7] indent --- .github/workflows/integration-tests-kubevirt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml index 368633f8ab..72a2ea5d03 100644 --- a/.github/workflows/integration-tests-kubevirt.yaml +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -100,7 +100,7 @@ jobs: - name: Deploy kubevirt run: >- - ${{ env.kubevirt }}/hack/e2e-setup.sh \ + ${{ env.kubevirt }}/hack/e2e-setup.sh \ -v \ --configure-inotify-limits \ --configure-secondary-network \ From 9ef7125b61eeddb04a0c6e6266a901a70d598c30 Mon Sep 17 00:00:00 2001 From: abikouo Date: Thu, 30 May 2024 07:18:39 +0200 Subject: [PATCH 7/7] Set workflow as non blocking --- .github/workflows/integration-tests-kubevirt.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-tests-kubevirt.yaml b/.github/workflows/integration-tests-kubevirt.yaml index 72a2ea5d03..aa6a1d5481 100644 --- a/.github/workflows/integration-tests-kubevirt.yaml +++ b/.github/workflows/integration-tests-kubevirt.yaml @@ -11,6 +11,7 @@ on: jobs: splitter: + continue-on-error: true env: kubernetes: "./kubernetes" kubevirt: "./kubevirt" @@ -45,6 +46,7 @@ jobs: if: ${{ needs.splitter.outputs.test_targets != '' }} name: "integration-kubevirt-${{ matrix.test-target }}" runs-on: ubuntu-latest + continue-on-error: true needs: - splitter env: