mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-05 21:54:24 -07:00
sh don't know 'echo -e', so we use bash instead. Also, we need to wait for the container to be healthy before trying to restart it. Otherwise that could corrupt it.
198 lines
6.5 KiB
YAML
198 lines
6.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 * * *'
|
|
|
|
|
|
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.40
|
|
- mysql:8.0.31
|
|
# - mariadb:10.4.24
|
|
- mariadb:10.5.18
|
|
# - mariadb:10.6.11
|
|
# - mariadb:10.7.7
|
|
# - mariadb:10.8.3
|
|
ansible:
|
|
# - stable-2.12
|
|
# - stable-2.13
|
|
- stable-2.14
|
|
# - devel
|
|
python:
|
|
# - 3.8
|
|
- 3.9
|
|
# - 3.10
|
|
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.4.24
|
|
connector: pymysql==0.7.10
|
|
- db_engine_version: mariadb:10.5.18
|
|
connector: pymysql==0.7.10
|
|
- db_engine_version: mariadb:10.8.3
|
|
connector: pymysql==0.7.10
|
|
- 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
|
|
- python: 3.9
|
|
connector: mysqlclient==2.0.1
|
|
- python: 3.10
|
|
ansible: stable-2.12
|
|
|
|
services:
|
|
db_primary:
|
|
image: ${{ matrix.db_engine_version }}
|
|
env:
|
|
MARIADB_ROOT_PASSWORD: msandbox
|
|
MYSQL_ROOT_PASSWORD: msandbox
|
|
ports:
|
|
- 3307:3306
|
|
# We write our own health-cmd because the mariadb container does not
|
|
# provide a healthcheck
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -P 3306 -pmsandbox |grep alive || exit 1"
|
|
--health-start-period 10s
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 6
|
|
|
|
db_replica1:
|
|
image: ${{ matrix.db_engine_version }}
|
|
env:
|
|
MARIADB_ROOT_PASSWORD: msandbox
|
|
MYSQL_ROOT_PASSWORD: msandbox
|
|
ports:
|
|
- 3308:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -P 3306 -pmsandbox |grep alive || exit 1"
|
|
--health-start-period 10s
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 6
|
|
|
|
db_replica2:
|
|
image: ${{ matrix.db_engine_version }}
|
|
env:
|
|
MARIADB_ROOT_PASSWORD: msandbox
|
|
MYSQL_ROOT_PASSWORD: msandbox
|
|
ports:
|
|
- 3309:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -P 3306 -pmsandbox |grep alive || exit 1"
|
|
--health-start-period 10s
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 6
|
|
|
|
steps:
|
|
|
|
# No need to check for service health. GitHub Action took care of it.
|
|
|
|
- name: Restart MySQL server with settings for replication
|
|
run: |
|
|
docker exec ${{ job.services.db_primary.id }} bash -c 'echo -e [mysqld]\\nserver-id=1\\nlog-bin=/var/lib/mysql/primary-bin > /etc/mysql/conf.d/replication.cnf'
|
|
docker exec ${{ job.services.db_replica1.id }} bash -c 'echo -e [mysqld]\\nserver-id=2\\nlog-bin=/var/lib/mysql/replica1-bin > /etc/mysql/conf.d/replication.cnf'
|
|
docker exec ${{ job.services.db_replica2.id }} bash -c 'echo -e [mysqld]\\nserver-id=3\\nlog-bin=/var/lib/mysql/replica2-bin > /etc/mysql/conf.d/replication.cnf'
|
|
docker restart ${{ job.services.db_primary.id }}
|
|
docker restart ${{ job.services.db_replica1.id }}
|
|
docker restart ${{ job.services.db_replica2.id }}
|
|
|
|
- name: Wait for the primary to be healthy
|
|
run: |
|
|
while ! /usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" ${{ job.services.db_primary.id }} && [[ "$SECONDS" -lt 120 ]]; do sleep 1; done
|
|
|
|
- name: >-
|
|
Perform integration testing against
|
|
Ansible version ${{ matrix.ansible }}
|
|
under Python ${{ matrix.python }}
|
|
uses: ansible-community/ansible-test-gh-action@release/v1
|
|
with:
|
|
ansible-core-version: ${{ matrix.ansible }}
|
|
pre-test-cmd: >-
|
|
echo Setting db_engine_version to "${{ matrix.db_engine_version }}"...;
|
|
echo -n "${{ matrix.db_engine_version }}" > tests/integration/db_engine_version;
|
|
echo Setting Connector version to "${{ matrix.connector }}"...;
|
|
echo -n "${{ matrix.connector }}" > tests/integration/connector
|
|
target-python-version: ${{ matrix.python }}
|
|
testing-type: integration
|
|
|
|
# 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
|