Repository navigation
151 lines (134 loc) · 4.77 KB
/
Copy pathrun-e2e-tests.yaml
File metadata and controls
151 lines (134 loc) · 4.77 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: E2E tests
on:
workflow_call:
env:
FORCE_COLOR: 1
permissions: {}
jobs:
run-e2e-tests:
name: E2E tests (${{ matrix.shard }}/${{ matrix.total }})
strategy:
fail-fast: false
matrix:
include:
- shard: 1
total: 4
- shard: 2
total: 4
- shard: 3
total: 4
- shard: 4
total: 4
env:
NEXT_PUBLIC_E2E_BACKEND_BASE_URL: http://localhost:9000
NEXT_SERVER_CSRF_URL: http://localhost:9000/csrf/
NEXT_SERVER_GRAPHQL_URL: http://localhost:9000/graphql/
permissions:
contents: read
runs-on: ubuntu-26.04-arm
services:
cache:
image: redis:8.8.0-alpine3.23@sha256:09160599abd229764c0fb44cb6be640294e1d360a54b19985ab4843dcf2d90f1
options: >-
--health-cmd="redis-cli ping"
--health-interval=5s
--health-retries=5
--health-timeout=5s
ports:
- 6379:6379
db:
env:
POSTGRES_DB: nest_db_e2e
POSTGRES_PASSWORD: nest_user_e2e_password
POSTGRES_USER: nest_user_e2e
image: pgvector/pgvector:pg16@sha256:00ba258a66dac104fd5171074a0084462a64a1369d8513f3d0a634e2f24d15bc
options: >-
--health-cmd="pg_isready -U nest_user_e2e -d nest_db_e2e -h localhost -p 5432"
--health-interval=5s
--health-retries=5
--health-timeout=5s
ports:
- 5432:5432
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up backend environment
uses: ./.github/actions/setup-backend-environment
with:
backend_port: 9000
db_name: nest_db_e2e
db_password: nest_user_e2e_password
db_username: nest_user_e2e
env_file: .env.e2e-tests
- name: Install frontend dependencies
uses: ./.github/actions/install-frontend-dependencies
- name: Install e2e dependencies
run: pnpm install --frozen-lockfile
working-directory: e2e
- name: Cache Playwright Chromium
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: e2e-playwright-chromium-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('e2e/package.json', 'e2e/pnpm-lock.yaml') }}
path: ~/.cache/ms-playwright
restore-keys: |
e2e-playwright-chromium-${{ runner.os }}-${{ runner.arch }}-
- name: Install Playwright Chromium
run: |
npx playwright install-deps chromium
npx playwright install chromium
working-directory: e2e
- name: Cache Next.js build
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: next-cache-e2e-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('frontend/next.config.ts', 'frontend/package.json', 'frontend/pnpm-lock.yaml')
}}
path: frontend/.next/cache
- name: Prepare environment variables for frontend
run: cp .env.e2e .env
working-directory: frontend
- name: Build frontend
run: pnpm run build
working-directory: frontend
- name: Copy public and static folders
run: |
cp -r public .next/standalone/frontend/
cp -r .next/static .next/standalone/frontend/.next/
working-directory: frontend
- name: Run frontend in the background
env:
HOSTNAME: 0.0.0.0
NEXT_PUBLIC_E2E_BACKEND_BASE_URL: http://localhost:9000
NEXT_SERVER_CSRF_URL: http://localhost:9000/csrf/
NEXT_SERVER_GRAPHQL_URL: http://localhost:9000/graphql/
NEXT_TELEMETRY_DISABLED: '1'
NODE_ENV: production
PORT: '3000'
run: |
nohup node .next/standalone/frontend/server.js > /dev/null 2>&1 &
disown
working-directory: frontend
- name: Wait for frontend to be ready
run: |
timeout 5m bash -c '
until wget --spider http://localhost:3000/api/health; do
echo "Waiting for the frontend..."
sleep 5
done
'
echo "Frontend is up!"
- name: Run frontend end-to-end tests
env:
CI: 'true'
FRONTEND_URL: http://localhost:3000
run: pnpm run test:e2e --shard=${{ matrix.shard }}/${{ matrix.total }}
working-directory: e2e
- name: Upload Playwright test results
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-test-results-shard-${{ matrix.shard }}
path: e2e/test-results/
retention-days: 7
timeout-minutes: 10