From 71a684250eb28737a3b6e3b09de909e10ce541bc Mon Sep 17 00:00:00 2001 From: Manuel Meister Date: Sun, 16 Jun 2024 14:24:00 +0200 Subject: [PATCH] Use paratest for parallel test execution --- .../continuous-integration-optional.yml | 2 +- .github/workflows/continuous-integration.yml | 36 +++++- .../reusable-api-performance-test.yml | 4 +- api/.env | 3 +- api/composer.json | 5 + api/composer.lock | 112 ++++++++++++++++-- api/config/packages/dev/doctrine.yaml | 4 + api/config/packages/test/doctrine.yaml | 3 +- 8 files changed, 149 insertions(+), 20 deletions(-) create mode 100644 api/config/packages/dev/doctrine.yaml diff --git a/.github/workflows/continuous-integration-optional.yml b/.github/workflows/continuous-integration-optional.yml index cee9c8ac8f..2f19cc7187 100644 --- a/.github/workflows/continuous-integration-optional.yml +++ b/.github/workflows/continuous-integration-optional.yml @@ -92,7 +92,7 @@ jobs: name: 'API: validate migrations' runs-on: ubuntu-latest env: - TEST_DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3test?serverVersion=15&charset=utf8 + DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3?serverVersion=15&charset=utf8 services: postgres: diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 44d417808b..fc1cf51692 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -223,7 +223,7 @@ jobs: - api-check-needed if: needs.api-check-needed.outputs.should_skip != 'true' env: - TEST_DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3test?serverVersion=15&charset=utf8 + DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3?serverVersion=15&charset=utf8 services: postgres: @@ -279,7 +279,35 @@ jobs: - run: php bin/console doctrine:migrations:migrate --no-interaction -e test working-directory: api - - run: composer test + - run: | + php bin/console doctrine:database:create --no-interaction -e test + php bin/console doctrine:migrations:migrate --no-interaction -e test + env: + TEST_TOKEN: 1 + working-directory: api + + - run: | + php bin/console doctrine:database:create --no-interaction -e test + php bin/console doctrine:migrations:migrate --no-interaction -e test + env: + TEST_TOKEN: 2 + working-directory: api + + - run: | + php bin/console doctrine:database:create --no-interaction -e test + php bin/console doctrine:migrations:migrate --no-interaction -e test + env: + TEST_TOKEN: 3 + working-directory: api + + - run: | + php bin/console doctrine:database:create --no-interaction -e test + php bin/console doctrine:migrations:migrate --no-interaction -e test + env: + TEST_TOKEN: 4 + working-directory: api + + - run: composer paratest -- -p 4 working-directory: api env: PERFORMANCE_TEST_DEBUG_OUTPUT: ${{ vars.PERFORMANCE_TEST_DEBUG_OUTPUT }} @@ -330,7 +358,7 @@ jobs: - name: replace paths in lcov.info that they reflect repo path run: | sed -i "s|src/|frontend/src/|g" frontend/data/coverage/lcov.info - + - name: Coveralls Parallel uses: coverallsapp/github-action@v2 with: @@ -442,7 +470,7 @@ jobs: parallel-finished: true carryforward: "api,frontend,print,pdf" fail-on-error: false - + workflow-success: name: workflow-success needs: diff --git a/.github/workflows/reusable-api-performance-test.yml b/.github/workflows/reusable-api-performance-test.yml index d8c87d25be..b1fa952d32 100644 --- a/.github/workflows/reusable-api-performance-test.yml +++ b/.github/workflows/reusable-api-performance-test.yml @@ -2,13 +2,13 @@ name: '[reusable only] api performance tests' on: workflow_call: - + jobs: api-performance-test: name: 'Tests: API performance tests' runs-on: ubuntu-latest env: - TEST_DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3test?serverVersion=15&charset=utf8 + DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3?serverVersion=15&charset=utf8 services: postgres: diff --git a/api/.env b/api/.env index c09c3d6eb7..f02a90fa5e 100644 --- a/api/.env +++ b/api/.env @@ -31,8 +31,7 @@ APP_SECRET=!ChangeMe! # # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" # DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7" -DATABASE_URL="postgresql://ecamp3:ecamp3@database:5432/ecamp3dev?serverVersion=15&charset=utf8" -TEST_DATABASE_URL="postgresql://ecamp3:ecamp3@database:5432/ecamp3test?serverVersion=15&charset=utf8" +DATABASE_URL="postgresql://ecamp3:ecamp3@database:5432/ecamp3?serverVersion=15&charset=utf8" ###< doctrine/doctrine-bundle ### ###> nelmio/cors-bundle ### diff --git a/api/composer.json b/api/composer.json index 891d29548d..8f3f81f2a9 100644 --- a/api/composer.json +++ b/api/composer.json @@ -51,6 +51,7 @@ "webonyx/graphql-php": "15.12.5" }, "require-dev": { + "brianium/paratest": "^7.4", "friendsofphp/php-cs-fixer": "3.62.0", "hautelook/alice-bundle": "2.13.0", "justinrainbow/json-schema": "6.0.0", @@ -114,6 +115,10 @@ "Composer\\Config::disableProcessTimeout", "bin/phpunit -d memory_limit=-1" ], + "paratest": [ + "Composer\\Config::disableProcessTimeout", + "vendor/bin/paratest --passthru-php=\"-d memory_limit=-1\"" + ], "update-snapshots": [ "Composer\\Config::disableProcessTimeout", "bin/phpunit -d memory_limit=-1 -d --update-snapshots tests/Api/SnapshotTests", diff --git a/api/composer.lock b/api/composer.lock index aa59cf66aa..e76fdd2dca 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1ce91f397201ed13fe999c198b6e0cda", + "content-hash": "e2a179284549c0d918ceef74f75943c3", "packages": [ { "name": "api-platform/core", @@ -10302,6 +10302,100 @@ ], "time": "2024-04-13T18:00:56+00:00" }, + { + "name": "brianium/paratest", + "version": "v7.4.5", + "source": { + "type": "git", + "url": "https://github.com/paratestphp/paratest.git", + "reference": "d4de825332842a7dee1ff350f0fd6caafa930d79" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/d4de825332842a7dee1ff350f0fd6caafa930d79", + "reference": "d4de825332842a7dee1ff350f0fd6caafa930d79", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-simplexml": "*", + "fidry/cpu-core-counter": "^1.1.0", + "jean85/pretty-package-versions": "^2.0.6", + "php": "~8.2.0 || ~8.3.0", + "phpunit/php-code-coverage": "^10.1.14 || ^11.0.3", + "phpunit/php-file-iterator": "^4.1.0 || ^5.0.0", + "phpunit/php-timer": "^6.0.0 || ^7.0.0", + "phpunit/phpunit": "^10.5.20 || ^11.1.3", + "sebastian/environment": "^6.1.0 || ^7.1.0", + "symfony/console": "^6.4.7 || ^7.1.0", + "symfony/process": "^6.4.7 || ^7.1.0" + }, + "require-dev": { + "doctrine/coding-standard": "^12.0.0", + "ext-pcov": "*", + "ext-posix": "*", + "phpstan/phpstan": "^1.11.2", + "phpstan/phpstan-deprecation-rules": "^1.2.0", + "phpstan/phpstan-phpunit": "^1.4.0", + "phpstan/phpstan-strict-rules": "^1.6.0", + "squizlabs/php_codesniffer": "^3.10.1", + "symfony/filesystem": "^6.4.3 || ^7.1.0" + }, + "bin": [ + "bin/paratest", + "bin/paratest.bat", + "bin/paratest_for_phpstorm" + ], + "type": "library", + "autoload": { + "psr-4": { + "ParaTest\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Scaturro", + "email": "scaturrob@gmail.com", + "role": "Developer" + }, + { + "name": "Filippo Tessarotto", + "email": "zoeslam@gmail.com", + "role": "Developer" + } + ], + "description": "Parallel testing for PHP", + "homepage": "https://github.com/paratestphp/paratest", + "keywords": [ + "concurrent", + "parallel", + "phpunit", + "testing" + ], + "support": { + "issues": "https://github.com/paratestphp/paratest/issues", + "source": "https://github.com/paratestphp/paratest/tree/v7.4.5" + }, + "funding": [ + { + "url": "https://github.com/sponsors/Slamdunk", + "type": "github" + }, + { + "url": "https://paypal.me/filippotessarotto", + "type": "paypal" + } + ], + "time": "2024-05-31T13:59:20+00:00" + }, { "name": "clue/ndjson-react", "version": "v1.3.0", @@ -10368,26 +10462,26 @@ }, { "name": "composer/pcre", - "version": "3.2.0", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90" + "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/ea4ab6f9580a4fd221e0418f2c357cdd39102a90", - "reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90", + "url": "https://api.github.com/repos/composer/pcre/zipball/1637e067347a0c40bbb1e3cd786b20dcab556a81", + "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81", "shasum": "" }, "require": { "php": "^7.4 || ^8.0" }, "conflict": { - "phpstan/phpstan": "<1.11.8" + "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.8", + "phpstan/phpstan": "^1.11.10", "phpstan/phpstan-strict-rules": "^1.1", "phpunit/phpunit": "^8 || ^9" }, @@ -10427,7 +10521,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.2.0" + "source": "https://github.com/composer/pcre/tree/3.3.0" }, "funding": [ { @@ -10443,7 +10537,7 @@ "type": "tidelift" } ], - "time": "2024-07-25T09:36:02+00:00" + "time": "2024-08-19T19:43:53+00:00" }, { "name": "composer/semver", diff --git a/api/config/packages/dev/doctrine.yaml b/api/config/packages/dev/doctrine.yaml new file mode 100644 index 0000000000..ac27353d25 --- /dev/null +++ b/api/config/packages/dev/doctrine.yaml @@ -0,0 +1,4 @@ +doctrine: + dbal: + # "TEST_TOKEN" is typically set by ParaTest + dbname_suffix: 'dev' \ No newline at end of file diff --git a/api/config/packages/test/doctrine.yaml b/api/config/packages/test/doctrine.yaml index 2970b76ee4..c4ccb1853e 100644 --- a/api/config/packages/test/doctrine.yaml +++ b/api/config/packages/test/doctrine.yaml @@ -1,5 +1,4 @@ doctrine: dbal: - url: '%env(resolve:TEST_DATABASE_URL)%' # "TEST_TOKEN" is typically set by ParaTest - #dbname_suffix: '_test%env(default::TEST_TOKEN)%' \ No newline at end of file + dbname_suffix: 'test%env(default::TEST_TOKEN)%' \ No newline at end of file