mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-21 13:31:45 -07:00
Embed pymysql
within the collection and use default test container
This change eliminates the need to install the connector on each controlled node, as `pymysql` version 1.1.1 is now included. As a result, we can safely assume its availability, thus simplifying the testing process. Also, I managed to remove the need for pre-built test containers. We now use the default test containers from ansible-test.
This commit is contained in:
parent
16d530348d
commit
04af62c400
49 changed files with 4392 additions and 979 deletions
141
.github/workflows/ansible-test-plugins.yml
vendored
141
.github/workflows/ansible-test-plugins.yml
vendored
|
@ -36,7 +36,7 @@ jobs:
|
|||
pull-request-change-detection: true
|
||||
|
||||
integration:
|
||||
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, DB: ${{ matrix.db_engine_name }} ${{ matrix.db_engine_version }}, connector: ${{ matrix.connector_name }} ${{ matrix.connector_version }})"
|
||||
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, DB: ${{ matrix.db_engine_name }} ${{ matrix.db_engine_version }})"
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
@ -59,28 +59,8 @@ jobs:
|
|||
- '3.8'
|
||||
- '3.9'
|
||||
- '3.10'
|
||||
connector_name:
|
||||
- pymysql
|
||||
- mysqlclient
|
||||
connector_version:
|
||||
- 0.7.11
|
||||
- 0.9.3
|
||||
- 1.0.2
|
||||
- 2.0.1
|
||||
- 2.0.3
|
||||
- 2.1.1
|
||||
include:
|
||||
- python: '3.9' # RHEL9 uses 3.9 by default
|
||||
connector_version: '0.10.1' # From RHEL package python3-PyMySQL
|
||||
connector_name: pymysql
|
||||
|
||||
- python: '3.11'
|
||||
connector_version: '1.0.2' # From RHEL package python3.11-PyMySQL
|
||||
connector_name: pymysql
|
||||
|
||||
- python: '3.12'
|
||||
connector_version: '1.1.0' # From RHEL package python3.12-PyMySQL
|
||||
connector_name: pymysql
|
||||
- '3.11'
|
||||
- '3.12'
|
||||
exclude:
|
||||
- db_engine_name: mysql
|
||||
db_engine_version: 10.4.27
|
||||
|
@ -97,48 +77,6 @@ jobs:
|
|||
- db_engine_name: mariadb
|
||||
db_engine_version: 8.0.31
|
||||
|
||||
- connector_name: pymysql
|
||||
connector_version: 2.0.1
|
||||
|
||||
- connector_name: pymysql
|
||||
connector_version: 2.0.3
|
||||
|
||||
- connector_name: pymysql
|
||||
connector_version: 2.1.1
|
||||
|
||||
- connector_name: mysqlclient
|
||||
connector_version: 0.7.11
|
||||
|
||||
- connector_name: mysqlclient
|
||||
connector_version: 0.10.1
|
||||
|
||||
- connector_name: mysqlclient
|
||||
connector_version: 0.9.3
|
||||
|
||||
- connector_name: mysqlclient
|
||||
connector_version: 1.0.2
|
||||
|
||||
- connector_name: mysqlclient
|
||||
connector_version: 1.1.0
|
||||
|
||||
- db_engine_name: mariadb
|
||||
connector_version: 0.7.11
|
||||
|
||||
- db_engine_version: 5.7.40
|
||||
python: '3.9'
|
||||
|
||||
- db_engine_version: 5.7.40
|
||||
python: '3.10'
|
||||
|
||||
- db_engine_version: 5.7.40
|
||||
ansible: stable-2.15
|
||||
|
||||
- db_engine_version: 5.7.40
|
||||
ansible: stable-2.16
|
||||
|
||||
- db_engine_version: 5.7.40
|
||||
ansible: devel
|
||||
|
||||
- db_engine_version: 8.0.31
|
||||
python: '3.8'
|
||||
|
||||
|
@ -154,39 +92,6 @@ jobs:
|
|||
- db_engine_version: 10.6.11
|
||||
python: '3.9'
|
||||
|
||||
- python: '3.8'
|
||||
connector_version: 1.0.2
|
||||
|
||||
- python: '3.8'
|
||||
connector_version: 2.0.3
|
||||
|
||||
- python: '3.8'
|
||||
connector_version: 2.1.1
|
||||
|
||||
- python: '3.9'
|
||||
connector_version: 0.7.11
|
||||
|
||||
- python: '3.9'
|
||||
connector_version: 1.0.2
|
||||
|
||||
- python: '3.9'
|
||||
connector_version: 2.0.1
|
||||
|
||||
- python: '3.9'
|
||||
connector_version: 2.1.1
|
||||
|
||||
- python: '3.10'
|
||||
connector_version: 0.7.11
|
||||
|
||||
- python: '3.10'
|
||||
connector_version: 0.9.3
|
||||
|
||||
- python: '3.10'
|
||||
connector_version: 2.0.1
|
||||
|
||||
- python: '3.10'
|
||||
connector_version: 2.0.3
|
||||
|
||||
- python: '3.8'
|
||||
ansible: stable-2.16
|
||||
|
||||
|
@ -270,37 +175,6 @@ jobs:
|
|||
${{ job.services.db_primary.id }}
|
||||
| grep healthy && [[ "$SECONDS" -lt 120 ]]; do sleep 1; done
|
||||
|
||||
- name: Compute docker_image - Set python_version_flat
|
||||
run: >
|
||||
echo "python_version_flat=$(echo ${{ matrix.python }}
|
||||
| tr -d '.')" >> $GITHUB_ENV
|
||||
|
||||
- name: Compute docker_image - Set connector_version_flat
|
||||
run: >
|
||||
echo "connector_version_flat=$(echo ${{ matrix.connector_version }}
|
||||
|tr -d .)" >> $GITHUB_ENV
|
||||
|
||||
- name: Compute docker_image - Set db_engine_version_flat
|
||||
run: >
|
||||
echo "db_engine_version_flat=$(echo ${{ matrix.db_engine_version }}
|
||||
| awk -F '.' '{print $1 $2}')" >> $GITHUB_ENV
|
||||
|
||||
- name: Compute docker_image - Set db_client
|
||||
run: >
|
||||
if [[ ${{ env.db_engine_version_flat }} == 57 ]]; then
|
||||
echo "db_client=my57" >> $GITHUB_ENV;
|
||||
else
|
||||
echo "db_client=$(echo ${{ matrix.db_engine_name }})" >> $GITHUB_ENV;
|
||||
fi
|
||||
|
||||
- name: Set docker_image
|
||||
run: |-
|
||||
echo "docker_image=ghcr.io/ansible-collections/community.mysql\
|
||||
/test-container-${{ env.db_client }}\
|
||||
-py${{ env.python_version_flat }}\
|
||||
-${{ matrix.connector_name }}${{ env.connector_version_flat }}\
|
||||
:latest" >> $GITHUB_ENV
|
||||
|
||||
- name: >-
|
||||
Perform integration testing against
|
||||
Ansible version ${{ matrix.ansible }}
|
||||
|
@ -318,14 +192,6 @@ jobs:
|
|||
echo -n "${{ matrix.db_engine_version }}"
|
||||
> tests/integration/db_engine_version;
|
||||
|
||||
echo Setting Connector name to "${{ matrix.connector_name }}"...;
|
||||
echo -n "${{ matrix.connector_name }}"
|
||||
> tests/integration/connector_name;
|
||||
|
||||
echo Setting Connector name to "${{ matrix.connector_version }}"...;
|
||||
echo -n "${{ matrix.connector_version }}"
|
||||
> tests/integration/connector_version;
|
||||
|
||||
echo Setting Python version to "${{ matrix.python }}"...;
|
||||
echo -n "${{ matrix.python }}"
|
||||
> tests/integration/python;
|
||||
|
@ -333,7 +199,6 @@ jobs:
|
|||
echo Setting Ansible version to "${{ matrix.ansible }}"...;
|
||||
echo -n "${{ matrix.ansible }}"
|
||||
> tests/integration/ansible
|
||||
docker-image: ${{ env.docker_image }}
|
||||
target-python-version: ${{ matrix.python }}
|
||||
testing-type: integration
|
||||
|
||||
|
|
242
.github/workflows/build-docker-image.yml
vendored
242
.github/workflows/build-docker-image.yml
vendored
|
@ -1,242 +0,0 @@
|
|||
---
|
||||
name: Build Docker Image for ansible-test
|
||||
|
||||
on: # yamllint disable-line rule:truthy
|
||||
workflow_call:
|
||||
inputs:
|
||||
registry:
|
||||
required: true
|
||||
type: string
|
||||
image_name:
|
||||
required: true
|
||||
type: string
|
||||
context:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- from: ubuntu2004
|
||||
db_client: mariadb
|
||||
python_minor: '8'
|
||||
connector_name: pymysql
|
||||
connector_major: '0'
|
||||
connector_minor: '9'
|
||||
connector_release: '3'
|
||||
|
||||
- from: ubuntu2004
|
||||
db_client: mariadb
|
||||
python_minor: '8'
|
||||
connector_name: mysqlclient
|
||||
connector_major: '2'
|
||||
connector_minor: '0'
|
||||
connector_release: '1'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mariadb
|
||||
python_minor: '9' # RHEL9 uses 3.9 by default
|
||||
connector_name: pymysql
|
||||
# Same ver. as RHEL package python3-PyMySQL
|
||||
connector_major: '0'
|
||||
connector_minor: '10'
|
||||
connector_release: '1'
|
||||
|
||||
- from: ubuntu2004
|
||||
db_client: mariadb
|
||||
python_minor: '9'
|
||||
connector_name: mysqlclient
|
||||
connector_major: '2'
|
||||
connector_minor: '0'
|
||||
connector_release: '3'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mariadb
|
||||
python_minor: '10'
|
||||
connector_name: pymysql
|
||||
connector_major: '1'
|
||||
connector_minor: '0'
|
||||
connector_release: '2'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mariadb
|
||||
python_minor: '10'
|
||||
connector_name: mysqlclient
|
||||
connector_major: '2'
|
||||
connector_minor: '1'
|
||||
connector_release: '1'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mariadb
|
||||
python_minor: '11' # RHEL9 uses 3.9 by default
|
||||
connector_name: pymysql
|
||||
# Same ver. as RHEL package python3.11-PyMySQL
|
||||
connector_major: '1'
|
||||
connector_minor: '0'
|
||||
connector_release: '2'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mariadb
|
||||
python_minor: '12' # RHEL9 uses 3.9 by default
|
||||
connector_name: pymysql
|
||||
# Same ver. as RHEL package python3.12-PyMySQL
|
||||
connector_major: '1'
|
||||
connector_minor: '1'
|
||||
connector_release: '0'
|
||||
|
||||
- from: ubuntu2004
|
||||
db_client: mysql
|
||||
python_minor: '8'
|
||||
connector_name: pymysql
|
||||
connector_major: '0'
|
||||
connector_minor: '9'
|
||||
connector_release: '3'
|
||||
|
||||
- from: ubuntu2004
|
||||
db_client: mysql
|
||||
python_minor: '8'
|
||||
connector_name: mysqlclient
|
||||
connector_major: '2'
|
||||
connector_minor: '0'
|
||||
connector_release: '1'
|
||||
|
||||
- from: ubuntu2004
|
||||
db_client: mysql
|
||||
python_minor: '9'
|
||||
connector_name: pymysql
|
||||
connector_major: '0'
|
||||
connector_minor: '10'
|
||||
connector_release: '1'
|
||||
|
||||
- from: ubuntu2004
|
||||
db_client: mysql
|
||||
python_minor: '9'
|
||||
connector_name: mysqlclient
|
||||
connector_major: '2'
|
||||
connector_minor: '0'
|
||||
connector_release: '3'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mysql
|
||||
python_minor: '10'
|
||||
connector_name: pymysql
|
||||
connector_major: '1'
|
||||
connector_minor: '0'
|
||||
connector_release: '2'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mysql
|
||||
python_minor: '10'
|
||||
connector_name: mysqlclient
|
||||
connector_major: '2'
|
||||
connector_minor: '1'
|
||||
connector_release: '1'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mysql
|
||||
python_minor: '11' # RHEL9 uses 3.9 by default
|
||||
connector_name: pymysql
|
||||
# Same ver. as RHEL package python3.11-PyMySQL
|
||||
connector_major: '1'
|
||||
connector_minor: '0'
|
||||
connector_release: '2'
|
||||
|
||||
- from: ubuntu2204
|
||||
db_client: mysql
|
||||
python_minor: '12' # RHEL9 uses 3.9 by default
|
||||
connector_name: pymysql
|
||||
# Same ver. as RHEL package python3.12-PyMySQL
|
||||
connector_major: '1'
|
||||
connector_minor: '1'
|
||||
connector_release: '0'
|
||||
|
||||
env:
|
||||
connector_version:
|
||||
"${{ matrix.connector_major }}.\
|
||||
${{ matrix.connector_minor }}.\
|
||||
${{ matrix.connector_release }}"
|
||||
|
||||
steps:
|
||||
# Requirement to use 'context' in docker/build-push-action@v3
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ghcr.io
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata (tags, labels)
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images:
|
||||
" ghcr.io\
|
||||
/${{ github.repository }}\
|
||||
/test-container-${{ matrix.db_client }}-\
|
||||
py3${{ matrix.python_minor }}-\
|
||||
${{ matrix.connector_name }}${{ matrix.connector_major }}\
|
||||
${{ matrix.connector_minor }}${{ matrix.connector_release }}"
|
||||
tags: latest
|
||||
|
||||
# Setting up Docker Buildx with docker-container driver is required
|
||||
# at the moment to be able to use a subdirectory with Git context
|
||||
#
|
||||
# https://github.com/docker/setup-buildx-action
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image with Buildx
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: |
|
||||
FROM quay.io/ansible/${{ matrix.from }}-test-container:main
|
||||
|
||||
RUN apt-get update -y && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
|
||||
--no-install-recommends && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
--no-install-recommends \
|
||||
python3${{ matrix.python_minor }} \
|
||||
python3${{ matrix.python_minor }}-dev \
|
||||
iproute2 \
|
||||
build-essential \
|
||||
|
||||
if [[ "${{ matrix.db_client }}" == "mysql" ]]; then
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
--no-install-recommends default-libmysqlclient-dev \
|
||||
mysql-client
|
||||
else
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
--no-install-recommends mariadb-client
|
||||
fi
|
||||
|
||||
RUN python3${{ matrix.python_minor }} -m pip install \
|
||||
--disable-pip-version-check \
|
||||
--no-cache-dir \
|
||||
cffi \
|
||||
${{ matrix.connector_name }}==$connector_version
|
||||
|
||||
ENV container=docker
|
||||
CMD ["/sbin/init"]
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
Loading…
Add table
Add a link
Reference in a new issue