-
Notifications
You must be signed in to change notification settings - Fork 40
295 lines (282 loc) · 10.6 KB
/
Copy pathtest.yml
File metadata and controls
295 lines (282 loc) · 10.6 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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Test
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_NO_WARNINGS: 1
CI: true
jobs:
unit:
strategy:
fail-fast: false
matrix:
node-version:
- 20
- 22
- 24
- 25
hive-router-runtime:
- 0
- 1
name: Unit / Node v${{matrix.node-version}} / ${{matrix.hive-router-runtime == 1 && 'Router' || 'Stitching'}} Runtime
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version: ${{matrix.node-version}}
- name: Test
run: yarn test
env:
HIVE_ROUTER_RUNTIME: ${{matrix.hive-router-runtime}}
unit-bun:
name: Unit / Bun
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: Test with Stitching Runtime
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
with:
timeout_minutes: 10
max_attempts: 3
command: yarn test:bun
- name: Test with Router Runtime
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
env:
HIVE_ROUTER_RUNTIME: 1
with:
timeout_minutes: 10
max_attempts: 3
command: yarn test:bun
leaks:
strategy:
fail-fast: false
matrix:
node-version:
- 20
- 22
- 24
- 25
hive-router-runtime:
- 0
- 1
name: Leaks / Node v${{matrix.node-version}} / ${{matrix.hive-router-runtime == 1 && 'Router' || 'Stitching'}} Runtime
needs: [unit] # leak tests run unit tests but check for leaks; if unit tests fail, leaks will fail too - avoid confusion by running them in series
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version: ${{matrix.node-version}}
- name: Test
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
env:
HIVE_ROUTER_RUNTIME: ${{matrix.hive-router-runtime}}
with:
timeout_minutes: 10
max_attempts: 3
command: yarn test:leaks
e2e:
runs-on: ${{ matrix.setup.os }}
strategy:
fail-fast: false
matrix:
setup:
# Node
- workflow-name: Node 20 on Ubuntu
os: ubuntu-latest
gateway-runner: node
hive-router-runtime: 0
node-version: 20
- workflow-name: Node 22 on Ubuntu
os: ubuntu-latest
gateway-runner: node
hive-router-runtime: 0
node-version: 22
- workflow-name: Node 24 on Ubuntu
os: ubuntu-latest
gateway-runner: node
hive-router-runtime: 0
node-version: 24
- workflow-name: Node 25 on Ubuntu
os: ubuntu-latest
gateway-runner: node
hive-router-runtime: 0
node-version: 25
- workflow-name: Node 25 on Ubuntu with Router Runtime
os: ubuntu-latest
gateway-runner: node
hive-router-runtime: 1
node-version: 25
# Node on Docker
- workflow-name: Node Docker on Ubuntu
os: ubuntu-latest
gateway-runner: docker
hive-router-runtime: 0
# Node Binary
- workflow-name: Node Binary on Ubuntu
os: ubuntu-latest
gateway-runner: bin
hive-router-runtime: 0
- workflow-name: Node Binary on Windows
os: windows-latest
gateway-runner: bin
hive-router-runtime: 0
# Should be the same with Linux
# - workflow-name: Node Binary on MacOS Arm64
# os: macos-15 # MacOS Arm64
# gateway-runner: bin
# hive-router-runtime: 0
# - workflow-name: Node Binary on MacOS x86_64
# os: macos-15-intel # MacOS x86_64
# gateway-runner: bin
# hive-router-runtime: 0
# Bun
- workflow-name: Bun on Ubuntu
os: ubuntu-latest
gateway-runner: bun
hive-router-runtime: 0
- workflow-name: Bun on Ubuntu with Router Runtime
os: ubuntu-latest
gateway-runner: bun
hive-router-runtime: 1
- workflow-name: Bun Docker on Ubuntu
os: ubuntu-latest
gateway-runner: bun-docker
hive-router-runtime: 0
name: E2E / ${{matrix.setup.workflow-name}}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- if: runner.os == 'Windows'
name: Cache WMIC
id: cache-wmic
uses: actions/cache@v5
with:
path: |
C:\Windows\System32\wbem\WMIC.exe
C:\Windows\System32\wbem\wmic.exe
key: wmic-${{ matrix.setup.os }}
- if: runner.os == 'Windows' && !contains(steps.cache-wmic.outputs.cache-hit, 'true')
name: Enable WMIC
run: DISM /Online /Add-Capability /CapabilityName:WMIC~~~~
- name: Check if WMIC is installed
if: runner.os == 'Windows'
run: C:\Windows\System32\wbem\wmic.exe /?
- name: Add WMIC to PATH
if: runner.os == 'Windows'
run: echo "C:\Windows\System32\wbem" >> "$GITHUB_PATH"
- name: Check if WMIC works
if: runner.os == 'Windows'
run: wmic /?
- if: matrix.setup.gateway-runner == 'docker' || matrix.setup.gateway-runner == 'bun-docker'
name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- if: runner.os == 'Windows'
name: Install Windows SDK
run: scripts\install-winsdk.ps1
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version # if matrix.setup.node-version is not provided, the version from the file will be used
node-version: ${{matrix.setup.node-version}}
- if: runner.os == 'Linux'
name: Hash Docker Images
id: hash-docker-images
run: | # get all "image: '" occurrences in the e2e tests and hash them
echo "result=$(grep -r -h "image: '" e2e | shasum | base64)" >> "$GITHUB_OUTPUT"
- if: runner.os == 'Linux'
name: Cache Docker Images
uses: ScribeMD/docker-cache@e1be5d7e63cc5f0c6400d8cb86d3d899a7fd71e2 # 0.5.0 + https://github.com/ScribeMD/docker-cache/pull/838
continue-on-error: true
with:
key: docker-images-${{ runner.os }}-${{ steps.hash-docker-images.outputs.result }}
- if: matrix.setup.gateway-runner == 'docker' || matrix.setup.gateway-runner == 'bun-docker' || matrix.setup.gateway-runner == 'bin'
name: Build # TODO: necessary only because rollup does not use tsconfig paths within node_modules and we have packages scattered between Mesh and Hive GW repos
run: yarn build
- if: matrix.setup.gateway-runner == 'docker' || matrix.setup.gateway-runner == 'bun-docker' || matrix.setup.gateway-runner == 'bin'
name: Bundle
env:
E2E_GATEWAY_RUNNER: ${{matrix.setup.gateway-runner}}
run: yarn workspace @graphql-hive/gateway bundle
- if: matrix.setup.gateway-runner == 'docker' || matrix.setup.gateway-runner == 'bun-docker'
name: Bake
uses: docker/bake-action@5be5f02ff8819ecd3092ea6b2e6261c31774f2b4 # v6
with:
source: .
targets: e2e${{ matrix.setup.gateway-runner == 'bun-docker' && '_bun' || '' }}
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
# we must load so that the e2e tests can use the cached image
load: true
- if: matrix.setup.gateway-runner == 'bin'
name: Package binary
run: yarn workspace @graphql-hive/gateway tsx scripts/package-binary
- name: Test
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
with:
timeout_minutes: 10
max_attempts: 3
command: yarn test:e2e
env:
HIVE_ROUTER_RUNTIME: ${{matrix.setup.hive-router-runtime}}
E2E_GATEWAY_RUNNER: ${{matrix.setup.gateway-runner}}
E2E_TEST_APOLLO_GRAPH_REF: ${{secrets.E2E_TEST_APOLLO_GRAPH_REF}}
E2E_TEST_APOLLO_KEY: ${{secrets.E2E_TEST_APOLLO_KEY}}
security:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
runtime: [Node, Bun]
name: Security / ${{matrix.runtime}} Docker Image
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Set up env
uses: the-guild-org/shared-config/setup@v1
with:
node-version-file: .node-version
- name: Build
run: yarn build
- name: Bundle
env:
E2E_GATEWAY_RUNNER: ${{ matrix.runtime == 'Bun' && 'bun-docker' || 'docker' }}
run: yarn workspace @graphql-hive/gateway bundle
- name: Bake
uses: docker/bake-action@5be5f02ff8819ecd3092ea6b2e6261c31774f2b4 # v6
with:
source: .
# we build the e2e image because the release image cant be loaded due to annotations and platforms
# but the e2e image builds _from_ the release image, so it's actually the same
targets: e2e${{ matrix.runtime == 'Bun' && '_bun' || '' }}
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
# we must load so that the created image can be scanned
load: true
- name: Scan
uses: aquasecurity/trivy-action@c1824fd6edce30d7ab345a9989de00bbd46ef284 # 0.34.0
with:
image-ref: ghcr.io/graphql-hive/gateway:e2e${{ matrix.runtime == 'Bun' && '-bun' || '' }}
format: table
exit-code: 1
severity: CRITICAL,HIGH,MEDIUM # fail if the following severity vulnerabilities are found
ignore-unfixed: true # there really nothing we can do about unfixed cves