-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (119 loc) · 4.5 KB
/
load-tests.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
name: Load Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
service-matrix:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.determine-matrix.outputs.changes }}
# IF you add a new filter it ALSO needs to be here
services: >-
["account-api", "graph-api", "content-publishing-api", "content-watcher"]
# Resolves to true if it should run everything, aka when common files change
run-all: ${{ contains(fromJson(steps.determine-matrix.outputs.changes), 'common') }}
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: determine-matrix
with:
# Adding a filter? Check for the need to add to the outputs as well
filters: |
common:
- 'Docker/**'
- 'tools/ci-k6/**'
- '.github/**'
- 'docker-compose.yaml'
- 'libs/types'
- 'libs/utils'
- 'libs/consumer'
account-api:
- 'apps/account-api/**'
- 'libs/account-lib/**'
- 'docker-compose-k6.account-api.yaml'
graph-api:
- 'apps/graph-api/**'
- 'libs/graph-lib/**'
- 'docker-compose-k6.graph-api.yaml'
content-publishing-api:
- 'apps/content-publishing-api/**'
- 'libs/content-publishing-lib/**'
- 'libs/storage/**'
- 'docker-compose-k6.content-publishing-api.yaml'
content-watcher:
- 'apps/content-watcher/**'
- 'libs/content-watcher-lib/**'
- 'libs/storage/**'
- 'docker-compose-k6.content-watcher.yaml'
build:
name: '[${{ matrix.service }}] Load Test'
runs-on: ubuntu-latest
needs: service-matrix
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.service-matrix.outputs.services) }}
steps:
- name: Run or Skip
id: should
run: echo "RUN=${{ needs.service-matrix.outputs.run-all == true || contains(fromJson(needs.service-matrix.outputs.changes), matrix.service) }}" >> "$GITHUB_OUTPUT"
- name: Checkout
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: actions/checkout@v4
- name: Install Node.js
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
cache-dependency-path: tools/ci-k6/package-lock.json
- name: Install dependencies
if: ${{ steps.should.outputs.RUN == 'true' }}
working-directory: tools/ci-k6
run: npm ci
- name: Set up Docker Buildx
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: docker/setup-buildx-action@v3
# Use GitHub Container Registry instead due to rate limits
with:
buildkitd-config-inline: |
[registry."ghcr.io"]
- name: Start Frequency
if: ${{ steps.should.outputs.RUN == 'true' }}
run: |
docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml up -d frequency
sleep 15
- name: Generate Provider and Capacity
if: ${{ steps.should.outputs.RUN == 'true' }}
working-directory: tools/ci-k6
run: npm run main
# Just start the services we need...
- name: Start All Services
if: ${{ steps.should.outputs.RUN == 'true' }}
run: docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml up -d
- name: Wait for API to be ready
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: cygnetdigital/wait_for_response@v2.0.0
with:
url: 'http://localhost:3000/readyz'
responseCode: '200'
timeout: 120000
interval: 2000
- name: Setup K6
if: ${{ steps.should.outputs.RUN == 'true' }}
uses: grafana/setup-k6-action@v1
- name: Run k6 Tests
if: ${{ steps.should.outputs.RUN == 'true' }}
run: |
for test_file in apps/${{ matrix.service }}/k6-test/*.k6.js; do
k6 run --no-color --quiet --no-usage-report "$test_file" || exit 1
done
- name: Stop Docker Compose
if: ${{ steps.should.outputs.RUN == 'true' || failure() }}
run: docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml down