-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (200 loc) · 6.22 KB
/
test.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: tests
on:
push:
branches:
- 'master'
- 'renovate/**'
tags:
- '*.*.*'
pull_request:
branches:
- 'master'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
unit-tests:
name: unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run unit tests
run: pnpm test
build:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.docker_meta.outputs.version }}
steps:
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=long
type=schedule,pattern=nightly
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=stable,enable=${{ !contains(github.event.push.ref, 'alpha') && !contains(github.event.push.ref, 'beta') && !contains(github.event.push.ref, 'rc') }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
id: docker_build
uses: docker/build-push-action@v6
with:
push: false
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
outputs: type=docker,dest=/tmp/image.tar
- name: Print image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: image
path: /tmp/image.tar
e2e-tests:
name: end to end
needs: [build]
runs-on: ubuntu-latest
env:
shardTotal: 6
WEBSITE_URL: 'http://localhost:3000'
MONGODB_URI: 'mongodb://localhost:27017/tf2pickup'
STEAM_API_KEY: ${{ secrets.STEAM_API_KEY || 'FAKE_STEAM_API_KEY' }}
QUEUE_CONFIG: '6v6'
THUMBNAIL_SERVICE_URL: 'https://mapthumbnails.tf2pickup.org'
LOG_RELAY_ADDRESS: '127.0.0.1'
LOG_RELAY_PORT: '9871'
GAME_SERVER_SECRET: 'xxxxxx'
KEY_STORE_PASSPHRASE: 'a_password'
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
services:
mongo:
image: mongo:latest
ports:
- 27017:27017
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Start mumble server
run: |
docker run \
--rm --detach \
--name mumble-server \
--network=${{ job.services.mongo.network }} \
-p 64738:64738/tcp \
-p 64738:64738/udp \
-e MUMBLE_CONFIG_AUTOBAN_ATTEMPTS=0 \
-e MUMBLE_SUPERUSER_PASSWORD=123456 \
--volume ${{ github.workspace }}/tests/mumble-data:/data \
--user root \
mumblevoip/mumble-server:latest
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: image
path: /tmp
- name: Load image
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Start app
run: |
docker run \
--name=tf2pickup-app \
--detach \
--network=${{ job.services.mongo.network }} \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-e WEBSITE_URL \
-e MONGODB_URI \
-e STEAM_API_KEY \
-e QUEUE_CONFIG \
-e KEY_STORE_PASSPHRASE \
-e LOG_RELAY_ADDRESS \
-e LOG_RELAY_PORT \
-e GAME_SERVER_SECRET \
-e THUMBNAIL_SERVICE_URL \
-p 3000:3000/tcp \
-p 9871:9871/udp \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.tag }}
docker inspect tf2pickup-app
while ! curl -s http://localhost:3000 > /dev/null; do
echo "Waiting for server..."
sleep 5
done
env:
MONGODB_URI: 'mongodb://mongo:27017/tf2pickup'
timeout-minutes: 1
- name: Run Playwright tests
run: pnpm test:e2e --shard=${{ matrix.shard }}/${{ env.shardTotal }}
env:
STEAM_USERNAME: ${{ secrets.TEST_USER_USERNAME }}
STEAM_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
- name: Stop app
if: ${{ always() }}
run: docker container stop tf2pickup-app
- name: Show app logs
if: ${{ always() }}
run: docker container logs tf2pickup-app
- if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shard }}
path: blob-report
retention-days: 1
merge-reports:
if: ${{ !cancelled() }}
needs: [e2e-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge reports from shards
run: PLAYWRIGHT_JSON_OUTPUT_NAME=results.json npx playwright merge-reports --reporter=html,json ./all-blob-reports
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report-attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 30
- uses: daun/playwright-report-summary@v3
with:
report-file: results.json