Skip to content

Commit fe52350

Browse files
abikouopatchback[bot]
authored andcommitted
kubevirt.core collection cross testing (#731)
* Initial * update python version * update python version * checkout local version of collection * add integration job * indent * Set workflow as non blocking (cherry picked from commit c0666a5)
1 parent f22ffca commit fe52350

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Integration tests Kubevirt
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- synchronize
8+
branches:
9+
- main
10+
- stable-*
11+
12+
jobs:
13+
splitter:
14+
continue-on-error: true
15+
env:
16+
kubernetes: "./kubernetes"
17+
kubevirt: "./kubevirt"
18+
py_version: 3.9
19+
runs-on: ubuntu-latest
20+
outputs:
21+
test_targets: ${{ steps.splitter.outputs.kubevirt_targets }}
22+
steps:
23+
- name: Checkout kubernetes.core repository
24+
uses: actions/checkout@v3
25+
with:
26+
path: ${{ env.kubernetes }}
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
29+
- name: Checkout the kubevirt.core collection
30+
uses: actions/checkout@v3
31+
with:
32+
repository: kubevirt/kubevirt.core
33+
path: ${{ env.kubevirt }}
34+
35+
- name: "Set up Python ${{ env.py_version }}"
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: "${{ env.py_version }}"
39+
40+
- name: List targets from kubevirt.core collection
41+
id: splitter
42+
run: python ${{ env.kubernetes }}/tools/kubevirt_list_targets.py ${{ env.kubevirt }}
43+
shell: bash
44+
45+
integration:
46+
if: ${{ needs.splitter.outputs.test_targets != '' }}
47+
name: "integration-kubevirt-${{ matrix.test-target }}"
48+
runs-on: ubuntu-latest
49+
continue-on-error: true
50+
needs:
51+
- splitter
52+
env:
53+
kubernetes: "./kubernetes"
54+
kubevirt: "./kubevirt"
55+
ansible_version: milestone
56+
python_version: 3.12
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
test-target: ${{ fromJson(needs.splitter.outputs.test_targets) }}
61+
steps:
62+
- name: Checkout kubernetes.core repository
63+
uses: actions/checkout@v4
64+
with:
65+
path: ${{ env.kubernetes }}
66+
ref: ${{ github.event.pull_request.head.sha }}
67+
68+
- name: Checkout kubevirt.core repository
69+
uses: actions/checkout@v4
70+
with:
71+
repository: kubevirt/kubevirt.core
72+
path: ${{ env.kubevirt }}
73+
ref: main
74+
75+
# Install ansible
76+
- name: Install ansible-core (${{ env.ansible_version }})
77+
run: >-
78+
python3 -m pip install
79+
https://github.com/ansible/ansible/archive/${{ env.ansible_version }}.tar.gz
80+
--disable-pip-version-check
81+
shell: bash
82+
83+
- name: Build and install kubevirt.core collection
84+
id: install-kubevirt
85+
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
86+
with:
87+
install_python_dependencies: true
88+
source_path: ${{ env.kubevirt }}
89+
90+
- name: Build and install kubernetes.core collection
91+
id: install-kubernetes
92+
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
93+
with:
94+
install_python_dependencies: true
95+
source_path: ${{ env.kubernetes }}
96+
97+
- name: Install kind / kubectl
98+
uses: helm/[email protected]
99+
with:
100+
version: v0.22.0
101+
install_only: true
102+
103+
- name: Deploy kubevirt
104+
run: >-
105+
${{ env.kubevirt }}/hack/e2e-setup.sh \
106+
-v \
107+
--configure-inotify-limits \
108+
--configure-secondary-network \
109+
--deploy-kubevirt \
110+
--deploy-kubevirt-cdi \
111+
--deploy-kubevirt-common-instancetypes \
112+
--deploy-cnao \
113+
--create-cluster \
114+
--create-nad
115+
env:
116+
KIND: kind
117+
KUBECTL: kubectl
118+
119+
- name: Run integration tests
120+
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
121+
with:
122+
collection_path: ${{ steps.install-kubevirt.outputs.collection_path }}
123+
python_version: ${{ env.python_version }}
124+
ansible_version: ${{ env.ansible_version }}
125+
ansible_test_targets: ${{ matrix.test-target }}
126+
env:
127+
ANSIBLE_COLLECTIONS_PATHS: /home/runner/collections

tools/kubevirt_list_targets.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
from pathlib import PosixPath
4+
5+
6+
def main():
7+
8+
src = sys.argv[1]
9+
path = PosixPath(src) / PosixPath("tests/integration/targets/")
10+
11+
def _is_disable(path):
12+
flags = ("unsupported", "disabled", "unstable", "hidden")
13+
aliases_path = path / PosixPath("aliases")
14+
return (aliases_path.exists() and any((d.startswith(flags) for d in aliases_path.read_text().split("\n"))))
15+
16+
targets = [i.stem for i in path.glob("*") if i.is_dir() and not _is_disable(i)]
17+
with open(os.environ.get("GITHUB_OUTPUT"), "a", encoding="utf-8") as fw:
18+
fw.write(f"kubevirt_targets={targets}\n")
19+
20+
21+
if __name__ == "__main__":
22+
main()

0 commit comments

Comments
 (0)