name: CI on: # Run CI against all pushes (direct commits) and Pull Requests push: pull_request: schedule: - cron: '0 2 * * 1' jobs: build: name: Build collection runs-on: ubuntu-latest strategy: fail-fast: false matrix: ansible-version: [stable-2.16] steps: - name: Check out code uses: actions/checkout@v4 - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install ansible (${{ matrix.ansible-version }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Build a collection tarball run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" - name: Store migrated collection artifacts uses: actions/upload-artifact@v4 with: name: collection path: .cache/collection-tarballs ### # Unit tests # # https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html unit: name: Unit Tests needs: [build] runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13'] ansible-version: [stable-2.16, stable-2.17, stable-2.18, devel] exclude: - ansible-version: stable-2.16 python-version: '3.13' - ansible-version: stable-2.17 python-version: '3.13' - ansible-version: devel python-version: '3.10' - ansible-version: devel python-version: '3.11' - ansible-version: stable-2.18 python-version: '3.10' steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install ansible (${{ matrix.ansible-version }}) version run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts uses: actions/download-artifact@v4 with: name: collection path: .cache/collection-tarballs - name: Setup Unit test Pre-requisites run: | ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz git clone https://github.com/ansible/ansible.git -b ${{ matrix.ansible-version }} 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 cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/ if [ "${{ matrix.ansible-version }}" == "devel" ]; then echo "devel branch detected → injecting legacy utils.py" wget https://raw.githubusercontent.com/ansible/ansible/stable-2.17/test/units/modules/utils.py -O \ /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py else cp -rf ansible/test/units/modules/utils.py \ /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/ fi 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 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 - name: Run Unit tests using ansible-test run: ansible-test units -v --color --python ${{ matrix.python-version }} --coverage working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ - name: Generate coverage report run: | if [ "${{ matrix.ansible-version }}" == "stable-2.16" ] || [ "${{ matrix.ansible-version }}" == "stable-2.17" ]; then pip install coverage==7.3.2; fi if [ "${{ matrix.ansible-version }}" == "devel" ]; then pip install "coverage==7.10.7" fi ansible-test coverage xml -v --group-by command --group-by version working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ ### # Integration tests # # https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html integration: name: Integration tests needs: [build] runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13'] ansible-version: [stable-2.16, stable-2.17, stable-2.18, devel] exclude: - ansible-version: stable-2.16 python-version: '3.13' - ansible-version: stable-2.17 python-version: '3.13' - ansible-version: devel python-version: '3.10' - ansible-version: stable-2.18 python-version: '3.10' steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Check out code uses: actions/checkout@v4 - name: Install ansible-core run: | case "${{ matrix.ansible-version }}" in stable-2.16) pip install ansible-core==2.16.* ;; stable-2.17) pip install ansible-core==2.17.* ;; stable-2.18) pip install ansible-core==2.18.* ;; devel) pip install ansible-core --pre ;; esac # - name: Install ansible-base (${{ matrix.ansible-version }}) # run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts uses: actions/download-artifact@v4 with: name: collection path: .cache/collection-tarball - name: Install the collection tarball run: ansible-galaxy collection install .cache/collection-tarball/*.tar.gz - name: Setup Integration test Pre-requisites run: | sudo apt-get update sudo apt install -y python3-gi libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 gobject-introspection export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig" pip install -r /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/requirements.txt # Run the integration tests - name: Run integration test run: | echo $ANSIBLE_NIOSSIM_CONTAINER ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage env: ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:7.0.0 working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ # ansible-test support producing code coverage date - name: Generate coverage report run: ansible-test coverage xml -v --requirements --group-by command --group-by version working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/ - uses: codecov/codecov-action@v4 with: fail_ci_if_error: false ### # Sanity tests (REQUIRED) # # https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html sanity: name: Sanity Tests runs-on: ubuntu-latest needs: [build] strategy: fail-fast: false matrix: ansible-version: [stable-2.16, stable-2.17, stable-2.18, devel] steps: - name: Set up Python 3.11 uses: actions/setup-python@v5 with: # it is just required to run that once as "ansible-test sanity" in the docker image # will run on all python versions it supports. python-version: ${{ matrix.ansible-version == 'devel' && '3.12' || '3.11' }} - name: Install ansible (${{ matrix.ansible-version }}) version run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts uses: actions/download-artifact@v4 with: name: collection path: .cache/collection-tarballs - name: Setup Sanity test Pre-requisites run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz # Run ansible-test sanity inside Docker. # The docker container has all the pinned dependencies that are required # and all python versions ansible support. - name: Run sanity tests run: ansible-test sanity --docker -v --color working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules