[ADD]Integration and Unit test cases for extensible attribute. #745
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.15] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- 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.9', '3.10', '3.11', '3.12'] | |
ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel] | |
exclude: | |
- ansible-version: devel | |
python-version: '3.11' | |
- ansible-version: devel | |
python-version: '3.10' | |
- ansible-version: devel | |
python-version: '3.9' | |
- ansible-version: stable-2.17 | |
python-version: '3.9' | |
- ansible-version: stable-2.16 | |
python-version: '3.9' | |
- ansible-version: stable-2.15 | |
python-version: '3.12' | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
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" ] && [ "${{ matrix.ansible-version }}" != "stable-2.17" ]; 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 }}" == "devel" ]; then | |
pip install coverage==7.6.1; | |
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.9', '3.10', '3.11', '3.12'] | |
ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel] | |
exclude: | |
- ansible-version: devel | |
python-version: '3.11' | |
- ansible-version: devel | |
python-version: '3.10' | |
- ansible-version: devel | |
python-version: '3.9' | |
- ansible-version: stable-2.17 | |
python-version: '3.9' | |
- ansible-version: stable-2.16 | |
python-version: '3.9' | |
- ansible-version: stable-2.15 | |
python-version: '3.12' | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
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:4.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.15, stable-2.16, stable-2.17, devel] | |
steps: | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v2 | |
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.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@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 |