Skip to content

Commit

Permalink
Merge pull request #123 from nextras/pr/tests-in-docker
Browse files Browse the repository at this point in the history
integration tests in docker
  • Loading branch information
JanTvrdik authored Jun 14, 2022
2 parents 436c9a3 + 36bd71d commit fd82847
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------

Expand Down
11 changes: 11 additions & 0 deletions tests/drivers.docker.ini
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions tests/php.docker.ini
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/run-in-docker.sh
Original file line number Diff line number Diff line change
@@ -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" "$@"
3 changes: 3 additions & 0 deletions tests/run-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fd82847

Please sign in to comment.