diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..556614c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,48 @@ +x-php-service-base: &php-service-base + deploy: + replicas: 0 + + working_dir: /src + user: '1000:1000' + volumes: + - ./src:/src/src + - ./tests:/src/tests + - ./composer.bridgeless.json:/src/composer.bridgeless.json + +services: + php71: + <<: *php-service-base + image: thecodingmachine/php:7.1-v3-cli + + php72: + <<: *php-service-base + image: thecodingmachine/php:7.2-v4-cli + + php73: + <<: *php-service-base + image: thecodingmachine/php:7.3-v4-cli + + php74: + <<: *php-service-base + image: thecodingmachine/php:7.4-v4-cli + + php80: + <<: *php-service-base + image: thecodingmachine/php:8.0-v4-cli + + php81: + <<: *php-service-base + image: thecodingmachine/php:8.1-v4-cli + + postgres: + image: postgres:9.6 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: nextras_migrations_test + + mysql: + image: mysql:5.6 + environment: + MYSQL_DATABASE: nextras_migrations_test + MYSQL_ROOT_PASSWORD: root diff --git a/readme.md b/readme.md index e5e735e..00d6cd6 100644 --- a/readme.md +++ b/readme.md @@ -18,6 +18,23 @@ For more information read **[documentation](https://nextras.org/migrations/docs) * [dibi](https://github.com/dg/dibi) +Development & Running Integration Tests in Docker +------------------------------------------------ + +1. Create `./tests/*.ini` files + ```bash + cp tests/php.docker.ini tests/php.ini + cp tests/drivers.docker.ini tests/drivers.ini + ``` +2. Start containers + ```bash + docker-compose up --detach + ``` +3. Run tests + ```bash + tests/run-in-docker.sh php81 tests/run-integration.sh + ``` + License ------- diff --git a/tests/drivers.docker.ini b/tests/drivers.docker.ini new file mode 100644 index 0000000..d061292 --- /dev/null +++ b/tests/drivers.docker.ini @@ -0,0 +1,11 @@ +[mysql] +host = "mysql" +database = nextras_migrations_test +username = root +password = root + +[pgsql] +host = "postgres" +database = nextras_migrations_test +username = postgres +password = postgres diff --git a/tests/php.docker.ini b/tests/php.docker.ini new file mode 100644 index 0000000..113ac3f --- /dev/null +++ b/tests/php.docker.ini @@ -0,0 +1,14 @@ +[PHP] +extension = ctype.so +extension = curl.so +extension = dom.so +extension = json.so +extension = mysqlnd.so +extension = mysqli.so +extension = pdo.so +extension = pdo_mysql.so +extension = pdo_pgsql.so +extension = pgsql.so +extension = simplexml.so +extension = tokenizer.so +extension = zip.so diff --git a/tests/run-in-docker.sh b/tests/run-in-docker.sh new file mode 100755 index 0000000..541d850 --- /dev/null +++ b/tests/run-in-docker.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -o errexit -o pipefail -o nounset + +export COMPOSER_HOME=${COMPOSER_HOME:-$HOME/.config/composer} +export COMPOSER_CACHE_DIR=${COMPOSER_CACHE_DIR:-$HOME/.cache/composer} + +PHP_SERVICE="$1" +shift + +docker-compose run \ + -e COMPOSER_HOME \ + -e COMPOSER_CACHE_DIR \ + -v $COMPOSER_HOME:$COMPOSER_HOME \ + -v $COMPOSER_CACHE_DIR:$COMPOSER_CACHE_DIR \ + "$PHP_SERVICE" "$@" diff --git a/tests/run-integration.sh b/tests/run-integration.sh index 11b21c3..5132e39 100755 --- a/tests/run-integration.sh +++ b/tests/run-integration.sh @@ -103,6 +103,9 @@ tester_run_integration_group() } +sudo composer self-update --2 + + if [[ "$#" -eq 0 ]]; then for FILENAME in "$PROJECT_DIR/tests/matrix"/**/*.sh; do run "$FILENAME"