community.mysql/.github/workflows/ansible-test-plugins.yml
R.Sicart 1b061131dd
Feature/mariadb integration ci (#246)
* Replace matrix.mysql by matrix.db_engine_version

* Specify db flavor

* Upgrade dbdeployer to 1.56.0

See https://github.com/datacharmer/dbdeployer/issues/120

* Fix: github workflow syntax

* Fix: mysql version file for mariadb engine

* Do not test mysql_variables modes persist and persist_only on mariadb

Those modes do not exist on mariadb. See https://mariadb.com/kb/en/set/

* Exclude integration tests for mariadb_10.5.4 with pymysql==0.7.10

* TLS on mariadb is disabled by default

* Configure mariadb supported versions in matrix

As discussed in https://github.com/ansible-collections/community.mysql/discussions/141#discussioncomment-643657

* Fix: test_mysql_db : assert that databases does not exist

"assertion": "database1 not in mysql_result.stdout"

* Fix: assertion mysql_version in result.version.full

* Fix: test_mysql_user : Check that the module made a change and that the expected plugin type is set

'mysql_native_password' in show_create_user.stdout

* Fix: test_mysql_replication : Create user for replication

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the
right syntax to use near 'BY 'replication_pass'' at line 1

https://dev.mysql.com/doc/mysql-replication-excerpt/5.7/en/replication-howto-repuser.html
https://dev.mysql.com/doc/mysql-replication-excerpt/8.0/en/replication-howto-repuser.html
https://mariadb.com/kb/en/setting-up-replication/#example-enabling-replication-for-mariadb

Create user syntax compatible with auth plugin and password on both
mysql and mariadb.

https://dev.mysql.com/doc/refman/8.0/en/create-user.html
https://mariadb.com/kb/en/create-user/

* Fix: test_mysql_replication: replica_status 'dict object' has no attribute 'Source_Host'

* Do not test mysql_replication_channel.yml on mariadb

* Do not test target 'test_mysql_role' with mariadb, too much errors to fix

* Setup mysql_version_parts depending on install type (mysql or mariadb)

* Install mariadb-client when install_type is mariadb

To use the same client tools as the database engine.

And to use a more updated mysqldump version, in order to fix this error:

ERROR 1556 (HY000) at line 776: You can't use locks with log tables

* Fix: mysql auth plugin is set on mariadb >10.2

* Fix: skip assertion on mariadb 10.2

* Do not execute test_user_plugin_auth.yml tests on mariadb, create/update useer sql syntax not compatible

* Fix: test_mysql_user : assert user1 TLS requirements

Remove test for oldd versions

* Fix: typo

* Fix: test_mysql_user : Test idempotency (expect ok) ignore mariadb 10.5

* [ci skip] Add changelog fragment

* Delete changelog fragment
2021-12-14 09:30:46 +01:00

176 lines
5.7 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: "./ansible_collections/community/mysql/tests/integration/targets/setup_mysql/defaults/main.yml"
connector_version_file: "./ansible_collections/community/mysql/tests/integration/targets/setup_mysql/vars/main.yml"
jobs:
sanity:
name: "Sanity (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }})"
runs-on: ubuntu-latest
strategy:
matrix:
ansible:
- stable-2.9
- stable-2.10
- stable-2.11
- stable-2.12
- devel
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: 3.8
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/community/mysql
integration:
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, MySQL: ${{ matrix.db_engine_version }}, Connector: ${{ matrix.connector }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
db_engine_version:
- mysql_5.7.31
- mysql_8.0.22
- mariadb_10.2.37
- mariadb_10.5.9
ansible:
- stable-2.9
- stable-2.10
- stable-2.11
- stable-2.12
#- devel
python:
- 3.6
- 3.8
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.5.9
connector: pymysql==0.7.10
- python: 3.8
ansible: stable-2.9
- python: 3.8
ansible: stable-2.10
- python: 3.8
ansible: stable-2.11
- python: 3.6
ansible: stable-2.12
- python: 3.6
ansible: devel
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: 3.8
- 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 MySQL version (${{ matrix.db_engine_version }})
run: |
export DB_VERSION=$(echo "${{ matrix.db_engine_version }}" | awk -F_ '{print $2}')
sed -i "s/^mysql_version:.*/mysql_version: $DB_VERSION/g" ${{ env.mysql_version_file }}
if: ${{ startsWith(matrix.db_engine_version, 'mysql') }}
- name: Set MariaDB version (${{ matrix.db_engine_version }})
run: |
export DB_VERSION=$(echo "${{ matrix.db_engine_version }}" | awk -F_ '{print $2}')
sed -i -e "s/^mariadb_version:.*/mariadb_version: $DB_VERSION/g" -e 's/^mariadb_install: false/mariadb_install: true/g' ${{ env.mysql_version_file }}
if: ${{ startsWith(matrix.db_engine_version, 'mariadb') }}
- name: Set Connector version (${{ matrix.connector }})
run: "sed -i 's/^python_packages:.*/python_packages: [${{ matrix.connector }}]/' ${{ env.connector_version_file }}"
- name: Run integration tests
run: ansible-test integration --docker -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-latest
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.9
- stable-2.10
- stable-2.11
- stable-2.12
- devel
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: 3.8
- name: Install ansible-base (${{matrix.ansible}})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
# Run the unit tests
- name: Run unit test
run: ansible-test units -v --color --docker --coverage
working-directory: ./ansible_collections/community/mysql
# 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: ./ansible_collections/community/mysql
# See the reports at https://codecov.io/gh/GITHUBORG/REPONAME
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false