Carsten Brandt
8 years ago
committed by
GitHub
28 changed files with 643 additions and 62 deletions
@ -0,0 +1,118 @@
|
||||
before_script: |
||||
# set stack isolation |
||||
- export ISOLATION=buildpipeline${CI_PIPELINE_ID}${CI_BUILD_NAME} |
||||
- export COMPOSE_PROJECT_NAME=${ISOLATION} |
||||
- export TUPLE_C=$(expr ${CI_BUILD_ID} % 99) |
||||
- echo ${TUPLE_C} |
||||
# run docker-compose commands from tests environment |
||||
- cd tests |
||||
- cp .env-dist .env |
||||
- docker-compose config |
||||
|
||||
after_script: |
||||
- export ISOLATION=buildpipeline${CI_PIPELINE_ID}${CI_BUILD_NAME} |
||||
- export COMPOSE_PROJECT_NAME=${ISOLATION} |
||||
# run docker-compose commands from tests environment |
||||
- cd tests |
||||
- cp .env-dist .env |
||||
- docker-compose down -v --remove-orphans |
||||
- docker ps -f name=${ISOLATION} |
||||
|
||||
stages: |
||||
- travis |
||||
- test |
||||
- cleanup |
||||
|
||||
test: |
||||
stage: test |
||||
script: |
||||
- docker-compose up --build -d |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --exclude caching,db,data --log-junit tests/_junit/test.xml |
||||
|
||||
caching: |
||||
stage: test |
||||
only: |
||||
- tests/caching |
||||
- tests/full |
||||
script: |
||||
- export COMPOSE_FILE=docker-compose.yml:docker-compose.${CI_BUILD_NAME}.yml |
||||
- docker-compose up --build -d |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --group caching --exclude db |
||||
|
||||
db: |
||||
stage: test |
||||
only: |
||||
- tests/mysql |
||||
- tests/full |
||||
script: |
||||
- docker-compose up --build -d |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --group db --exclude caching,mysql,pgsql,mssql,cubrid,oci |
||||
|
||||
|
||||
mysql: |
||||
stage: test |
||||
only: |
||||
- tests/mysql |
||||
- tests/full |
||||
script: |
||||
- export COMPOSE_FILE=docker-compose.yml:docker-compose.${CI_BUILD_NAME}.yml |
||||
- docker-compose up --build -d |
||||
# wait for db (retry X times) |
||||
- docker-compose run --rm php bash -c "while ! curl mysql:3306; do ((c++)) && ((c==30)) && break; sleep 2; done" |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --group mysql |
||||
|
||||
|
||||
pgsql: |
||||
stage: test |
||||
only: |
||||
- tests/pgsql |
||||
- tests/full |
||||
script: |
||||
- export COMPOSE_FILE=docker-compose.yml:docker-compose.${CI_BUILD_NAME}.yml |
||||
- docker-compose up --build -d |
||||
# wait for db (retry X times) |
||||
- docker-compose run --rm php bash -c 'while [ true ]; do curl postgres:5432; if [ $? == 52 ]; then break; fi; ((c++)) && ((c==25)) && break; sleep 2; done' |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --group pgsql |
||||
|
||||
|
||||
cubrid: |
||||
stage: test |
||||
only: |
||||
- tests/cubrid |
||||
- tests/extra |
||||
script: |
||||
- cd cubrid |
||||
- docker-compose up --build -d |
||||
# wait for db (retry X times) |
||||
- docker-compose run --rm php bash -c 'while [ true ]; do curl cubrid:1523; if [ $? == 56 ]; then break; fi; ((c++)) && ((c==20)) && break; sleep 3; done' |
||||
- sleep 5 |
||||
- docker-compose run --rm php /project/vendor/bin/phpunit -v --group cubrid |
||||
|
||||
|
||||
mssql: |
||||
stage: test |
||||
only: |
||||
- tests/mssql |
||||
- tests/extra |
||||
script: |
||||
- cd mssql |
||||
- docker-compose up --build -d |
||||
# wait for db (retry X times) |
||||
- docker-compose run --rm php bash -c 'while [ true ]; do curl mssql:1433; if [ $? == 52 ]; then break; fi; ((c++)) && ((c==15)) && break; sleep 5; done' |
||||
- sleep 3 |
||||
# Note: Password has to be the last parameter |
||||
- docker-compose run --rm sqlcmd sh -c 'sqlcmd -S mssql -U sa -Q "CREATE DATABASE yii2test" -P Microsoft-12345' |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --group mssql |
||||
|
||||
|
||||
travis: |
||||
stage: travis |
||||
only: |
||||
- travis |
||||
script: |
||||
- export COMPOSE_FILE=docker-compose.yml:docker-compose.mysql.yml:docker-compose.pgsql.yml |
||||
- docker-compose up --build -d |
||||
# wait for dbs ... |
||||
- sleep 10 |
||||
- docker-compose run --rm php vendor/bin/phpunit -v --exclude mssql,cubrid,oci,wincache,xcache,zenddata,cubrid |
||||
|
@ -0,0 +1,8 @@
|
||||
FROM dmstr/php-yii2:7.0-fpm-1.9-beta2-alpine-nginx |
||||
|
||||
# Project source-code |
||||
WORKDIR /project |
||||
ADD composer.* /project/ |
||||
RUN /usr/local/bin/composer install --prefer-dist |
||||
ADD ./ /project |
||||
ENV PATH /project/vendor/bin:${PATH} |
@ -0,0 +1,10 @@
|
||||
# docker-compose test environment |
||||
|
||||
# Choose a flavour |
||||
#COMPOSE_FILE=docker-compose.yml:docker-compose.caching.yml |
||||
#COMPOSE_FILE=docker-compose.yml:docker-compose.mysql.yml |
||||
#COMPOSE_FILE=docker-compose.yml:docker-compose.postgres.yml |
||||
|
||||
# Choose a version |
||||
DOCKER_MYSQL_IMAGE=percona:5.7 |
||||
DOCKER_POSTGRES_IMAGE=postgres |
@ -0,0 +1,31 @@
|
||||
FROM php:5-fpm |
||||
|
||||
# /usr/local/lib/php/extensions/no-debug-non-zts-20131226/cubrid.so |
||||
RUN pecl install pdo_cubrid-9.3.0.0001 |
||||
RUN echo "extension=pdo_cubrid.so" > /usr/local/etc/php/conf.d/cubrid.ini |
||||
|
||||
|
||||
# Install system packages for composer (git) |
||||
RUN apt-get update && \ |
||||
apt-get -y install \ |
||||
git \ |
||||
--no-install-recommends && \ |
||||
apt-get clean && \ |
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
||||
# Register the COMPOSER_HOME environment variable |
||||
ENV COMPOSER_HOME /composer |
||||
# Add global binary directory to PATH and make sure to re-export it |
||||
ENV PATH /usr/local/bin:$PATH |
||||
# Allow Composer to be run as root |
||||
ENV COMPOSER_ALLOW_SUPERUSER 1 |
||||
# Install composer |
||||
RUN curl -sS https://getcomposer.org/installer | php -- \ |
||||
--filename=composer.phar \ |
||||
--install-dir=/usr/local/bin |
||||
|
||||
|
||||
# Project source-code |
||||
WORKDIR /project |
||||
ADD composer.* /project/ |
||||
RUN /usr/local/bin/composer.phar install --prefer-dist |
||||
ADD ./ /project |
@ -0,0 +1,17 @@
|
||||
version: '2' |
||||
services: |
||||
|
||||
php: |
||||
build: |
||||
context: ../.. |
||||
dockerfile: tests/cubrid/Dockerfile |
||||
ports: |
||||
- 80 |
||||
#volumes: |
||||
# - ../..:/project |
||||
depends_on: |
||||
- cubrid |
||||
|
||||
cubrid: |
||||
image: lighthopper/cubrid:9.3.6.0002 |
||||
command: ./create-start-demodb.sh |
@ -0,0 +1,59 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* This is the configuration file for the Yii 2 unit tests. |
||||
* You can override configuration values by creating a `config.local.php` file |
||||
* and manipulate the `$config` variable. |
||||
* For example to change MySQL username and password your `config.local.php` should |
||||
* contain the following: |
||||
* |
||||
<?php |
||||
$config['databases']['mysql']['username'] = 'yiitest'; |
||||
$config['databases']['mysql']['password'] = 'changeme'; |
||||
|
||||
*/ |
||||
|
||||
$config = [ |
||||
'databases' => [ |
||||
'cubrid' => [ |
||||
'dsn' => 'cubrid:dbname=demodb;host=cubrid;port=33000', |
||||
'username' => 'dba', |
||||
'password' => '', |
||||
'fixture' => __DIR__ . '/cubrid.sql', |
||||
], |
||||
'mysql' => [ |
||||
'dsn' => 'mysql:host=mysql;dbname=yiitest', |
||||
'username' => 'travis', |
||||
'password' => 'travis', |
||||
'fixture' => __DIR__ . '/mysql.sql', |
||||
], |
||||
'sqlite' => [ |
||||
'dsn' => 'sqlite::memory:', |
||||
'fixture' => __DIR__ . '/sqlite.sql', |
||||
], |
||||
'sqlsrv' => [ |
||||
'dsn' => 'sqlsrv:Server=mssql;Database=yii2test', |
||||
'username' => 'sa', |
||||
'password' => 'Microsoft-12345', |
||||
'fixture' => __DIR__ . '/mssql.sql', |
||||
], |
||||
'pgsql' => [ |
||||
'dsn' => 'pgsql:host=postgres;dbname=yiitest;port=5432;', |
||||
'username' => 'postgres', |
||||
'password' => 'postgres', |
||||
'fixture' => __DIR__ . '/postgres.sql', |
||||
], |
||||
'oci' => [ |
||||
'dsn' => 'oci:dbname=LOCAL_XE;charset=AL32UTF8;', |
||||
'username' => '', |
||||
'password' => '', |
||||
'fixture' => __DIR__ . '/oci.sql', |
||||
], |
||||
], |
||||
]; |
||||
|
||||
if (is_file(__DIR__ . '/config.local.php')) { |
||||
include(__DIR__ . '/config.local.php'); |
||||
} |
||||
|
||||
return $config; |
@ -0,0 +1,13 @@
|
||||
version: '2' |
||||
services: |
||||
|
||||
php: |
||||
depends_on: |
||||
- redis |
||||
- memcached |
||||
|
||||
redis: |
||||
image: redis |
||||
|
||||
memcached: |
||||
image: memcached |
@ -0,0 +1,15 @@
|
||||
version: '2' |
||||
services: |
||||
|
||||
php: |
||||
depends_on: |
||||
- mysql |
||||
|
||||
mysql: |
||||
image: ${DOCKER_MYSQL_IMAGE} |
||||
environment: |
||||
- MYSQL_ROOT_PASSWORD=secret |
||||
- MYSQL_DATABASE=yiitest |
||||
- MYSQL_USER=travis |
||||
- MYSQL_PASSWORD=travis |
||||
|
@ -0,0 +1,14 @@
|
||||
version: '2' |
||||
|
||||
services: |
||||
|
||||
php: |
||||
depends_on: |
||||
- postgres |
||||
|
||||
postgres: |
||||
image: ${DOCKER_POSTGRES_IMAGE} |
||||
environment: |
||||
- POSTGRES_DB=yiitest |
||||
- POSTGRES_USER=postgres |
||||
- POSTGRES_PASSWORD=postgres |
@ -0,0 +1,22 @@
|
||||
version: '2' |
||||
services: |
||||
|
||||
php: |
||||
build: .. |
||||
working_dir: /project |
||||
volumes: |
||||
- ../tests/data/config-docker.php:/project/tests/data/config.php |
||||
# Enable for debugging, enabling tests might be slow for file access (data) on host-volume |
||||
#- ../tests:/project/tests |
||||
# - ../framework:/project/framework |
||||
# Tmpfs volume (experimental, asset tests may fail) |
||||
#tmpfs: |
||||
# - /project/tests/runtime |
||||
|
||||
networks: |
||||
default: |
||||
ipam: |
||||
driver: default |
||||
config: |
||||
# prevent overlapping/duplicated networks, since docker assigns /16 subnets by default ranging from 10.x over 172.x to 192.168.x |
||||
- subnet: 10.100.1${TUPLE_C}.1/24 |
@ -0,0 +1,56 @@
|
||||
FROM bylexus/apache-php7 |
||||
|
||||
|
||||
# https://www.microsoft.com/en-us/sql-server/developer-get-started/php-ubuntu |
||||
RUN apt-get update |
||||
RUN apt-get install -y curl apt-transport-https |
||||
|
||||
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - |
||||
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list |
||||
|
||||
RUN apt-get update \ |
||||
&& apt-get install -y unixodbc-dev-utf16 php-dev \ |
||||
&& pecl install sqlsrv pdo_sqlsrv |
||||
|
||||
RUN echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/apache2/php.ini |
||||
RUN echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/apache2/php.ini |
||||
RUN echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/cli/php.ini |
||||
RUN echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/cli/php.ini |
||||
|
||||
# IMPORTANT NOTICE! Install `msodbcsql` after `unixodbc-dev-utf16` and `pdo_sqlsrv`, due to dependency & build issues |
||||
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql |
||||
|
||||
# Install system packages for composer (git) |
||||
RUN apt-get update && \ |
||||
apt-get -y install \ |
||||
git \ |
||||
php-curl \ |
||||
--no-install-recommends && \ |
||||
rm -rf /tmp/* /var/tmp/* |
||||
# Register the COMPOSER_HOME environment variable |
||||
ENV COMPOSER_HOME /composer |
||||
# Add global binary directory to PATH and make sure to re-export it |
||||
ENV PATH /usr/local/bin:$PATH |
||||
# Allow Composer to be run as root |
||||
ENV COMPOSER_ALLOW_SUPERUSER 1 |
||||
# Install composer |
||||
RUN curl -sS https://getcomposer.org/installer | php -- \ |
||||
--filename=composer.phar \ |
||||
--install-dir=/usr/local/bin |
||||
RUN composer.phar global require --optimize-autoloader \ |
||||
"hirak/prestissimo" |
||||
|
||||
|
||||
# Project source-code |
||||
WORKDIR /project |
||||
ADD composer.* /project/ |
||||
RUN /usr/local/bin/composer.phar install --prefer-dist |
||||
ADD ./ /project |
||||
|
||||
# https://github.com/Microsoft/msphpsql/issues/161 |
||||
RUN apt-get install -y locales \ |
||||
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ |
||||
&& locale-gen |
||||
|
||||
# Debug installation |
||||
RUN dpkg -L msodbcsql |
@ -0,0 +1,34 @@
|
||||
version: '2' |
||||
services: |
||||
|
||||
php: |
||||
build: |
||||
context: ../.. |
||||
dockerfile: tests/mssql/Dockerfile |
||||
# Alternative pre-built image (TODO: evaluate) |
||||
#image: ppoffice/apache-php-mssql-odbc |
||||
ports: |
||||
- 80 |
||||
# Enable for debugging, Note: File-cache tests may be VERY slow or fail |
||||
#volumes: |
||||
# - ../../..:/project |
||||
depends_on: |
||||
- mssql |
||||
# Enable for debugging |
||||
#entrypoint: ['bash'] |
||||
|
||||
mssql: |
||||
image: microsoft/mssql-server-linux |
||||
# Alternative pre-built image (TODO: evaluate) |
||||
#image: microsoft/mssql-server-windows |
||||
environment: |
||||
- ACCEPT_EULA=Y |
||||
- SA_PASSWORD=Microsoft-12345 |
||||
|
||||
sqlcmd: |
||||
image: tsgkadot/mssql-tools |
||||
# Mount project for accessing SQL dump (TODO) |
||||
volumes: |
||||
- ../..:/project |
||||
# Enable for debugging |
||||
#entrypoint: ['bash'] |
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
# Generate a "hash" from 0-99 for subnet tuple (10, 11, ..., 199) - it's a hack |
||||
echo "Creating CI_BUILD_ID and CI_PIPELINE_ID from first argument..." |
||||
export CI_BUILD_ID=$(expr $((32#${1})) % 99) |
||||
export CI_PIPELINE_ID=${1} |
||||
|
||||
# Copy snippets from https://git.hrzg.de/ci/lint |
||||
case $1 in |
||||
'default') |
||||
export ISOLATION=buildpipeline${CI_PIPELINE_ID} |
||||
export COMPOSE_PROJECT_NAME=${ISOLATION} |
||||
export TUPLE_C=$(expr ${CI_BUILD_ID} % 255) |
||||
echo ${TUPLE_C} |
||||
docker-compose up -d |
||||
docker-compose run --rm php vendor/bin/phpunit -v --exclude caching,db |
||||
docker-compose down -v |
||||
;; |
||||
'caching') |
||||
export ISOLATION=buildpipeline${CI_PIPELINE_ID} |
||||
export COMPOSE_PROJECT_NAME=${ISOLATION} |
||||
export TUPLE_C=$(expr ${CI_BUILD_ID} % 255) |
||||
echo ${TUPLE_C} |
||||
export COMPOSE_PROJECT_NAME=${ISOLATION}caching |
||||
docker-compose up -d |
||||
docker-compose run --rm php bash -c "while ! curl mysql:3306; do ((c++)) && ((c==30)) && break; sleep 2; done" |
||||
docker-compose run --rm php vendor/bin/phpunit -v --group caching |
||||
docker-compose down -v |
||||
;; |
||||
'mssql') |
||||
export ISOLATION=buildpipeline${CI_PIPELINE_ID} |
||||
export COMPOSE_PROJECT_NAME=${ISOLATION} |
||||
export TUPLE_C=$(expr ${CI_BUILD_ID} % 255) |
||||
echo ${TUPLE_C} |
||||
cd mssql |
||||
docker-compose up --build -d |
||||
docker-compose run --rm php bash -c 'while [ true ]; do curl mssql:1433; if [ $? == 52 ]; then break; fi; ((c++)) && ((c==15)) && break; sleep 5; done' |
||||
sleep 10 |
||||
docker-compose run --rm sqlcmd sh -c 'sqlcmd -S mssql -U sa -Q "CREATE DATABASE yii2test" -P Microsoft-12345' |
||||
sleep 10 |
||||
docker-compose logs mssql |
||||
docker-compose config |
||||
pwd |
||||
docker-compose ps |
||||
docker-compose run --rm php php -i |
||||
docker-compose run --rm php vendor/bin/phpunit -v --group mssql |
||||
docker-compose down -v --remove-orphans |
||||
;; |
||||
'pgsql') |
||||
export ISOLATION=buildpipeline${CI_PIPELINE_ID} |
||||
export COMPOSE_PROJECT_NAME=${ISOLATION} |
||||
export TUPLE_C=$(expr ${CI_BUILD_ID} % 255) |
||||
echo ${TUPLE_C} |
||||
export COMPOSE_PROJECT_NAME=${ISOLATION}pgsql |
||||
docker-compose up -d |
||||
docker-compose run --rm php bash -c 'while [ true ]; do curl postgres:5432; if [ $? == 52 ]; then break; fi; ((c++)) && ((c==25)) && break; sleep 2; done' |
||||
docker-compose run --rm php vendor/bin/phpunit -v --group pgsql |
||||
docker-compose down -v |
||||
;; |
||||
*) |
||||
echo "Warning: No job argument specified" |
||||
;; |
||||
esac |
||||
|
||||
echo "Done." |
Loading…
Reference in new issue