v2.0.0 #1698
Workflow file for this run
This file contains hidden or 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 | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| 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/blockchain/**' | |
| - 'libs/cache/src/**' | |
| - 'libs/config/src/**' | |
| - 'libs/consumer/src/**' | |
| - 'libs/logger/src/**' | |
| - 'libs/openapi/src/**' | |
| - 'libs/queue/src/**' | |
| - 'libs/types/src/**' | |
| - 'libs/utils/src/**' | |
| 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" | |
| # We want to avoid running load:medium and stress tests on PRs | |
| # Rather we want to run load:light and leave the above for release | |
| - name: Determine Test Type | |
| id: test-type | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| echo "test_type=release" >> "$GITHUB_OUTPUT" | |
| echo "batch_scenario=medium" >> "$GITHUB_OUTPUT" | |
| echo "run_stress=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "test_type=pr" >> "$GITHUB_OUTPUT" | |
| echo "batch_scenario=light" >> "$GITHUB_OUTPUT" | |
| echo "run_stress=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - 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: 22 | |
| 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/[email protected] | |
| with: | |
| url: 'http://localhost:3000/readyz' | |
| responseCode: '200' | |
| timeout: 240000 | |
| interval: 2000 | |
| - name: Setup K6 | |
| if: ${{ steps.should.outputs.RUN == 'true' }} | |
| uses: grafana/setup-k6-action@v1 | |
| - name: Run k6 Tests - Release Mode (Medium Load + Stress Tests) | |
| if: ${{ steps.should.outputs.RUN == 'true' && steps.test-type.outputs.test_type == 'release' }} | |
| run: | | |
| for test_file in apps/${{ matrix.service }}/k6-test/*.k6.js; do | |
| # Run batch announcement tests with medium scenario | |
| if [[ "$test_file" == *"batch-announcement-load"* ]]; then | |
| echo "Running batch announcement test with medium scenario: $test_file" | |
| k6 run --no-color --quiet --no-usage-report -e SCENARIO=medium "$test_file" || exit 1 | |
| else | |
| echo "Running test: $test_file" | |
| k6 run --no-color --quiet --no-usage-report "$test_file" || exit 1 | |
| fi | |
| 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 |