diff --git a/Dockerfile b/Dockerfile index 7addcf76c..bf0a95372 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +FROM composer/composer:latest-bin AS composer FROM php:8.3-cli # System packages @@ -52,7 +53,11 @@ RUN echo 'umask 002' >> /root/.bashrc # PHP extensions -RUN docker-php-ext-install pdo_mysql pdo_pgsql +RUN docker-php-ext-install \ + pdo_mysql \ + pdo_pgsql \ + # For Psalm, to make use of JIT for a 20%+ performance boost. + opcache RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8 RUN echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini @@ -66,9 +71,12 @@ RUN printf "; priority=20\nextension=sqlsrv.so\n" > /usr/local/etc/php/conf.d/ph RUN pecl install pdo_sqlsrv RUN printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-pdo-sqlsrv.ini +# For code coverage (mutation testing) +RUN pecl install pcov && docker-php-ext-enable pcov + # Composer -COPY --from=composer:2.8.1 /usr/bin/composer /usr/local/bin/composer +COPY --from=composer /composer /usr/bin/composer # Code diff --git a/Makefile b/Makefile index 06e11269d..50c4eb6fa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,41 @@ -test-all: vendor/bin/phpunit --testsuite Sqlite,Mysql,Pgsql,Mssql,Oracle -test-sqlite: vendor/bin/phpunit --testsuite Sqlite -test-mysql: vendor/bin/phpunit --testsuite Mysql -test-pgsql: vendor/bin/phpunit --testsuite Pgsql -test-mssql: vendor/bin/phpunit --testsuite Mssql -test-oracle: vendor/bin/phpunit --testsuite Oracle +run: + docker compose run --rm --entrypoint $(CMD) php + +test-all: test-sqlite \ + test-mysql \ + test-pgsql \ + test-mssql \ + test-oracle +test-sqlite: testsuite-Sqlite +test-mysql: testsuite-Mysql +test-pgsql: testsuite-Pgsql +test-mssql: testsuite-Mssql +test-oracle: + docker compose run \ + --rm \ + --entrypoint 'bash -c -l "vendor/bin/phpunit --testsuite Oracle"' \ + php + +testsuite-%: + docker compose run \ + --rm \ + --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@)" \ + php + +static-analysis: CMD="vendor/bin/psalm --no-cache" +static-analysis: run + +mutation: CMD="\ +vendor/bin/roave-infection-static-analysis-plugin \ +--threads=2 \ +--min-msi=0 \ +--min-covered-msi=100 \ +--ignore-msi-with-no-mutations \ +--only-covered" +mutation: run + +composer-require-checker: CMD="vendor/bin/composer-require-checker" +composer-require-checker: run + +shell: CMD="bash" +shell: run diff --git a/docker-compose.yml b/docker-compose.yml index 6ae2b5913..062a94eb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,10 @@ services: condition: service_healthy postgres: condition: service_healthy + mssql: + condition: service_healthy + oracle: + condition: service_healthy environment: YII_MYSQL_DATABASE: yii YII_MYSQL_HOST: mysql @@ -31,11 +35,11 @@ services: YII_MSSQL_USER: SA YII_MSSQL_PASSWORD: YourStrong!Passw0rd - YII_ORACLE_DATABASE: + YII_ORACLE_SID: FREE YII_ORACLE_HOST: oracle - YII_ORACLE_PORT: + YII_ORACLE_PORT: 1521 YII_ORACLE_USER: system - YII_ORACLE_PASSWORD: root + YII_ORACLE_PASSWORD: sys_user_password mysql: image: mysql:9 ports: @@ -52,6 +56,23 @@ services: interval: 5s timeout: 5s retries: 20 + mariadb: + image: mariadb:11 + ports: + - "13306:3306" + volumes: + - type: tmpfs + target: /var/lib/mysql + environment: + MYSQL_DATABASE: yii + MYSQL_ROOT_PASSWORD: root + MYSQL_ROOT_HOST: "%" + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 postgres: image: postgres:17 ports: @@ -75,16 +96,37 @@ services: ACCEPT_EULA: Y ports: - "1433:1433" - expose: - - "1433" + user: root + volumes: + - mssql-data:/var/opt/mssql/data + - mssql-log:/var/opt/mssql/log + - mssql-secrets:/var/opt/mssql/secrets + healthcheck: + test: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$${SA_PASSWORD}" -Q "SELECT 1" -b -C -o /dev/null + interval: 10s + timeout: 3s + retries: 100 + start_period: 10s oracle: - image: gvenzl/oracle-xe:21 + build: + context: docker/oracle ports: - "1521:1521" - expose: - - "1521" + volumes: + - oracle-data:/opt/oracle/oradata environment: - ORACLE_PASSWORD : root - ORACLE_DATABASE : yiitest - APP_USER: yiitest - APP_USER_PASSWORD: root + ORACLE_PASSWORD: sys_user_password + APP_USER: my_user + APP_USER_PASSWORD: password_i_should_change + healthcheck: + test: ["CMD", "healthcheck.sh"] + interval: 10s + timeout: 5s + retries: 100 + start_period: 5s + start_interval: 5s +volumes: + mssql-data: + mssql-log: + mssql-secrets: + oracle-data: diff --git a/docker/oracle/Dockerfile b/docker/oracle/Dockerfile new file mode 100644 index 000000000..cc7e1498a --- /dev/null +++ b/docker/oracle/Dockerfile @@ -0,0 +1,3 @@ +FROM gvenzl/oracle-free:23 + +RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata