Skip to content

Commit

Permalink
Add PHP 8.1 tests + minor pipeline enhancements (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw authored Oct 18, 2021
1 parent f302862 commit 3d47b9a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 84 deletions.
74 changes: 16 additions & 58 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:

env:
extensions: pdo, pdo_pgsql
key: cache-v1

runs-on: ${{ matrix.os }}

Expand All @@ -22,45 +21,32 @@ jobs:
- ubuntu-latest

php:
- "7.4"
- "8.0"
- 7.4
- 8.0
- 8.1

pgsql:
- "9"
- "10"
- "11"
- "12"
- "13"
- 9
- 10
- 11
- 12
- 13
- 14

services:
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

steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
uses: actions/checkout@v2

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
Expand All @@ -71,43 +57,15 @@ jobs:
coverage: pcov
tools: composer:v2

- name: Determine composer cache directory on Linux
if: matrix.os == 'ubuntu-latest'
- name: Determine composer cache directory
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:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Update composer
run: composer self-update

- name: Install dependencies with composer php 7.4
if: matrix.php == '7.4'
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with composer php 8.0
if: matrix.php == '8.0'
- name: Install dependencies with composer
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests with phpunit and coverage on Linux php 7.4
if: matrix.os == 'ubuntu-latest' && matrix.php == '7.4'
run: vendor/bin/phpunit --coverage-clover=coverage.clover --colors=always

- name: Run tests with phpunit without coverage
if: matrix.os != 'ubuntu-latest' || matrix.php != '7.4'
- name: Run tests with phpunit
run: vendor/bin/phpunit --colors=always

- name: Code coverage
if: matrix.php == '7.4'
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --access-token=${{secrets.SCRUTINIZER}} --format=php-clover coverage.clover
10 changes: 5 additions & 5 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ jobs:
- ubuntu-latest

php:
- "7.4"
- 8.0

services:
postgres:
image: postgres:13
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

steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v2

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- ubuntu-latest

php:
- "7.4"
- 8.0

steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand Down
32 changes: 24 additions & 8 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,46 @@ filter:
- "src/*"

build:
image: default-bionic

environment:
php:
version: 8.0.11
ini:
"xdebug.mode": coverage
xdebug.mode: coverage

nodes:
analysis:
tests:
override:
- php-scrutinizer-run

tests-and-coverage:
phpunit:
services:
postgres: 13
db-pgsql:
image: postgres:14

dependencies:
override:
- composer self-update
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
# 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

tests:
override:
- command: "./vendor/bin/phpunit --coverage-clover ./coverage.xml"
- command: ./vendor/bin/phpunit --coverage-clover ./coverage.xml
on_node: 1
coverage:
file: coverage.xml
Expand Down
12 changes: 4 additions & 8 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected function resolveTableName(string $name): TableSchema
$resolvedName->getSchemaName() !== $this->defaultSchema ?
(string) $resolvedName->getSchemaName() . '.' :
''
) . (string) $resolvedName->getName()
) . $resolvedName->getName()
);

return $resolvedName;
Expand Down Expand Up @@ -454,7 +454,7 @@ protected function resolveTableNames(TableSchema $table, string $name): void
}

if ($table->getSchemaName() !== $this->defaultSchema) {
$name = (string) $table->getSchemaName() . '.' . (string) $table->getName();
$name = (string) $table->getSchemaName() . '.' . $table->getName();
} else {
$name = $table->getName();
}
Expand Down Expand Up @@ -491,9 +491,7 @@ protected function findConstraints(TableSchema $table): void
$tableName = $table->getName();
$tableSchema = $table->getSchemaName();

if ($tableName !== null) {
$tableName = $this->quoteValue($tableName);
}
$tableName = $this->quoteValue($tableName);

if ($tableSchema !== null) {
$tableSchema = $this->quoteValue($tableSchema);
Expand Down Expand Up @@ -664,9 +662,7 @@ protected function findColumns(TableSchema $table): bool
$schemaName = $table->getSchemaName();
$orIdentity = '';

if ($tableName !== null) {
$tableName = $this->getDb()->quoteValue($tableName);
}
$tableName = $this->getDb()->quoteValue($tableName);

if ($schemaName !== null) {
$schemaName = $this->getDb()->quoteValue($schemaName);
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class TestCase extends AbstractTestCase

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';
protected array $dataProvider;
protected array $expectedSchemas = ['public'];
Expand Down

0 comments on commit 3d47b9a

Please sign in to comment.