Skip to content

Commit 79c121f

Browse files
committed
CI: add api performance test
Do not add it to every PR or push for now, run it overnight and if the label is set on a PR. We don't know if the tests are flaky, and they need quite some resources.
1 parent 76f163a commit 79c121f

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Tests: API performance test"
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [ opened, labeled, unlabeled, synchronize ]
7+
schedule:
8+
- cron: '51 4 * * *'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}
12+
cancel-in-progress: false
13+
14+
jobs:
15+
api-performance-test:
16+
name: 'API performance test'
17+
if: contains(github.event.pull_request.labels.*.name, 'api-performance-test!') || github.event_name != 'pull_request'
18+
uses: ./.github/workflows/reusable-api-performance-test.yml
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

Comments
 (0)