-
-
Notifications
You must be signed in to change notification settings - Fork 12
267 lines (227 loc) · 7.08 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: test
on:
push:
branches:
- 'master'
- '*.*.*'
- 'renovate/**'
tags:
- '*.*.*'
pull_request:
branches:
- 'master'
merge_group:
jobs:
unit-tests:
name: unit
runs-on: ubuntu-22.04
strategy:
matrix:
node-version:
- 18.x
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run unit test
run: pnpm test:ci
- name: Upload test coverage info
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
e2e-tests:
name: end-to-end
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
node-version:
- 18.x
test-name:
- 'e2e/app.e2e-spec.ts'
- 'e2e/assign-and-release-gameserver.e2e-spec.ts'
- 'e2e/cancel-player-substitute.e2e-spec.ts'
- 'e2e/configuration.e2e-spec.ts'
- 'e2e/game-server-diagnostics.e2e-spec.ts'
- 'e2e/game-server-heartbeat.e2e-spec.ts'
- 'e2e/launch-game.e2e-spec.ts'
- 'e2e/manage-player-bans.e2e-spec.ts'
- 'e2e/player-action-logs.e2e-spec.ts'
- 'e2e/player-disconnects-and-gets-substituted.e2e-spec.ts'
- 'e2e/player-does-not-join-and-gets-substituted.e2e-spec.ts'
- 'e2e/player-substitutes-another-player.e2e-spec.ts'
- 'e2e/player-substitutes-himself.e2e-spec.ts'
- 'e2e/reassign-game-server.e2e-spec.ts'
- 'e2e/update-player-skill.e2e-spec.ts'
- 'e2e/websocket.e2e-spec.ts'
services:
mongo:
image: mongo:4.0
ports:
- 27017:27017
redis:
image: redis:7-alpine
ports:
- 6379:6379
gameserver1:
image: ghcr.io/tf2pickup-org/tf2-gameserver:latest
ports:
- 27015:27015/tcp
- 27015:27015/udp
- 27020:27020/udp
env:
SERVER_HOSTNAME: 'test game server 1'
PORT: 27015
CLIENT_PORT: 27016
STEAM_PORT: 27017
STV_PORT: 27020
RCON_PASSWORD: '123456'
TF2PICKUPORG_API_ADDRESS: 'host.docker.internal:3000'
TF2PICKUPORG_SECRET: 'xxxxxx'
options: --tty --add-host host.docker.internal:host-gateway
gameserver2:
image: ghcr.io/tf2pickup-org/tf2-gameserver:latest
ports:
- 27025:27025/tcp
- 27025:27025/udp
- 27030:27030/udp
env:
SERVER_HOSTNAME: 'test game server 2'
PORT: 27025
CLIENT_PORT: 27026
STEAM_PORT: 27027
STV_PORT: 27030
RCON_PASSWORD: '123456'
TF2PICKUPORG_API_ADDRESS: 'host.docker.internal:3000'
TF2PICKUPORG_SECRET: 'xxxxxx'
options: --tty --add-host host.docker.internal:host-gateway
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Setup mongodb-tools
run: |
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.6.1.deb
sudo apt install ./mongodb-database-tools-*-100.6.1.deb
mongorestore --version
- name: Restore database dump for e2e tests
run: mongorestore mongodb://localhost:27017 --quiet e2e/dump/
- name: Run e2e tests
env:
WEBSITE_NAME: 'tf2pickup.pl e2e testing'
API_URL: 'http://localhost:3000'
CLIENT_URL: 'http://localhost:4200'
BOT_NAME: 'tf2pickup.pl'
MONGODB_URI: 'mongodb://localhost:27017/tf2pickuppl_e2e_tests'
REDIS_URL: 'redis://localhost:6379'
STEAM_API_KEY: 'FAKE_API_KEY'
KEY_STORE_PASSPHRASE: 'a_password'
SUPER_USER: '76561199195756652'
QUEUE_CONFIG: '6v6'
LOG_RELAY_ADDRESS: 'host.docker.internal'
LOG_RELAY_PORT: '9871'
GAME_SERVER_SECRET: 'xxxxxx'
LOGS_TF_API_KEY: 'FAKE_LOGS_TF_API_KEY'
run: pnpm test:e2e ${{ matrix.test-name }}
- name: Upload test coverage info
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Show gameserver logs
if: failure()
run: |
docker logs "${{ job.services.gameserver1.id }}"
docker logs "${{ job.services.gameserver2.id }}"
# Start the app with a clean database and verify it doesn't crash
fresh-start:
name: fresh-start
runs-on: ubuntu-22.04
strategy:
matrix:
node-version:
- 18.x
services:
mongo:
image: mongo:4.0
ports:
- 27017:27017
redis:
image: redis:7-alpine
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run fresh instance
env:
WEBSITE_NAME: 'tf2pickup.org fresh'
API_URL: 'http://localhost:3000'
CLIENT_URL: 'http://localhost:4200'
BOT_NAME: 'tf2pickup.pl'
MONGODB_URI: 'mongodb://localhost:27017/tf2pickuporg_fresh'
REDIS_URL: 'redis://localhost:6379'
STEAM_API_KEY: 'FAKE_API_KEY'
KEY_STORE_PASSPHRASE: 'a_password'
SUPER_USER: '76561199195756652'
QUEUE_CONFIG: '6v6'
LOG_RELAY_ADDRESS: 'host.docker.internal'
LOG_RELAY_PORT: '9871'
GAME_SERVER_SECRET: 'xxxxxx'
LOGS_TF_API_KEY: 'FAKE_LOGS_TF_API_KEY'
run: timeout 3m pnpm dev || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
build:
name: build
runs-on: ubuntu-22.04
strategy:
matrix:
node-version:
- 18.x
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build