community.mysql/.github/workflows/ansible-test-plugins.yml
2022-12-09 15:33:33 +01:00

167 lines
5 KiB
YAML

name: Plugins CI
on:
push:
paths:
- 'plugins/**'
- 'tests/**'
- '.github/workflows/ansible-test-plugins.yml'
pull_request:
paths:
- 'plugins/**'
- 'tests/**'
- '.github/workflows/ansible-test-plugins.yml'
schedule:
- cron: '0 6 * * *'
env:
mysql_version_file: "tests/integration/targets/setup_mysql/defaults/main.yml"
connector_version_file: "tests/integration/targets/setup_mysql/vars/main.yml"
jobs:
sanity:
name: "Sanity (Ansible: ${{ matrix.ansible }})"
runs-on: ubuntu-20.04
strategy:
matrix:
ansible:
- stable-2.12
- stable-2.13
- stable-2.14
- devel
steps:
- name: Perform sanity testing
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
testing-type: sanity
pull-request-change-detection: true
integration:
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, MySQL: ${{ matrix.db_engine_version }}, Connector: ${{ matrix.connector }})"
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
db_engine_version:
- mysql_5.7.31
- mysql_8.0.22
- mariadb_10.3.34
# When adding later versions below,
# also change the "Set MariaDB URL sub dir" task
- mariadb_10.8.3
ansible:
- stable-2.12
- stable-2.13
- stable-2.14
- devel
python:
- 3.6
- 3.8
- 3.9
connector:
- pymysql==0.7.10
- pymysql==0.9.3
- mysqlclient==2.0.1
exclude:
- db_engine_version: mysql_8.0.22
connector: pymysql==0.7.10
- db_engine_version: mariadb_10.8.3
connector: pymysql==0.7.10
- python: 3.6
ansible: stable-2.12
- python: 3.6
ansible: stable-2.13
- python: 3.6
ansible: stable-2.14
- python: 3.6
ansible: devel
- python: 3.8
ansible: stable-2.13
- python: 3.8
ansible: stable-2.14
- python: 3.8
ansible: devel
- python: 3.9
ansible: stable-2.12
# runs all of the steps inside the specified container rather than on the VM host.
# Because of this the network configuration changes from host based network to a container network.
services:
mariadb105:
container_name: mariadb105
image: mariadb:10.5
env:
MARIADB_ROOT_PASSWORD: msandbox
ports:
- 3307:3306
# needed because the mariadb container does not provide a healthcheck
options: --health-cmd mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/community/mysql
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Set Connector version (${{ matrix.connector }})
run: "sed -i 's/^python_packages:.*/python_packages: [${{ matrix.connector }}]/' ${{ env.connector_version_file }}"
# TODO, add a loop that wait on mariadb container healthcheck here
- name: Run integration tests
run: ansible-test integration --venv -v --color --retry-on-error --continue-on-error --python ${{ matrix.python }} --diff --coverage
working-directory: ./ansible_collections/community/mysql
- name: Generate coverage report.
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: ./ansible_collections/community/mysql
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
units:
runs-on: ubuntu-20.04
name: Units (Ⓐ${{ matrix.ansible }})
strategy:
# As soon as the first unit test fails,
# cancel the others to free up the CI queue
fail-fast: true
matrix:
ansible:
- stable-2.12
- stable-2.13
- stable-2.14
- devel
python:
- 3.8
- 3.9
exclude:
- python: 3.8
ansible: stable-2.13
- python: 3.8
ansible: stable-2.14
- python: 3.8
ansible: devel
- python: 3.9
ansible: stable-2.12
steps:
- name: >-
Perform unit testing against
Ansible version ${{ matrix.ansible }}
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
target-python-version: ${{ matrix.python }}
testing-type: units
pull-request-change-detection: true