-
Notifications
You must be signed in to change notification settings - Fork 14
226 lines (204 loc) · 7.05 KB
/
Copy pathtest-graphql.yml
File metadata and controls
226 lines (204 loc) · 7.05 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
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
name: Test graphql package logic functionalities
on:
push:
branches: ['v3', 'v3*']
paths:
- 'packages/graphql/**'
- '.github/workflows/test-graphql.yml'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'packages/graphql/**'
- '.github/workflows/test-graphql.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: klicker
POSTGRES_PASSWORD: klicker
POSTGRES_DB: klicker-prod
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
postgres_hatchet:
image: postgres:15
env:
POSTGRES_USER: hatchet
POSTGRES_PASSWORD: hatchet
POSTGRES_DB: hatchet
options: >-
--health-cmd "pg_isready -U hatchet -d hatchet"
--health-interval 5s
--health-timeout 10s
--health-retries 10
--health-start-period 30s
ports:
- 5433:5432
hatchet:
image: ghcr.io/hatchet-dev/hatchet/hatchet-lite:v0.73.1
env:
DATABASE_URL: 'postgresql://hatchet:hatchet@postgres_hatchet:5432/hatchet?sslmode=disable'
SERVER_AUTH_COOKIE_DOMAIN: localhost
SERVER_AUTH_COOKIE_INSECURE: 't'
SERVER_GRPC_BIND_ADDRESS: '0.0.0.0'
SERVER_GRPC_INSECURE: 't'
SERVER_GRPC_BROADCAST_ADDRESS: localhost:7077
SERVER_INTERNAL_CLIENT_INTERNAL_GRPC_BROADCAST_ADDRESS: localhost:7077
SERVER_GRPC_PORT: '7077'
SERVER_URL: http://localhost:8888
SERVER_AUTH_SET_EMAIL_VERIFIED: 't'
SERVER_DEFAULT_ENGINE_VERSION: 'V1'
SERVER_LOGGER_LEVEL: debug
SERVER_LOGGER_FORMAT: console
options: >-
--health-cmd "curl -f http://localhost:8888/healthz"
--health-interval 30s
--health-timeout 10s
--health-retries 10
ports:
- 8888:8888
- 7077:7077
redis_exec:
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
image: redis:7
ports:
- 6379:6379
redis_assessment:
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
image: redis:7
ports:
- 6380:6379
redis_cache:
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
image: redis:7
ports:
- 6381:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11.5.0
run_install: true
- name: Build dependency packages
run: |
cd packages/prisma
pnpm run build
cd ../types
pnpm run build
cd ../grading
pnpm run build
cd ../util
pnpm run build
cd ../knowledge-graph
pnpm run build
cd ../graphql
pnpm run build
cd ../hatchet
pnpm run build
cd ../../apps/hatchet-worker-general
pnpm run build
- name: Setup database
run: |
cd packages/prisma
pnpm run prisma:reset:raw -f
env:
DATABASE_URL: postgresql://klicker:klicker@localhost:5432/klicker-prod
- name: Run tests
run: |
set -euo pipefail
. ./util/_create_hatchet_token_graphql.sh
HATCHET_CLIENT_TOKEN=$(grep -m1 '^HATCHET_CLIENT_TOKEN=' packages/graphql/.env | cut -d'=' -f2-)
if [[ -z "${HATCHET_CLIENT_TOKEN}" ]]; then
echo "Failed to read HATCHET_CLIENT_TOKEN from packages/graphql/.env" >&2
exit 1
fi
WORKER_ENV_FILE=apps/hatchet-worker-general/.env.test.ci
cat <<EOF > "${WORKER_ENV_FILE}"
HATCHET_CLIENT_TOKEN=${HATCHET_CLIENT_TOKEN}
HATCHET_CLIENT_HOST_PORT=localhost:7077
HATCHET_CLIENT_TLS_STRATEGY=none
HATCHET_API_URL=http://localhost:8888
HATCHET_HOST_PORT=localhost:7077
HATCHET_LOG_LEVEL=DEBUG
HATCHET_TENANT_ID=707d0855-80ab-4e1f-a156-f1c4546cbf52
HATCHET_WORKER_NAME=hatchet-worker-general
LOG_LEVEL=info
NODE_ENV=test
DATABASE_URL=postgresql://klicker:klicker@localhost:5432/klicker-prod
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_ASSESSMENT_HOST=localhost
REDIS_ASSESSMENT_PORT=6380
REDIS_CACHE_HOST=localhost
REDIS_CACHE_PORT=6381
APP_ORIGIN_API=http://api.klicker.com
APP_ORIGIN_AUTH=http://auth.klicker.com
APP_ORIGIN_LTI=http://lti.klicker.com
APP_ORIGIN_PWA=http://pwa.klicker.com
APP_ORIGIN_MANAGE=http://manage.klicker.com
APP_ORIGIN_CONTROL=http://control.klicker.com
APP_ORIGIN_ASSESSMENT_API=http://assessment-api.klicker.com
APP_ORIGIN_ASSESSMENT_PWA=http://assessment.klicker.com
EOF
cleanup() {
if [[ -n "${HATCHET_WORKER_PID:-}" ]]; then
if kill -0 "${HATCHET_WORKER_PID}" >/dev/null 2>&1; then
kill "${HATCHET_WORKER_PID}" >/dev/null 2>&1 || true
wait "${HATCHET_WORKER_PID}" 2>/dev/null || true
fi
fi
rm -f "${WORKER_ENV_FILE}"
}
trap cleanup EXIT
node --env-file "${WORKER_ENV_FILE}" apps/hatchet-worker-general/dist/index.js &
HATCHET_WORKER_PID=$!
sleep 5
if ! kill -0 "${HATCHET_WORKER_PID}" >/dev/null 2>&1; then
echo "Hatchet worker failed to start. See logs above." >&2
exit 1
fi
cd packages/graphql
pnpm vitest run
env:
DATABASE_URL: postgresql://klicker:klicker@localhost:5432/klicker-prod
HATCHET_CLIENT_TLS_STRATEGY: none
HATCHET_CLIENT_HOST_PORT: localhost:7077
NODE_ENV: test
HATCHET_API_URL: http://localhost:8888
HATCHET_TENANT_ID: 707d0855-80ab-4e1f-a156-f1c4546cbf52
HATCHET_HOST_PORT: 7077
# Provide all app origins for consistency
APP_ORIGIN_API: http://api.klicker.com
APP_ORIGIN_AUTH: http://auth.klicker.com
APP_ORIGIN_LTI: http://lti.klicker.com
APP_ORIGIN_PWA: http://pwa.klicker.com
APP_ORIGIN_MANAGE: http://manage.klicker.com
APP_ORIGIN_CONTROL: http://control.klicker.com
APP_ORIGIN_ASSESSMENT_API: http://assessment-api.klicker.com
APP_ORIGIN_ASSESSMENT_PWA: http://assessment.klicker.com