-
Notifications
You must be signed in to change notification settings - Fork 74
464 lines (409 loc) · 12.9 KB
/
pull-request.yaml
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
name: Code build and checks
on:
push:
branches: [main]
pull_request:
env:
VERSION: ${{ github.sha }}
TAG: latest
TRACETEST_ENV: ci
TRACETEST_DEV: true
CYPRESS_BASE_URL: http://localhost:11633
POKEMON_HTTP_ENDPOINT: http://demo-api:8081
# We need to remove the need for these secrets so anyone can run the pipeline
GORELEASER_KEY: ${{ secrets.GORELEASER_LICENSE }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
jobs:
backend-arch-graph:
name: Generate backend architecture graph
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: install graph tool
run: |
mkdir /tmp/go-arch
cd /tmp/go-arch
curl -SLO https://github.com/mathnogueira/golang-arch-viewer/archive/refs/heads/master.zip
unzip master.zip
cd golang-arch-viewer-master
make
mv dist/go-arch /tmp/go-arch/go-arch
- name: generate graph
run: |
cd server
mkdir -p ../dist/
/tmp/go-arch/go-arch -o ../dist/architecture.png
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: architecture-graph
path: dist/architecture.png
unit-test-cli:
name: CLI unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd cli; make test
unit-test-server:
name: API Server unit tests
runs-on: ubuntu-latest
# git log --pretty=tformat:"%H" -n1 web
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd server; make test -B
unit-test-agent:
name: Agent unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- name: Run unit tests
run: cd agent; make test -B
unit-test-web:
name: WebUI unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- run: cd web; npm ci
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
- run: cd web; npm run lint && npm test
build-docker:
name: Build docker image
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: set cache keys
shell: bash
run: |
echo "WEB_CACHE_KEY=$(git log --pretty=tformat:"%H" -n1 web)" >> $GITHUB_ENV
echo "SERVER_CACHE_KEY=$(git log --pretty=tformat:"%H" -n1 server)" >> $GITHUB_ENV
echo "CLI_CACHE_KEY=$(git log --pretty=tformat:"%H" -n1 cli)" >> $GITHUB_ENV
# web
- name: Cache Web Build
id: cache-web-build
uses: actions/cache@v3
with:
path: web/build/
key: web-build-${{ env.WEB_CACHE_KEY }}
- name: Setup node
# if cache miss
if: steps.cache-web-build.outputs.cache-hit != 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
# if cache miss
if: steps.cache-web-build.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
run: cd web/; npm ci
# if cache miss for build and deps
if: steps.cache-web-build.outputs.cache-hit != 'true' && steps.cache-nodemodules.outputs.cache-hit != 'true'
- run: cd web; CI= npm run build
if: steps.cache-web-build.outputs.cache-hit != 'true'
# go+docker
- name: Cache Build
id: cache-docker-build
uses: actions/cache@v3
with:
path: dist/
key: dist-${{env.SERVER_CACHE_KEY }}-${{env.CLI_CACHE_KEY }}-${{ hashFiles('.goreleaser.dev.yaml', 'Dockerfile') }}
- name: Setup go
if: steps.cache-docker-build.outputs.cache-hit != 'true'
uses: actions/setup-go@v3
with:
go-version-file: "go.work"
cache: true
cache-dependency-path: go.work
- uses: goreleaser/goreleaser-action@v4
if: steps.cache-docker-build.outputs.cache-hit != 'true'
with:
distribution: goreleaser-pro
version: v1.19.2
args: release --skip-announce --snapshot -f .goreleaser.dev.yaml
- name: Move binaries to known location
if: steps.cache-docker-build.outputs.cache-hit != 'true'
run: |
find ./dist -name 'tracetest' -exec cp {} ./dist \;
find ./dist -name 'tracetest-server' -exec cp {} ./dist \;
chmod +x ./dist/tracetest ./dist/tracetest-server
- name: Export docker image
if: steps.cache-docker-build.outputs.cache-hit != 'true'
run: |
docker save --output dist/image.tar "kubeshop/tracetest:$TAG"
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: tracetest-dist
path: dist/
test-examples:
name: Test examples
needs: [build-docker]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example_dir:
- collector
- tracetest-jaeger
- tracetest-opensearch
- tracetest-tempo
- tracetest-no-tracing
- tracetest-provisioning-env
- tracetest-signoz
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Build example
run: |
cd examples/${{ matrix.example_dir }}
docker-compose up -d
docker compose logs -f > /tmp/docker-log &
- name: Run example test
run: |
chmod +x ./dist/tracetest
./scripts/wait-for-port.sh 11633
./dist/tracetest configure -g --endpoint http://localhost:11633
./dist/tracetest run test -f examples/${{ matrix.example_dir }}/tests/list-tests.yaml || (cat /tmp/docker-log; exit 1)
smoke-test-cli:
name: CLI smoke tests
needs: [build-docker]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_env:
- local
- docker
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Start server
run: |
cd examples/collector
docker-compose up -d
docker compose logs -f > /tmp/docker-log &
- name: Run tests
run: |
chmod +x ./dist/tracetest ./testing/cli-smoketest/run.bash
./scripts/wait-for-port.sh 11633
cd ./testing/cli-smoketest
TRACETEST_CLI="../../dist/tracetest" \
TEST_ENV="${{ matrix.test_env }}" \
./run.bash || (cat /tmp/docker-log; exit 1)
trace-testing:
needs: [build-docker]
name: Tracetesting API Server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Start services
run: |
./run.sh down up
./run.sh tracetest-logs > /tmp/docker-log &
- name: Run tests
run: |
chmod +x ./dist/tracetest ./dist/tracetest-server
./scripts/wait-for-port.sh 11633
./run.sh tracetests || (cat /tmp/docker-log; exit 1)
e2e-cli:
name: CLI e2e tests
needs: [build-docker]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Run tests
run: |
find ./dist -name 'tracetest' -exec cp {} ./dist \;
chmod +x ./dist/tracetest
export TRACETEST_CLI=$PWD/dist/tracetest
export TEST_ENVIRONMENT=jaeger
cd ./testing/cli-e2etest
make test
# TODO: this would be a great idea but it doesn't work on GHA with docker
# it can probablly be implemented with k8s in a separated job
# I'm leaving this as a reference and as a reminder to do it
# k6-test:
# name: k6 Load Test
# needs: [build-docker]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Setup go
# uses: actions/setup-go@v3
# with:
# go-version-file: "go.work"
# cache: true
# cache-dependency-path: go.work
# - uses: actions/download-artifact@v3
# with:
# name: tracetest-dist
# path: dist/
# - name: Import image
# run: |
# docker load --input dist/image.tar
# - name: Run tests
# run: |
# chmod +x ./dist/tracetest ./testing/load/run.bash
# cd ./testing/load
# export TRACETEST_CLI="../../dist/tracetest"
# ./run.bash || (cat /tmp/docker-log; exit 1)
config-e2e:
runs-on: ubuntu-latest
outputs:
CYPRESS_CONTAINERS: ${{ steps.configure-cypress-containers.outputs.CYPRESS_CONTAINERS }}
steps:
- name: Configure Cypress containers
id: configure-cypress-containers
run: |
# env.CYPRESS_RECORD_KEY is required for parallelization, so if it's empty run a single container
if [ "${{env.CYPRESS_RECORD_KEY}}" = "" ]; then
echo "CYPRESS_CONTAINERS=[1]" >> $GITHUB_OUTPUT
else
echo "CYPRESS_CONTAINERS=[1,2,3,4,5,6,7,8]" >> $GITHUB_OUTPUT
fi
e2e:
needs: [build-docker, config-e2e]
name: WebUI End-to-end tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: ${{fromJson(needs.config-e2e.outputs.CYPRESS_CONTAINERS)}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache dependencies
id: cache-nodemodules
uses: actions/cache@v3
with:
path: |
web/node_modules
/home/runner/.cache/Cypress
key: npm--${{ hashFiles('web/package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: cd web/; npm ci
- uses: actions/download-artifact@v3
with:
name: tracetest-dist
path: dist/
- name: Import image
run: |
docker load --input dist/image.tar
- name: Run integration tests
run: |
./run.sh down up
./run.sh tracetest-logs > /tmp/docker-log &
./scripts/wait-for-port.sh 11633
if [ "${{env.CYPRESS_RECORD_KEY}}" = "" ]; then
# if this is not container #1, the script won't get here, so don't need for additional checks
./run.sh cypress
else
./run.sh cypress-ci
fi