|
| 1 | +name: '[reusable only] api performance tests' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + api-performance-test: |
| 8 | + name: 'Tests: API performance tests' |
| 9 | + runs-on: ubuntu-latest |
| 10 | + env: |
| 11 | + TEST_DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3test?serverVersion=15&charset=utf8 |
| 12 | + |
| 13 | + services: |
| 14 | + postgres: |
| 15 | + image: 'postgres:15-alpine' |
| 16 | + env: |
| 17 | + POSTGRES_DB: 'ecamp3test' |
| 18 | + POSTGRES_PASSWORD: 'ecamp3' |
| 19 | + POSTGRES_USER: 'ecamp3' |
| 20 | + ports: |
| 21 | + - '5432:5432' |
| 22 | + options: >- |
| 23 | + --health-cmd pg_isready |
| 24 | + --health-interval 10s |
| 25 | + --health-timeout 5s |
| 26 | + --health-retries 5 |
| 27 | +
|
| 28 | + steps: |
| 29 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 30 | + |
| 31 | + - uses: shivammathur/setup-php@v2 |
| 32 | + with: |
| 33 | + php-version: '8.3.2' |
| 34 | + extensions: intl-73.1 |
| 35 | + tools: composer:2.7.0 |
| 36 | + coverage: pcov |
| 37 | + |
| 38 | + - name: Get Composer Cache Directory |
| 39 | + id: composer-cache |
| 40 | + run: 'echo "dir=$(composer config cache-files-dir)" | tr -d "\n" >> $GITHUB_OUTPUT' |
| 41 | + working-directory: api |
| 42 | + |
| 43 | + - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 |
| 44 | + with: |
| 45 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 46 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 47 | + restore-keys: | |
| 48 | + ${{ runner.os }}-composer- |
| 49 | +
|
| 50 | + - run: composer install --prefer-dist --no-progress --no-interaction |
| 51 | + working-directory: api |
| 52 | + |
| 53 | + - run: | |
| 54 | + mkdir -p var/cache var/log |
| 55 | + jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')} |
| 56 | + echo "Generating public / private keys for JWT" |
| 57 | + mkdir -p config/jwt |
| 58 | + echo "$jwt_passphrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096 |
| 59 | + echo "$jwt_passphrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout |
| 60 | + setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt |
| 61 | + setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt |
| 62 | + working-directory: api |
| 63 | +
|
| 64 | + - run: php bin/console doctrine:migrations:migrate --no-interaction -e test |
| 65 | + working-directory: api |
| 66 | + |
| 67 | + - run: composer performance_test |
| 68 | + working-directory: api |
0 commit comments