From 151eb790d7fac662f9c978b70bee0f04c0e3881b 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 --- .github/workflows/continuous-integration.yml | 29 ++++-- api/.env | 3 +- api/composer.json | 7 +- api/composer.lock | 96 +++++++++++++++++++- api/config/packages/dev/doctrine.yaml | 4 + api/config/packages/test/doctrine.yaml | 3 +- 6 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 api/config/packages/dev/doctrine.yaml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3d960f3d5c1..7c4b052b82a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -175,15 +175,15 @@ jobs: name: 'Tests: API' 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: image: 'postgres:15-alpine' env: - POSTGRES_DB: 'ecamp3test' POSTGRES_PASSWORD: 'ecamp3' POSTGRES_USER: 'ecamp3' + POSTGRES_DB: 'ecamp3test' ports: - '5432:5432' options: >- @@ -218,6 +218,7 @@ jobs: working-directory: api - run: | + sudo apt-get install acl -y mkdir -p var/cache var/log jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')} echo "Generating public / private keys for JWT" @@ -228,10 +229,26 @@ jobs: setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt working-directory: api - - run: php bin/console doctrine:migrations:migrate --no-interaction -e test + - run: | + php bin/console doctrine:database:create --no-interaction -e test + 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: composer paratest working-directory: api env: PERFORMANCE_TEST_DEBUG_OUTPUT: ${{ vars.PERFORMANCE_TEST_DEBUG_OUTPUT }} @@ -282,7 +299,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: @@ -391,7 +408,7 @@ jobs: parallel-finished: true carryforward: "api,frontend,print,pdf" fail-on-error: false - + workflow-success: name: workflow-success needs: diff --git a/api/.env b/api/.env index c09c3d6eb7a..f02a90fa5e4 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 c173cf8ea64..7f98e8c0ca8 100644 --- a/api/composer.json +++ b/api/composer.json @@ -51,6 +51,7 @@ "webonyx/graphql-php": "15.12.2" }, "require-dev": { + "brianium/paratest": "^7.4", "friendsofphp/php-cs-fixer": "3.58.1", "hautelook/alice-bundle": "2.13.0", "justinrainbow/json-schema": "5.2.13", @@ -114,6 +115,10 @@ "Composer\\Config::disableProcessTimeout", "bin/phpunit -d memory_limit=-1" ], + "paratest": [ + "Composer\\Config::disableProcessTimeout", + "vendor/bin/paratest -p 2 --passthru-php=\"-d memory_limit=-1\"" + ], "update-snapshots": [ "Composer\\Config::disableProcessTimeout", "bin/phpunit -d memory_limit=-1 -d --update-snapshots tests/Api/SnapshotTests", @@ -156,4 +161,4 @@ } } } -} \ No newline at end of file +} diff --git a/api/composer.lock b/api/composer.lock index c80ddb3c0cd..57ee593e643 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": "a85860de00348d87ba59975167682c32", + "content-hash": "73b3cf683f66ffaf579df785b4d00ffe", "packages": [ { "name": "api-platform/core", @@ -10406,6 +10406,100 @@ ], "time": "2024-04-13T18:00:56+00:00" }, + { + "name": "brianium/paratest", + "version": "v7.4.4", + "source": { + "type": "git", + "url": "https://github.com/paratestphp/paratest.git", + "reference": "bfe354e71aca261cf37bf70bf47791081100000d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/bfe354e71aca261cf37bf70bf47791081100000d", + "reference": "bfe354e71aca261cf37bf70bf47791081100000d", + "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.0.7", + "symfony/process": "^6.4.7 || ^7.0.7" + }, + "require-dev": { + "doctrine/coding-standard": "^12.0.0", + "ext-pcov": "*", + "ext-posix": "*", + "phpstan/phpstan": "^1.10.67", + "phpstan/phpstan-deprecation-rules": "^1.1.4", + "phpstan/phpstan-phpunit": "^1.3.16", + "phpstan/phpstan-strict-rules": "^1.5.5", + "squizlabs/php_codesniffer": "^3.9.2", + "symfony/filesystem": "^6.4.3 || ^7.0.7" + }, + "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.4" + }, + "funding": [ + { + "url": "https://github.com/sponsors/Slamdunk", + "type": "github" + }, + { + "url": "https://paypal.me/filippotessarotto", + "type": "paypal" + } + ], + "time": "2024-05-03T13:01:49+00:00" + }, { "name": "clue/ndjson-react", "version": "v1.3.0", diff --git a/api/config/packages/dev/doctrine.yaml b/api/config/packages/dev/doctrine.yaml new file mode 100644 index 00000000000..34231a42942 --- /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%env(default::TEST_TOKEN)%' \ No newline at end of file diff --git a/api/config/packages/test/doctrine.yaml b/api/config/packages/test/doctrine.yaml index 2970b76ee4c..c4ccb1853e7 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