Skip to content

feat/sovereign

feat/sovereign #125

Workflow file for this run

name: Load Tests
on:
push:
branches: [main, development]
pull_request:
branches: [main, development]
jobs:
test-base:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Initialize the project
run: npm run init
- name: Build
run: npm run build
- name: Copy devnet config file from src to dist
run: cp ./config/config.devnet.yaml ./dist/config/config.yaml
- name: Start docker services
run: docker compose up -d
- name: Start Node.js API
run: node ./dist/src/main.js &
- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Wait for API to be ready
run: |
until curl --output /dev/null --silent --fail http://localhost:4001/hello; do
echo 'Waiting for API...'
sleep 1
done
- name: Preload cache
run: k6 run ./k6/preload.js
- name: Run k6 Load Test
run: k6 run ./k6/script.js
- name: Upload result file for base branch
uses: actions/upload-artifact@v3
with:
name: base-results
path: k6/output/summary.json
- name: Stop docker services
run: docker compose down
test-head:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Initialize the project
run: npm run init
- name: Build
run: npm run build
- name: Copy devnet config file from src to dist
run: cp ./config/config.devnet.yaml ./dist/config/config.yaml
- name: Start docker services
run: docker compose up -d
- name: Start Node.js API
run: node ./dist/src/main.js &
- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Wait for API to be ready
run: |
until curl --output /dev/null --silent --fail http://localhost:4001/hello; do
echo 'Waiting for API...'
sleep 1
done
- name: Preload cache
run: k6 run ./k6/preload.js
- name: Run k6 Load Test
run: k6 run ./k6/script.js
- name: Upload result file for head branch
uses: actions/upload-artifact@v3
with:
name: head-results
path: k6/output/summary.json
- name: Stop docker services
run: docker compose down
compare-results:
runs-on: ubuntu-latest
needs: [test-base, test-head]
steps:
- uses: actions/checkout@v2
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Compare test results
run: |
node ./k6/compare-results.js ${{ github.event.pull_request.base.sha }} artifacts/base-results/summary.json ${{ github.event.pull_request.head.sha }} artifacts/head-results/summary.json report.md
- name: Render the report from the template
id: template
uses: chuhlomin/render-template@v1
if: github.event_name == 'pull_request'
with:
template: report.md
vars: |
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
- name: Upload the report markdown
uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request'
with:
name: report-markdown
path: report.md
- name: Find the comment containing the report
id: fc
uses: peter-evans/find-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'k6 load testing comparison'
- name: Create or update the report comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.template.outputs.result }}
edit-mode: replace