Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Build/Test Tools: Add matrix test for databases
The suitability of databases needs to be tested with CI.

Add testing for MySQL and MariaDB on the earliest supported version,
and the latest version.

MariaDB Testing is also done on their non-released version by using
a container image produced from their CI. This image contains reviewed
and tested work of the MariaDB developers. This is a good opporunity
to catch pre-release regressiosn on their part.

This is based off the end to end tests, but now we are applying them
across database versions.

Docker debug information uses \s to show the client and server
information. The MariaDB Testing images also contain /manifest.txt
containing the git version of build to report regressions.

References:
* [https://mariadb.org/new-service-quay-io-mariadb-foundation-mariadb-devel/ MariaDB Blog of quay.io service]

Trac ticket:
  • Loading branch information
grooverdan committed Sep 15, 2022
1 parent 39617d8 commit 8a2079f
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 14 deletions.
14 changes: 2 additions & 12 deletions .env
Expand Up @@ -39,19 +39,9 @@ LOCAL_PHP_MEMCACHED=false
##
# The database software to use.
#
# Supported values are `mysql` and `mariadb`.
# Contains the image name, a mysql or mariadb image, with optional tag for use.
##
LOCAL_DB_TYPE=mysql

##
# The database version to use.
#
# Defaults to 5.7 with the assumption that LOCAL_DB_TYPE is set to `mysql` above.
#
# When using `mysql`, see https://hub.docker.com/r/amd64/mysql for valid versions.
# When using `mariadb`, see https://hub.docker.com/r/amd64/mariadb for valid versions.
##
LOCAL_DB_VERSION=5.7
LOCAL_DB_IMAGE=docker.io/amd64/mysql:5.7

# The debug settings to add to `wp-config.php`.
LOCAL_WP_DEBUG=true
Expand Down
202 changes: 202 additions & 0 deletions .github/workflows/database-compatibility.yml
@@ -0,0 +1,202 @@
name: Database Compatibility Tests

on:
# The database compatiblity test suite was introduced in WordPress 6.1.
push:
branches:
- database_ci
- trunk
- '6.[1-9]'
- '[7-9].[0-9]'
tags:
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
- '![345].[0-9].[0-9]+'
- '!6.0.[0-9]+'
pull_request:
branches:
- trunk
- '6.[1-9]'
- '[7-9].[0-9]'
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

env:
LOCAL_DIR: build

jobs:
wordpress-build:
name: build wordpress
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2

- name: Log debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
php --version
php -i
locale -a
- name: Install NodeJS
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install Dependencies
run: npm ci

- name: Build WordPress
run: npm run build

- name: Save wordpress image as tarball
run: docker export --output /tmp/wordpress.tar wordpressdevelop/php

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: wordpress
path: /tmp/wordpress.tar

- name: General debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
- name: Docker debug information
run: |
docker -v
docker-compose -v
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm php php -i
docker-compose run --rm php locale -a
# Runs the database compatibility test suite.
#
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# _ Installs NPM dependencies.
# - Builds WordPress to run from the `build` directory.
# - Starts the WordPress Docker container.
# - Logs general debug information.
# - Logs the running Docker containers.
# - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container).
# - Install WordPress within the Docker container.
# - Run the E2E tests.
# - Ensures version-controlled files are not modified or deleted.
database-tests:
name: Database Test ${{ matrix.image }}
runs-on: ubuntu-latest
needs: [ wordpress-build ]
timeout-minutes: 10
# TODO tmp if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
image:
- mysql:5.7
- mysql:latest
- mariadb:10.3
- mariadb:latest
- quay.io/mariadb-foundation/mariadb-devel:10.3
- quay.io/mariadb-foundation/mariadb-devel:10.11

steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: wordpress
path: /tmp

- name: Load Docker image
run: |
docker load --input /tmp/wordpress.tar
docker image ls -a
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2

- name: Start Docker environment
run: |
export LOCAL_DB_IMAGE=${{ matrix.image }}
npm run env:start
- name: Log running Docker containers
run: docker ps -a

- name: Docker debug information
run: |
docker-compose exec -t mysql mysql -ppassword -e 'select version();'
docker-compose exec mysql sh -c '[ -f /manifest.txt ] && cat /manifest.txt'
- name: Install WordPress
run: npm run env:install

- name: Run E2E tests
run: npm run test:e2e

slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
needs: [ database-tests ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ needs.database-tests.result == 'success' && 'success' || needs.database-tests.result == 'cancelled' && 'cancelled' || 'failure' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}

failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ database-tests, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.database-tests.result == 'cancelled' || needs.database-tests.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@c713e510dbd7d213d92d41b7a7805a986f4c5c66 # v6.2.0
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: '${{ github.ref_name }}',
inputs: {
run_id: '${{ github.run_id }}'
}
});
4 changes: 2 additions & 2 deletions docker-compose.yml
Expand Up @@ -62,10 +62,10 @@ services:
- localhost:host-gateway

##
# The MySQL container.
# The MySQL or MariaDB container.
##
mysql:
image: amd64/${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-latest}
image: ${LOCAL_DB_IMAGE-amd64/mysql:5.7}

networks:
- wpdevnet
Expand Down

0 comments on commit 8a2079f

Please sign in to comment.