| 1 |
name: CI |
| 2 |
on: |
| 3 |
|
| 4 |
push: |
| 5 |
pull_request: |
| 6 |
schedule: |
| 7 |
- cron: '0 2 * * 1' |
| 8 |
|
| 9 |
jobs: |
| 10 |
build: |
| 11 |
name: Build collection |
| 12 |
runs-on: ubuntu-latest |
| 13 |
strategy: |
| 14 |
fail-fast: false |
| 15 |
matrix: |
| 16 |
ansible-version: [stable-2.16] |
| 17 |
steps: |
| 18 |
- name: Check out code |
| 19 |
uses: actions/checkout@v4 |
| 20 |
|
| 21 |
- name: Set up Python 3.11 |
| 22 |
uses: actions/setup-python@v5 |
| 23 |
with: |
| 24 |
python-version: '3.11' |
| 25 |
|
| 26 |
- name: Install ansible (${{ matrix.ansible-version }}) |
| 27 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check |
| 28 |
|
| 29 |
- name: Build a collection tarball |
| 30 |
run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" |
| 31 |
|
| 32 |
- name: Store migrated collection artifacts |
| 33 |
uses: actions/upload-artifact@v4 |
| 34 |
with: |
| 35 |
name: collection |
| 36 |
path: .cache/collection-tarballs |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
unit: |
| 45 |
name: Unit Tests |
| 46 |
needs: [build] |
| 47 |
runs-on: ubuntu-latest |
| 48 |
strategy: |
| 49 |
fail-fast: false |
| 50 |
matrix: |
| 51 |
python-version: ['3.10', '3.11', '3.12', '3.13'] |
| 52 |
ansible-version: [stable-2.16, stable-2.17, stable-2.18, devel] |
| 53 |
exclude: |
| 54 |
- ansible-version: stable-2.16 |
| 55 |
python-version: '3.13' |
| 56 |
- ansible-version: stable-2.17 |
| 57 |
python-version: '3.13' |
| 58 |
- ansible-version: devel |
| 59 |
python-version: '3.10' |
| 60 |
- ansible-version: devel |
| 61 |
python-version: '3.11' |
| 62 |
- ansible-version: stable-2.18 |
| 63 |
python-version: '3.10' |
| 64 |
|
| 65 |
steps: |
| 66 |
- name: Set up Python ${{ matrix.python-version }} |
| 67 |
uses: actions/setup-python@v5 |
| 68 |
with: |
| 69 |
python-version: ${{ matrix.python-version }} |
| 70 |
|
| 71 |
- name: Install ansible (${{ matrix.ansible-version }}) version |
| 72 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check |
| 73 |
|
| 74 |
- name: Download migrated collection artifacts |
| 75 |
uses: actions/download-artifact@v4 |
| 76 |
with: |
| 77 |
name: collection |
| 78 |
path: .cache/collection-tarballs |
| 79 |
|
| 80 |
- name: Setup Unit test Pre-requisites |
| 81 |
run: | |
| 82 |
ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz |
| 83 |
git clone https://github.com/ansible/ansible.git -b ${{ matrix.ansible-version }} |
| 84 |
if [ "${{ matrix.ansible-version }}" == "stable-2.16" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi |
| 85 |
cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/ |
| 86 |
if [ "${{ matrix.ansible-version }}" == "devel" ]; then |
| 87 |
echo "devel branch detected → injecting legacy utils.py" |
| 88 |
wget https://raw.githubusercontent.com/ansible/ansible/stable-2.17/test/units/modules/utils.py -O \ |
| 89 |
/home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py |
| 90 |
else |
| 91 |
cp -rf ansible/test/units/modules/utils.py \ |
| 92 |
/home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/ |
| 93 |
fi |
| 94 |
sed -i 's/units/ansible_collections.infoblox.nios_modules.tests.unit/' /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py |
| 95 |
if [ -f /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt ]; then pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt; fi |
| 96 |
- name: Run Unit tests using ansible-test |
| 97 |
run: ansible-test units -v --color --python ${{ matrix.python-version }} --coverage |
| 98 |
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ |
| 99 |
|
| 100 |
- name: Generate coverage report |
| 101 |
run: | |
| 102 |
if [ "${{ matrix.ansible-version }}" == "stable-2.16" ] || [ "${{ matrix.ansible-version }}" == "stable-2.17" ]; then |
| 103 |
pip install coverage==7.3.2; |
| 104 |
fi |
| 105 |
if [ "${{ matrix.ansible-version }}" == "devel" ]; then |
| 106 |
pip install "coverage==7.10.7" |
| 107 |
fi |
| 108 |
ansible-test coverage xml -v --group-by command --group-by version |
| 109 |
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
integration: |
| 118 |
name: Integration tests |
| 119 |
needs: [build] |
| 120 |
runs-on: ubuntu-latest |
| 121 |
strategy: |
| 122 |
fail-fast: false |
| 123 |
matrix: |
| 124 |
python-version: ['3.10', '3.11', '3.12', '3.13'] |
| 125 |
ansible-version: [stable-2.16, stable-2.17, stable-2.18, devel] |
| 126 |
exclude: |
| 127 |
- ansible-version: stable-2.16 |
| 128 |
python-version: '3.13' |
| 129 |
- ansible-version: stable-2.17 |
| 130 |
python-version: '3.13' |
| 131 |
- ansible-version: devel |
| 132 |
python-version: '3.10' |
| 133 |
- ansible-version: stable-2.18 |
| 134 |
python-version: '3.10' |
| 135 |
|
| 136 |
steps: |
| 137 |
- name: Set up Python ${{ matrix.python-version }} |
| 138 |
uses: actions/setup-python@v5 |
| 139 |
with: |
| 140 |
python-version: ${{ matrix.python-version }} |
| 141 |
|
| 142 |
- name: Check out code |
| 143 |
uses: actions/checkout@v4 |
| 144 |
|
| 145 |
- name: Install ansible-core |
| 146 |
run: | |
| 147 |
case "${{ matrix.ansible-version }}" in |
| 148 |
stable-2.16) pip install ansible-core==2.16.* ;; |
| 149 |
stable-2.17) pip install ansible-core==2.17.* ;; |
| 150 |
stable-2.18) pip install ansible-core==2.18.* ;; |
| 151 |
devel) pip install ansible-core --pre ;; |
| 152 |
esac |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
- name: Download migrated collection artifacts |
| 158 |
uses: actions/download-artifact@v4 |
| 159 |
with: |
| 160 |
name: collection |
| 161 |
path: .cache/collection-tarball |
| 162 |
|
| 163 |
- name: Install the collection tarball |
| 164 |
run: ansible-galaxy collection install .cache/collection-tarball/*.tar.gz |
| 165 |
|
| 166 |
- name: Setup Integration test Pre-requisites |
| 167 |
run: | |
| 168 |
sudo apt-get update |
| 169 |
sudo apt install -y python3-gi libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 gobject-introspection |
| 170 |
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig" |
| 171 |
pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/requirements.txt |
| 172 |
|
| 173 |
|
| 174 |
- name: Run integration test |
| 175 |
run: | |
| 176 |
echo $ANSIBLE_NIOSSIM_CONTAINER |
| 177 |
ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage |
| 178 |
env: |
| 179 |
ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:7.0.0 |
| 180 |
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ |
| 181 |
|
| 182 |
|
| 183 |
- name: Generate coverage report |
| 184 |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version |
| 185 |
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ |
| 186 |
|
| 187 |
- uses: codecov/codecov-action@v4 |
| 188 |
with: |
| 189 |
fail_ci_if_error: false |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
sanity: |
| 198 |
name: Sanity Tests |
| 199 |
runs-on: ubuntu-latest |
| 200 |
needs: [build] |
| 201 |
strategy: |
| 202 |
fail-fast: false |
| 203 |
matrix: |
| 204 |
ansible-version: [stable-2.16, stable-2.17, stable-2.18, devel] |
| 205 |
|
| 206 |
steps: |
| 207 |
- name: Set up Python 3.11 |
| 208 |
uses: actions/setup-python@v5 |
| 209 |
with: |
| 210 |
|
| 211 |
|
| 212 |
python-version: ${{ matrix.ansible-version == 'devel' && '3.12' || '3.11' }} |
| 213 |
|
| 214 |
- name: Install ansible (${{ matrix.ansible-version }}) version |
| 215 |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check |
| 216 |
|
| 217 |
- name: Download migrated collection artifacts |
| 218 |
uses: actions/download-artifact@v4 |
| 219 |
with: |
| 220 |
name: collection |
| 221 |
path: .cache/collection-tarballs |
| 222 |
|
| 223 |
- name: Setup Sanity test Pre-requisites |
| 224 |
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
- name: Run sanity tests |
| 230 |
run: ansible-test sanity --docker -v --color |
| 231 |
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules |