Skip to content

Commit

Permalink
chore: add a wrapper for PHPUnit binary
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Aug 8, 2024
1 parent 8bf8c4c commit b04a0d6
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 173 deletions.
103 changes: 29 additions & 74 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
tests:
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-dama == 1 && contains(matrix.database, 'sql') && ' (dama)' || '' }}${{ !contains(matrix.database, 'sql') && '' || matrix.use-migrate == 1 && ' (migrate)' || ' (schema)' }}
name: P:${{ matrix.php }}, S:${{ matrix.symfony }}, D:${{ matrix.database }}, PU:${{ matrix.phpunit }}${{ matrix.deps == 'lowest' && ' (lowest)' || '' }}${{ matrix.use-dama == 1 && contains(matrix.database, 'sql') && ' (dama)' || '' }}${{ !contains(matrix.database, 'sql') && '' || matrix.use-migrate == 1 && ' (migrate)' || ' (schema)' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -19,6 +19,7 @@ jobs:
database: [ mysql, mongo ]
use-dama: [ 1 ]
use-migrate: [ 0 ]
phpunit: [ 9 ]
exclude:
- php: 8.1
symfony: 7.0.*
Expand All @@ -31,52 +32,75 @@ jobs:
database: none
use-dama: 1
use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: mysql|mongo
use-dama: 1
use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: pgsql|mongo
use-dama: 1
use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: pgsql
use-dama: 0
use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: sqlite
use-dama: 0
use-migrate: 0
phpunit: 9
- php: 8.3
deps: lowest
symfony: '*'
database: sqlite
use-dama: 0
use-migrate: 0
phpunit: 9
- php: 8.3
deps: lowest
symfony: '*'
database: mysql
use-dama: 1
use-migrate: 0
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: mysql
use-dama: 1
use-migrate: 1
phpunit: 9
- php: 8.3
deps: highest
symfony: '*'
database: mysql|mongo
use-dama: 1
use-migrate: 0
phpunit: 10
- php: 8.3
deps: highest
symfony: '*'
database: mysql|mongo
use-dama: 1
use-migrate: 0
phpunit: 11
env:
DATABASE_URL: ${{ contains(matrix.database, 'mysql') && 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42' || contains(matrix.database, 'pgsql') && 'postgresql://root:root@localhost:5432/foundry?serverVersion=15' || contains(matrix.database, 'sqlite') && 'sqlite:///%kernel.project_dir%/var/data.db' || '' }}
MONGO_URL: ${{ contains(matrix.database, 'mongo') && 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb' || '' }}
USE_DAMA_DOCTRINE_TEST_BUNDLE: ${{ matrix.use-dama == 1 && contains(matrix.database, 'sql') && 1 || 0 }}
PHPUNIT_VERSION: ${{ matrix.phpunit }}
services:
postgres:
image: ${{ contains(matrix.database, 'pgsql') && 'postgres:15' || '' }}
Expand Down Expand Up @@ -119,67 +143,19 @@ jobs:
run: sudo /etc/init.d/mysql start

- name: Test
run: vendor/bin/phpunit -c "${PHPUNIT_CONFIG_FILE}"
run: ./phpunit
shell: bash
env:
DATABASE_RESET_MODE: ${{ matrix.use-migrate == 1 && 'migrate' || 'schema' }}
PHPUNIT_CONFIG_FILE: ${{ env.USE_DAMA_DOCTRINE_TEST_BUNDLE == 1 && 'phpunit.dama.xml.dist' || 'phpunit.xml.dist' }}

tests-no-phpunit-bridge:
name: PHPUnit:${{ matrix.phpunit }}, P:8.3, S:7.1.*, D:mysql|mongo (dama) (schema)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
phpunit: [10, 11]
env:
DATABASE_URL: 'mysql://root:root@localhost:3306/foundry?serverVersion=5.7.42'
MONGO_URL: 'mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb'
services:
mongo:
image: 'mongo:4'
ports:
- 27017:27017
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
tools: flex

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: --prefer-dist
env:
SYMFONY_REQUIRE: 7.1.*

- name: Set up MySQL
run: sudo /etc/init.d/mysql start

- name: Install PHPUnit ${{ matrix.phpunit }}
run: |
composer remove --dev symfony/phpunit-bridge
composer require --dev phpunit/phpunit:^${{ matrix.phpunit }} -W
- name: Install rector and change PHPUnit metadata from annotations to attributes
run: |
composer bin rector require --dev rector/rector
bin/tools/rector/vendor/rector/rector/bin/rector -c rector-phpunit-10.php
- name: Test
run: vendor/bin/phpunit -c phpunit-10.xml.dist

code-coverage:
name: Code Coverage
runs-on: ubuntu-latest
env:
DATABASE_URL: postgresql://root:root@localhost:5432/foundry?serverVersion=15
MONGO_URL: mongodb://127.0.0.1:27017/dbName?compressors=disabled&gssapiServiceName=mongodb
USE_DAMA_DOCTRINE_TEST_BUNDLE: 1
PHPUNIT_VERSION: 9
services:
mongo:
image: mongo:4
Expand Down Expand Up @@ -215,7 +191,7 @@ jobs:
composer-options: --prefer-dist

- name: Test with coverage
run: vendor/bin/phpunit -c phpunit.dama.xml.dist --coverage-text --coverage-clover coverage.xml
run: ./phpunit --coverage-text --coverage-clover coverage.xml
shell: bash
env:
SYMFONY_DEPRECATIONS_HELPER: disabled
Expand All @@ -242,27 +218,6 @@ jobs:
env:
DOCS_DIR: 'docs/'

build-docs:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: --prefer-dist

- name: Build docs
run: bin/build-docs

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/composer.lock
/phpunit.xml
/phpunit-dama-doctrine.xml
/phpunit-10.xml
/.phpunit.cache
/vendor/
/bin/tools/*/vendor/
/bin/tools/php-cs-fixer/composer.lock
Expand Down
38 changes: 19 additions & 19 deletions bin/tools/phpstan/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"dama/doctrine-test-bundle": "^7.0|^8.0",
"doctrine/common": "^3.2",
"doctrine/collections": "^1.7|^2.0",
"doctrine/common": "^3.2",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^2.2|^3.0",
"doctrine/mongodb-odm-bundle": "^4.6|^5.0",
"doctrine/orm": "^2.16|^3.0",
"phpunit/phpunit": "^9.5.0",
"phpunit/phpunit": "^9.5.0 || ^10.0 || ^11.0",
"symfony/console": "^6.4|^7.0",
"symfony/dotenv": "^6.4|^7.0",
"symfony/maker-bundle": "^1.55",
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ parameters:
- message: '#Return type of call to function Zenstruck\\Foundry\\Persistence\\proxy contains unresolvable type#'
path: src/Persistence/ProxyRepositoryDecorator.php

- message: '#Attribute class PHPUnit\\Framework\\Attributes\\(.*) does not exist.#'

# prevent PHPStan to force to type data providers
- identifier: missingType.iterableValue
path: tests/
Expand Down
Loading

0 comments on commit b04a0d6

Please sign in to comment.