forked from ecamp/ecamp3
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (75 loc) · 3.06 KB
/
reusable-e2e-tests-run.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: '[reusable only] e2e tests run'
on:
workflow_call:
inputs:
run-identifier:
required: false
type: string
jobs:
e2e-tests-run:
name: 'Tests: End-to-end'
runs-on: ubuntu-latest
timeout-minutes: 20
env:
DB_CPU_LIMIT: 4
strategy:
fail-fast: false
matrix:
browser:
- chrome
- firefox
- edge
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: cp .env.ci .env
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Restore tmp folder
uses: actions/download-artifact@v4
with:
name: e2e-tests-images
path: /tmp
- name: Load images
run: |
docker load --input /tmp/ecamp3-dev-api.tar
docker image ls -a --digests
- name: Restore cache volumes (npm, composer)
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: .cache
key: docker-compose-${{ hashFiles('frontend/package-lock.json', 'print/package-lock.json', 'api/composer.lock') }}-${{ matrix.browser }}
restore-keys: |
docker-compose-
- run: |
jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')}
echo "Generating public / private keys for JWT"
mkdir -p config/jwt
echo "$jwt_passphrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
echo "$jwt_passphrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout
setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
working-directory: api
- run: docker compose up --wait -d database
- run: docker compose -f docker-compose.yml run --rm api migrate-database
# start necessary containers
- run: docker compose -f docker-compose.yml up -d api frontend pdf print browserless database docker-host http-cache mail pg-admin reverse-proxy
# pull cypress while container are starting up
- run: docker compose pull e2e
- run: sh -x wait-for-container-startup.sh
- run: docker compose --profile e2e run --rm e2e --browser ${{ matrix.browser }}
- run: sudo chown -R $USER e2e
if: always()
# store screenshots and videos on GitHub as artifacts, for downloading and debugging in case of problems
- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-output-${{ matrix.browser }}${{ inputs.run-identifier != null && format('-{0}', inputs.run-identifier) }}
path: |
e2e/data/**/*
# print running containers
- run: docker ps -a
if: always()
# print docker container logs (good for debugging; can be disabled again later on)
- run: docker compose logs --tail="all"
if: always()