Skip to content

Commit

Permalink
Cleanup workflows, fix mutation tests (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Oct 18, 2021
1 parent f76ca88 commit 136520a
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 61 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/mssql.yml
Expand Up @@ -58,14 +58,10 @@ jobs:
coverage: pcov
tools: composer:v2, pecl

- name: Determine composer cache directory on Linux
- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
Expand All @@ -81,4 +77,4 @@ jobs:
run: composer require yiisoft/db-mssql --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit
run: vendor/bin/phpunit --testsuite Mssql --colors=always
run: vendor/bin/phpunit --group Mssql --colors=always
16 changes: 7 additions & 9 deletions .github/workflows/mutation.yml
Expand Up @@ -22,6 +22,7 @@ jobs:

php:
- 7.4
- 8.0

services:
mssql:
Expand All @@ -33,27 +34,23 @@ jobs:
ports:
- 1433:1433
options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3

mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_PASSWORD: ''
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: yiitest
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

postgres:
image: postgres:14
env:
POSTGRES_USER: scrutinizer
POSTGRES_PASSWORD: scrutinizer
POSTGRES_DB: scrutinizer
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: yiitest
ports:
- 5432:5432
options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3

oci:
image: wnameless/oracle-xe-11g-r2:latest
ports:
Expand All @@ -73,10 +70,11 @@ jobs:
php-version: "${{ matrix.php }}"
extensions: ${{ env.extensions }}
ini-values: memory_limit=-1
coverage: "pcov"
coverage: pcov
tools: composer:v2

- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/mysql.yml
Expand Up @@ -31,8 +31,7 @@ jobs:
mysql:
image: mysql:${{ matrix.mysql }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_PASSWORD: ''
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: yiitest
ports:
- 3306:3306
Expand All @@ -50,14 +49,10 @@ jobs:
ini-values: date.timezone='UTC'
coverage: pcov

- name: Determine composer cache directory on Linux
- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
Expand All @@ -73,5 +68,5 @@ jobs:
run: composer require yiisoft/db-mysql --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit
run: vendor/bin/phpunit --testsuite Mysql --colors=always
run: vendor/bin/phpunit --group Mysql --colors=always

2 changes: 1 addition & 1 deletion .github/workflows/oracle.yml
Expand Up @@ -61,4 +61,4 @@ jobs:
run: composer require yiisoft/db-oracle --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit
run: vendor/bin/phpunit --testsuite Oracle --colors=always
run: vendor/bin/phpunit --group Oracle --colors=always
14 changes: 5 additions & 9 deletions .github/workflows/pgsql.yml
Expand Up @@ -35,9 +35,9 @@ jobs:
postgres:
image: postgres:${{ matrix.pgsql }}
env:
POSTGRES_USER: scrutinizer
POSTGRES_PASSWORD: scrutinizer
POSTGRES_DB: scrutinizer
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: yiitest
ports:
- 5432:5432
options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
Expand All @@ -55,14 +55,10 @@ jobs:
coverage: pcov
tools: composer:v2

- name: Determine composer cache directory on Linux
- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Cache dependencies installed with composer
uses: actions/cache@v2
with:
Expand All @@ -78,4 +74,4 @@ jobs:
run: composer require yiisoft/db-pgsql --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit
run: vendor/bin/phpunit --testsuite Pgsql --colors=always
run: vendor/bin/phpunit --group Pgsql --colors=always
2 changes: 1 addition & 1 deletion .github/workflows/sqlite.yml
Expand Up @@ -60,4 +60,4 @@ jobs:
run: composer require yiisoft/db-sqlite --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit
run: vendor/bin/phpunit --testsuite Sqlite --colors=always
run: vendor/bin/phpunit --group Sqlite --colors=always
1 change: 1 addition & 0 deletions .github/workflows/static.yml
Expand Up @@ -17,6 +17,7 @@ jobs:

php:
- 7.4
- 8.0

steps:
- name: Checkout
Expand Down
34 changes: 32 additions & 2 deletions .scrutinizer.yml
Expand Up @@ -19,6 +19,28 @@ build:
- php-scrutinizer-run

phpunit:
services:
db-pgsql:
image: postgres:14

# Define any additional environment variables that are needed by the service.
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: yiitest

# We automatically forward these ports from your localhost to the service's port.
# Alternatively, you can also access the service on the "$SERVICE_SOME_NAME_IP"
# environment variable.
ports:
# Forward 127.0.0.1:12345 -> SERVICE_IP:12345
- 5432

# If your service writes data to disk like most databases do, you can significantly
# speed up tests by mounting a ramdisk at those paths.
ramdisks:
- /var/lib/data

dependencies:
override:
- wget https://sqlite.org/2021/sqlite-autoconf-3340100.tar.gz --no-check-certificate
Expand All @@ -30,11 +52,19 @@ build:
- sqlite3 --version && cd ..
- composer self-update
- composer require yiisoft/db-sqlite --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- composer require yiisoft/db-pgsql --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

tests:
override:
- command: "./vendor/bin/phpunit --testsuite Sqlite --coverage-clover ./coverage.xml"
- command: ./vendor/bin/phpunit --group Sqlite --coverage-clover ./coverage1.xml
on_node: 1
coverage:
file: coverage.xml
file: coverage1.xml
format: php-clover

- command: ./vendor/bin/phpunit --group Pgsql --coverage-clover ./coverage2.xml
on_node: 2
coverage:
file: coverage2.xml
format: php-clover

1 change: 1 addition & 0 deletions infection.json.dist
Expand Up @@ -4,6 +4,7 @@
"src"
]
},
"timeout": 45,
"logs": {
"text": "php:\/\/stderr",
"badge": {
Expand Down
16 changes: 2 additions & 14 deletions phpunit.xml.dist
Expand Up @@ -23,20 +23,8 @@
</include>
</coverage>
<testsuites>
<testsuite name="Mssql">
<directory>./tests/Mssql/</directory>
</testsuite>
<testsuite name="Mysql">
<directory>./tests/Mysql/</directory>
</testsuite>
<testsuite name="Oracle">
<directory>./tests/Oracle/</directory>
</testsuite>
<testsuite name="Pgsql">
<directory>./tests/Pgsql/</directory>
</testsuite>
<testsuite name="Sqlite">
<directory>./tests/Sqlite/</directory>
<testsuite name="Cache-Db">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion tests/Mssql/DbCacheMssqlTest.php
Expand Up @@ -8,7 +8,7 @@
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group mssql
* @group Mssql
*/
final class DbCacheMssqlTest extends DbCacheTest
{
Expand Down
3 changes: 3 additions & 0 deletions tests/Mssql/MigrationMssqlTest.php
Expand Up @@ -8,6 +8,9 @@
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Mssql
*/
final class MigrationMssqlTest extends MigrationTest
{
use TestTrait;
Expand Down
5 changes: 4 additions & 1 deletion tests/Mysql/DbCacheMysqlTest.php
Expand Up @@ -7,6 +7,9 @@
use Yiisoft\Cache\Db\Tests\DbCacheTest;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Mysql
*/
final class DbCacheMysqlTest extends DbCacheTest
{
use TestTrait;
Expand All @@ -16,7 +19,7 @@ final class DbCacheMysqlTest extends DbCacheTest
protected const DB_DSN = 'mysql:host=127.0.0.1;dbname=yiitest;port=3306';
protected const DB_FIXTURES_PATH = '';
protected const DB_USERNAME = 'root';
protected const DB_PASSWORD = '';
protected const DB_PASSWORD = 'root';
protected const DB_CHARSET = 'UTF8';

public function setUp(): void
Expand Down
5 changes: 4 additions & 1 deletion tests/Mysql/MigrationMysqlTest.php
Expand Up @@ -8,6 +8,9 @@
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Mysql
*/
final class MigrationMysqlTest extends MigrationTest
{
use TestTrait;
Expand All @@ -17,7 +20,7 @@ final class MigrationMysqlTest extends MigrationTest
protected const DB_DSN = 'mysql:host=127.0.0.1;dbname=yiitest;port=3306';
protected const DB_FIXTURES_PATH = '';
protected const DB_USERNAME = 'root';
protected const DB_PASSWORD = '';
protected const DB_PASSWORD = 'root';
protected const DB_CHARSET = 'UTF8';

public function setUp(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Oracle/DbCacheOracleTest.php
Expand Up @@ -7,6 +7,9 @@
use Yiisoft\Cache\Db\Tests\DbCacheTest;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Oracle
*/
final class DbCacheOracleTest extends DbCacheTest
{
use TestTrait;
Expand Down
3 changes: 3 additions & 0 deletions tests/Oracle/MigrationOracleTest.php
Expand Up @@ -8,6 +8,9 @@
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Oracle
*/
final class MigrationOracleTest extends MigrationTest
{
use TestTrait;
Expand Down
9 changes: 6 additions & 3 deletions tests/Pgsql/DbCachePgsqlTest.php
Expand Up @@ -7,16 +7,19 @@
use Yiisoft\Cache\Db\Tests\DbCacheTest;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Pgsql
*/
final class DbCachePgsqlTest extends DbCacheTest
{
use TestTrait;

protected const DB_CONNECTION_CLASS = \Yiisoft\Db\Pgsql\Connection::class;
protected const DB_DRIVERNAME = 'pgsql';
protected const DB_DSN = 'pgsql:host=127.0.0.1;dbname=scrutinizer;port=5432';
protected const DB_DSN = 'pgsql:host=127.0.0.1;dbname=yiitest;port=5432';
protected const DB_FIXTURES_PATH = '';
protected const DB_USERNAME = 'scrutinizer';
protected const DB_PASSWORD = 'scrutinizer';
protected const DB_USERNAME = 'root';
protected const DB_PASSWORD = 'root';
protected const DB_CHARSET = 'UTF8';

public function setUp(): void
Expand Down
9 changes: 6 additions & 3 deletions tests/Pgsql/MigrationPgsqlTest.php
Expand Up @@ -8,16 +8,19 @@
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Pgsql
*/
final class MigrationPgsqlTest extends MigrationTest
{
use TestTrait;

protected const DB_CONNECTION_CLASS = \Yiisoft\Db\Pgsql\Connection::class;
protected const DB_DRIVERNAME = 'pgsql';
protected const DB_DSN = 'pgsql:host=127.0.0.1;dbname=scrutinizer;port=5432';
protected const DB_DSN = 'pgsql:host=127.0.0.1;dbname=yiitest;port=5432';
protected const DB_FIXTURES_PATH = __DIR__ . '/Fixture/postgres.sql';
protected const DB_USERNAME = 'scrutinizer';
protected const DB_PASSWORD = 'scrutinizer';
protected const DB_USERNAME = 'root';
protected const DB_PASSWORD = 'root';
protected const DB_CHARSET = 'UTF8';

public function setUp(): void
Expand Down
7 changes: 5 additions & 2 deletions tests/Sqlite/DbCacheSqliteTest.php
Expand Up @@ -7,6 +7,9 @@
use Yiisoft\Cache\Db\Tests\DbCacheTest;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Sqlite
*/
final class DbCacheSqliteTest extends DbCacheTest
{
use TestTrait;
Expand All @@ -15,8 +18,8 @@ final class DbCacheSqliteTest extends DbCacheTest
protected const DB_DRIVERNAME = 'sqlite';
protected const DB_DSN = 'sqlite:' . __DIR__ . '/../runtime/test.sq3';
protected const DB_FIXTURES_PATH = '';
protected const DB_USERNAME = 'scrutinizer';
protected const DB_PASSWORD = 'scrutinizer';
protected const DB_USERNAME = '';
protected const DB_PASSWORD = '';
protected const DB_CHARSET = 'UTF8';

public function setUp(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/Sqlite/MigrationSqliteTest.php
Expand Up @@ -8,6 +8,9 @@
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\TestUtility\TestTrait;

/**
* @group Sqlite
*/
final class MigrationSqliteTest extends MigrationTest
{
use TestTrait;
Expand Down

0 comments on commit 136520a

Please sign in to comment.