Refactor MySQL and MariaDB run in a single script

parent 765432ad
......@@ -14,7 +14,11 @@ before_install:
fi
before_script:
- if [[ "$DB" == "mysql" || "$DB" == "mysqli" || "$DB" == *"mariadb"* ]]; then mysql < tests/travis/create-mysql-schema.sql; fi;
- |
if [[ -n "$IMAGE" ]]
then
bash ./tests/travis/docker-run-mysql-or-mariadb.sh
fi
install:
- travis_retry composer -n install --prefer-dist
......@@ -53,34 +57,24 @@ jobs:
- stage: Test
php: 7.2
env: DB=mysql.docker MYSQL_VERSION=8.0
sudo: required
env: DB=mysql.docker IMAGE=mysql:8.0
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: 7.2
env: DB=mysqli.docker MYSQL_VERSION=8.0
sudo: required
env: DB=mysqli.docker IMAGE=mysql:8.0
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: 7.2
env: DB=mariadb.docker MARIADB_VERSION=10.3
env: DB=mariadb.docker IMAGE=mariadb:10.3
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.2
env: DB=mariadb.mysqli.docker MARIADB_VERSION=10.3
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.2
env: DB=pgsql POSTGRESQL_VERSION=11.0
......@@ -114,74 +108,50 @@ jobs:
- bash ./tests/travis/install-mssql.sh
- stage: Test
php: 7.3
env: DB=mysql.docker MYSQL_VERSION=5.7 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
env: DB=mysql.docker IMAGE=mysql:5.7 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysql.docker MYSQL_VERSION=8.0 COVERAGE=yes
sudo: required
env: DB=mysql.docker IMAGE=mysql:8.0 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: 7.3
env: DB=mysqli.docker MYSQL_VERSION=5.7 COVERAGE=yes
sudo: required
before_script:
- bash ./tests/travis/install-mysql-5.7.sh
env: DB=mysqli.docker IMAGE=mysql:5.7 COVERAGE=yes
- stage: Test
php: 7.3
env: DB=mysqli.docker MYSQL_VERSION=8.0 COVERAGE=yes
sudo: required
env: DB=mysqli.docker IMAGE=mysql:8.0 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: 7.3
env: DB=mariadb.docker MARIADB_VERSION=10.1 COVERAGE=yes
env: DB=mariadb.docker IMAGE=mariadb:10.1 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.3
env: DB=mariadb.docker MARIADB_VERSION=10.2 COVERAGE=yes
env: DB=mariadb.docker IMAGE=mariadb:10.2 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.3
env: DB=mariadb.docker MARIADB_VERSION=10.3 COVERAGE=yes
env: DB=mariadb.docker IMAGE=mariadb:10.3 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.3
env: DB=mariadb.mysqli.docker MARIADB_VERSION=10.1 COVERAGE=yes
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.1 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.3
env: DB=mariadb.mysqli.docker MARIADB_VERSION=10.2 COVERAGE=yes
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.2 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.3
env: DB=mariadb.mysqli.docker MARIADB_VERSION=10.3 COVERAGE=yes
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3 COVERAGE=yes
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.3
env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes
......@@ -249,34 +219,24 @@ jobs:
- travis_retry composer update --prefer-dist --prefer-lowest
- stage: Test
php: 7.4
env: DB=mysql.docker MYSQL_VERSION=8.0
sudo: required
env: DB=mysql.docker IMAGE=mysql:8.0
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: 7.4
env: DB=mysqli.docker MYSQL_VERSION=8.0
sudo: required
env: DB=mysqli.docker IMAGE=mysql:8.0
services:
- docker
before_script:
- bash ./tests/travis/install-mysql-8.0.sh
- stage: Test
php: 7.4
env: DB=mariadb.docker MARIADB_VERSION=10.3
env: DB=mariadb.docker IMAGE=mariadb:10.3
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.4
env: DB=mariadb.mysqli.docker MARIADB_VERSION=10.3
env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3
services:
- docker
before_script:
- bash ./tests/travis/install-mariadb.sh
- stage: Test
php: 7.4
env: DB=pgsql POSTGRESQL_VERSION=11.0
......
DROP USER IF EXISTS 'travis'@'%';
CREATE USER 'travis'@'%';
CREATE SCHEMA doctrine_tests;
CREATE SCHEMA test_create_database;
CREATE SCHEMA test_drop_database;
GRANT ALL PRIVILEGES ON doctrine_tests.* to travis@'%';
GRANT ALL PRIVILEGES ON test_create_database.* to travis@'%';
GRANT ALL PRIVILEGES ON test_drop_database.* to travis@'%';
#!/usr/bin/env bash
set -ex
echo "Starting RDBMS…">&2
if [[ "$IMAGE" == "mysql:8.0" ]]
then
CMD_OPTIONS="--default-authentication-plugin=mysql_native_password"
else
CMD_OPTIONS=""
fi
docker run \
--health-cmd='mysqladmin ping --silent' \
--detach \
--env MYSQL_ALLOW_EMPTY_PASSWORD=yes \
--env MYSQL_DATABASE=doctrine_tests \
--publish 33306:3306 \
--name rdbms \
"$IMAGE" $CMD_OPTIONS
while true; do
healthStatus=$(docker inspect --format "{{json .State.Health.Status }}" rdbms)
case $healthStatus in
'"starting"')
echo "Waiting for RDBMS to become ready…">&2
sleep 1
;;
'"healthy"')
echo "Container is healthy">&2
break
;;
'"unhealthy"')
echo "Container is unhealthy">&2
exit 1
;;
*)
echo "Unexpected health status $healthStatus…">&2
;;
esac
done
#!/usr/bin/env bash
set -ex
sudo docker run \
--health-cmd='mysqladmin ping --silent' \
-d \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=doctrine_tests \
-p 33306:3306 \
--name mariadb \
mariadb:${MARIADB_VERSION}
until [ "$(sudo docker inspect --format "{{json .State.Health.Status }}" mariadb)" == "\"healthy\"" ]
do
echo "Waiting for MariaDB to become ready…"
sleep 1
done
#!/usr/bin/env bash
set -ex
echo "Starting MySQL 5.7..."
sudo docker run \
--health-cmd='mysqladmin ping --silent' \
-d \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=doctrine_tests \
-p 33306:3306 \
--name mysql57 \
mysql:5.7
until [ "$(sudo docker inspect --format "{{json .State.Health.Status }}" mysql57)" == "\"healthy\"" ]
do
echo "Waiting for MySQL to become ready…"
sleep 1
done
#!/usr/bin/env bash
set -ex
echo "Starting MySQL 8.0..."
sudo docker pull mysql:8.0
sudo docker run \
--health-cmd='mysqladmin ping --silent' \
-d \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_DATABASE=doctrine_tests \
-p 33306:3306 \
--name mysql80 \
mysql:8.0 \
--default-authentication-plugin=mysql_native_password
until [ "$(sudo docker inspect --format "{{json .State.Health.Status }}" mysql80)" == "\"healthy\"" ]
do
echo "Waiting for MySQL to become ready…"
sleep 1
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment