Skip to content

Commit bf43ccc

Browse files
ci: add performance script to PR jobs (#3274)
* feat: poc run performance against testenv - currently requires running tests to setup db (waiting to avoid actually running tests and spinning down tests/env) - loses ability to run k6 against rafiki w/ telemetry * Revert "feat: poc run performance against testenv" This reverts commit 1a6c0e6. * refactor: mv testenv to ./test from ./test/integration - in preparation for switching performance test to target testenv - ensured integration tests pass * refactor: mv MockASE to new test-lib - supports reuse in setup script for performance tests which will allow running performance test against testenv - also bumps graphql pacakge version across monorepo. added to test-lib which caused some type errors in backend and auth due to a version mismatch * chore: generate gql * feat(performance): make environment configurable * feat(performance): make run and test script configurable per env * fix(performance): up liquidity, matching localenv * ci: add performance test * chore: fix eslint error * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * fix: script typo * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore: debug test in ci * chore(auth): gql generate * chore: test manually commenting logs from perf test * chore: test comment w/ summary, not logs * fix: pr comment * chore: try linking perf results to gh job * Revert "chore: try linking perf results to gh job" This reverts commit 432c443. * chore: add logs to pr comment, try link again * chore: fix indentation * chore: try forming link * chore: rm badish link * fix: owner undefined * chore: test ci * chore: test ci * chore: test ci * chore: clarify job script * fix: override test config in ci - not sure if config outpute by script will reflect options passed in, probably not. config in gh pr comment may not be accurate. * ci: test failure * chore: ignore test summary * ci: un-fail step * ci: tune test config * ci: tune test config * ci: tune test config * fix: 401 bug for duplicate reqs * ci: tune test config * docs: update performance readme * docs: update README * docs: rm inaccurate info * ci: tune test config * fix: return to orginal duration * chore: fix typos * chore: rm console.log * Update .github/workflows/node-build.yml Co-authored-by: Max Kurapov <[email protected]> * ci(performance): test mase start failure * ci(performance): test mase start failure * ci(performance): test changes * ci(performance): test changes * ci(performance): test changes * ci(performance): test changes * fix: newline * ci: test start mase failure * chore: eslint * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: test start mase failure * ci: cleanup --------- Co-authored-by: Max Kurapov <[email protected]>
1 parent a338e5d commit bf43ccc

36 files changed

+1702
-1883
lines changed

.github/workflows/node-build.yml

+125
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,131 @@ jobs:
159159
- name: Run tests
160160
run: pnpm --filter integration run-tests
161161

162+
performance-test:
163+
runs-on: ubuntu-22.04
164+
needs: prerequisite
165+
timeout-minutes: 5
166+
steps:
167+
- name: Checkout code
168+
uses: actions/checkout@v4
169+
170+
- name: Setup environment
171+
uses: ./.github/workflows/rafiki/env-setup
172+
173+
- name: Set up k6
174+
uses: grafana/setup-k6-action@v1
175+
176+
- name: Setup hosts
177+
run: |
178+
echo "127.0.0.1 cloud-nine-wallet-test-backend" | sudo tee -a /etc/hosts
179+
echo "127.0.0.1 cloud-nine-wallet-test-auth" | sudo tee -a /etc/hosts
180+
echo "127.0.0.1 happy-life-bank-test-backend" | sudo tee -a /etc/hosts
181+
echo "127.0.0.1 happy-life-bank-test-auth" | sudo tee -a /etc/hosts
182+
183+
- name: Build dependencies
184+
run: pnpm --filter performance build:deps
185+
186+
- name: Bundle
187+
run: pnpm --filter performance bundle
188+
189+
- name: Start test environment
190+
run: pnpm --filter performance testenv:compose up --wait --build -d
191+
192+
- name: Start Mock Account Entity Services
193+
run: |
194+
pnpm --filter performance start-mases > mases.log 2>&1 &
195+
MASES_PID=$!
196+
sleep 5
197+
if ! ps -p $MASES_PID > /dev/null; then
198+
echo "Mock Account Entity Services failed to start. Check logs:"
199+
cat mases.log
200+
exit 1
201+
fi
202+
203+
- name: Run performance tests
204+
id: perf_test
205+
run: |
206+
pnpm --filter performance run-tests:testenv -k -q --vus 4 --duration 1m | tee performance.log
207+
208+
- name: Post/Update Performance Test Results as PR Comment
209+
if: always()
210+
uses: actions/github-script@v7
211+
with:
212+
github-token: ${{ secrets.GITHUB_TOKEN }}
213+
script: |
214+
const fs = require('fs');
215+
const summaryPath = './test/performance/k6-test-summary.txt';
216+
const logPath = './performance.log';
217+
let summaryContent = '';
218+
let logContent = '';
219+
220+
// Read the k6 summary file
221+
if (fs.existsSync(summaryPath)) {
222+
summaryContent = fs.readFileSync(summaryPath, 'utf8');
223+
} else {
224+
summaryContent = 'Performance test summary not found.';
225+
}
226+
227+
// Read the full logs
228+
if (fs.existsSync(logPath)) {
229+
logContent = fs.readFileSync(logPath, 'utf8');
230+
} else {
231+
logContent = 'Performance log not found.';
232+
}
233+
234+
// Limit in case large file size to avoid error posting comment (65kb limit)
235+
// https://github.com/orgs/community/discussions/41331
236+
const maxLogSize = 60000;
237+
const truncatedLogs = logContent.length > maxLogSize ? `...(truncated)...\n${logContent.slice(-maxLogSize)}` : logContent;
238+
239+
240+
const commentBody = `
241+
### 🚀 Performance Test Results
242+
243+
${summaryContent}
244+
245+
<details>
246+
<summary>📜 Logs</summary>
247+
248+
\`\`\`
249+
${truncatedLogs}
250+
\`\`\`
251+
252+
</details>
253+
`;
254+
255+
const { owner, repo } = context.repo;
256+
const prNumber = context.payload.pull_request?.number;
257+
258+
if (prNumber) {
259+
const comments = await github.rest.issues.listComments({
260+
owner,
261+
repo,
262+
issue_number: prNumber
263+
});
264+
265+
// Identify existing comment via title
266+
const existingComment = comments.data.find(comment => comment.body.includes('🚀 Performance Test Results'));
267+
268+
if (existingComment) { // upsert comment
269+
await github.rest.issues.updateComment({
270+
owner,
271+
repo,
272+
comment_id: existingComment.id,
273+
body: commentBody
274+
});
275+
} else {
276+
await github.rest.issues.createComment({
277+
owner,
278+
repo,
279+
issue_number: prNumber,
280+
body: commentBody
281+
});
282+
}
283+
} else {
284+
console.log("No PR detected, skipping comment.");
285+
}
286+
162287
node-build:
163288
runs-on: ubuntu-latest
164289
timeout-minutes: 5

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ packages/**/src/openapi/specs/schemas.yaml
6363
packages/**/src/openapi/specs/auth-server.yaml
6464
packages/**/src/openapi/specs/resource-server.yaml
6565
packages/**/src/openapi/specs/wallet-address-server.yaml
66+
67+
k6-test-summary.txt

0 commit comments

Comments
 (0)