Skip to content

GHA: use docker images as databases 10 bitnami images #158

GHA: use docker images as databases 10 bitnami images

GHA: use docker images as databases 10 bitnami images #158

Workflow file for this run

name: Run tests
on:
push:
branches:
# Push events on main branch
- main
- php-8.4
pull_request:
jobs:
tests:
runs-on: ${{ matrix.os }}
services:
db:
image: ${{ matrix.database_image }}
env:
# The MySQL docker container requires these environment variables to be set
# so we can create and migrate the test database.
# See: https://hub.docker.com/_/mysql
MARIADB_ROOT_PASSWORD: example
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: example
MYSQL_USER: example
MYSQL_PASSWORD: example
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
ports:
# Opens port 3306 on service container and host
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
- 3306:3306
# Before continuing, verify the mysql container is reachable from the ubuntu host
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
include:
# MySQL 8.0
- os: ubuntu-latest
database: mysql
database_image: bitnami/mysql:8.0
php-version: 8.1
- os: ubuntu-latest
database: mysql
database_image: bitnami/mysql:8.0
php-version: 8.2
- os: ubuntu-latest
database: mysql
database_image: bitnami/mysql:8.0
php-version: 8.3
- os: ubuntu-latest
database: mysql
database_image: bitnami/mysql:8.0
php-version: 8.4
# MariaDB 10.11 LTS
- os: ubuntu-20.04
database: mariadb
database_image: bitnami/mariadb:10.11
php-version: 8.1
- os: ubuntu-20.04
database: mariadb
database_image: bitnami/mariadb:10.11
php-version: 8.2
- os: ubuntu-20.04
database: mariadb
database_image: bitnami/mariadb:10.11
php-version: 8.3
- os: ubuntu-20.04
database: mariadb
database_image: bitnami/mariadb:10.11
php-version: 8.4
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Validate composer.json
run: composer validate
- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction
- name: Run PHPunit tests
run: vendor/bin/phpunit
- name: Create user and databases for testing
run: cat docker-entrypoint-initdb.d/${{ matrix.database }}-init.sql | mysql -h127.0.0.1 -uroot -pexample
- name: Run test script
run: cd tests/scripts && ./test.sh 127.0.0.1