Skip to content

Commit

Permalink
Use paratest for parallel test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmeister committed Jun 16, 2024
1 parent 22b9a5c commit 151eb79
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 12 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down Expand Up @@ -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"
Expand All @@ -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 }}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -391,7 +408,7 @@ jobs:
parallel-finished: true
carryforward: "api,frontend,print,pdf"
fail-on-error: false

workflow-success:
name: workflow-success
needs:
Expand Down
3 changes: 1 addition & 2 deletions api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ APP_SECRET=!ChangeMe!
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:[email protected]: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 ###
Expand Down
7 changes: 6 additions & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -156,4 +161,4 @@
}
}
}
}
}
96 changes: 95 additions & 1 deletion api/composer.lock

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

4 changes: 4 additions & 0 deletions api/config/packages/dev/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: 'dev%env(default::TEST_TOKEN)%'
3 changes: 1 addition & 2 deletions api/config/packages/test/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -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)%'
dbname_suffix: 'test%env(default::TEST_TOKEN)%'

0 comments on commit 151eb79

Please sign in to comment.