Content-publisher api: more validations #406
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ${{ 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' | |
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/**' | |
- 'docker-compose-k6.content-publishing-api.yaml' | |
content-watcher: | |
- 'apps/content-watcher/**' | |
- 'libs/content-watcher-lib/**' | |
- '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 || 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 |