Skip to content

CI

CI #383

Workflow file for this run

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.14]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Install ansible (${{ matrix.ansible-version }})
run: pip install 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@v1
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.8', '3.9', '3.10', '3.11']
ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel]
exclude:
- ansible-version: devel
python-version: '3.8'
- ansible-version: devel
python-version: '3.9'
- ansible-version: stable-2.16
python-version: '3.8'
- ansible-version: stable-2.16
python-version: '3.9'
- ansible-version: stable-2.15
python-version: '3.8'
- ansible-version: stable-2.14
python-version: '3.8'
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
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@v1
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 }}" != "devel" ]; 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/
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.14" ]; then
pip install coverage==6.5.0;
elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then
pip install coverage==6.5.0;
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.8', '3.9', '3.10', '3.11']
ansible-version: [stable-2.14, stable-2.15, stable-2.16, devel]
exclude:
- ansible-version: devel
python-version: '3.8'
- ansible-version: devel
python-version: '3.9'
- ansible-version: stable-2.16
python-version: '3.8'
- ansible-version: stable-2.16
python-version: '3.9'
- ansible-version: stable-2.15
python-version: '3.8'
- ansible-version: stable-2.14
python-version: '3.8'
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Check out code
uses: actions/checkout@v2
- 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@v1
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 install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0
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:3.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@v1
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.14, stable-2.15, stable-2.16, devel]
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v1
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: '3.10'
- 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@v1
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 of Docker.
# The docker container has all the pinned dependencies that are required
# and all python versions ansible supports.
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules