88
99env :
1010 NODE_VERSION : ' 20'
11- RUST_VERSION : ' 1.85 '
11+ RUST_VERSION : ' 1.88 '
1212
1313jobs :
1414 commitlint :
3939 run : npm ci --legacy-peer-deps
4040
4141 - name : Validate PR commits
42- run : npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.sha }} --verbose
42+ run : npx commitlint --from=origin/ ${{ github.event.pull_request.base.ref }} --to=HEAD --verbose
4343
4444 # ─────────────────────────────────────────────────────────
4545 # TypeScript / React Native Checks
5050 steps :
5151 - name : Checkout code
5252 uses : actions/checkout@v4
53+ with :
54+ token : ${{ secrets.GITHUB_TOKEN }}
5355
5456 - name : Setup Node.js
5557 uses : actions/setup-node@v4
6971 run : npm ci --legacy-peer-deps
7072
7173 - name : Check formatting (Prettier)
74+ id : prettier-check
7275 run : npm run format:check
76+ continue-on-error : true
77+
78+ - name : Auto-fix formatting issues
79+ if : steps.prettier-check.outcome == 'failure'
80+ run : |
81+ echo "Formatting inconsistencies detected. Executing auto-fixer..."
82+ npm run format:write || npx prettier --write "src/**/*.{ts,tsx,js,json,md}"
83+
84+ - name : Commit and Push formatting fixes
85+ if : steps.prettier-check.outcome == 'failure'
86+ uses : stefanzweifel/git-auto-commit-action@v5
87+ with :
88+ commit_message : ' chore: automated code formatting fixes via CI pipeline'
89+ commit_user_name : ' github-actions[bot]'
90+ commit_user_email : ' github-actions[bot]@users.noreply.github.com'
91+
92+ - name : Enforce strict layout check
93+ if : steps.prettier-check.outcome == 'failure'
94+ run : |
95+ echo "❌ Code styles were inconsistent. Automated modifications have been pushed to your branch."
96+ echo "Please pull latest changes locally or wait for the subsequent workflow run execution pass."
97+ exit 1
7398
7499 - name : Run ESLint
75100 run : npm run lint
@@ -201,6 +226,19 @@ jobs:
201226 if : steps.cache-node-modules.outputs.cache-hit != 'true'
202227 run : npm ci --legacy-peer-deps
203228
229+ - name : Patch metro exports for @expo/cli compatibility
230+ run : |
231+ node -e "
232+ const fs=require('fs');
233+ const p='node_modules/metro/package.json';
234+ if(!fs.existsSync(p)) process.exit(0);
235+ const m=JSON.parse(fs.readFileSync(p,'utf8'));
236+ if(!m.exports||m.exports['./src/lib/TerminalReporter']) process.exit(0);
237+ m.exports['./src/lib/TerminalReporter']='./src/lib/TerminalReporter.js';
238+ fs.writeFileSync(p,JSON.stringify(m,null,2));
239+ console.log('Patched metro exports to add ./src/lib/TerminalReporter');
240+ "
241+
204242 - name : Run Expo export
205243 run : npm run build
206244 env :
@@ -265,9 +303,9 @@ jobs:
265303 uses : actions/cache@v4
266304 with :
267305 path : |
268- ~/. cargo/registry/index/
269- ~/. cargo/registry/cache/
270- ~/. cargo/git/db/
306+ ~/cargo/registry/index/
307+ ~/cargo/registry/cache/
308+ ~/cargo/git/db/
271309 contracts/target/
272310 key : ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('contracts/Cargo.lock') }}
273311 restore-keys : |
@@ -293,9 +331,9 @@ jobs:
293331 uses : actions/cache@v4
294332 with :
295333 path : |
296- ~/. cargo/registry/index/
297- ~/. cargo/registry/cache/
298- ~/. cargo/git/db/
334+ ~/cargo/registry/index/
335+ ~/cargo/registry/cache/
336+ ~/cargo/git/db/
299337 contracts/target/
300338 key : ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('contracts/Cargo.lock') }}
301339 restore-keys : |
@@ -321,9 +359,9 @@ jobs:
321359 uses : actions/cache@v4
322360 with :
323361 path : |
324- ~/. cargo/registry/index/
325- ~/. cargo/registry/cache/
326- ~/. cargo/git/db/
362+ ~/cargo/registry/index/
363+ ~/cargo/registry/cache/
364+ ~/cargo/git/db/
327365 contracts/target/
328366 key : ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('contracts/Cargo.lock') }}
329367 restore-keys : |
@@ -339,15 +377,47 @@ jobs:
339377 load-test :
340378 name : k6 Load Test
341379 runs-on : ubuntu-latest
380+ continue-on-error : true
381+ strategy :
382+ fail-fast : false
383+ matrix :
384+ scenario : [subscription, billing, contract]
342385 steps :
343386 - name : Checkout code
344387 uses : actions/checkout@v4
345388
346- - name : Run k6 Load Test
347- uses : grafana/k6-action@v0.5.1
389+ - name : Prepare reports directory
390+ run : mkdir -p load-tests/reports
391+
392+ - name : Install k6
393+ run : |
394+ sudo gpg -k
395+ sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg \
396+ --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
397+ echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" \
398+ | sudo tee /etc/apt/sources.list.d/k6.list
399+ sudo apt-get update
400+ sudo apt-get install -y k6
401+
402+ - name : Run k6 Load Test (${{ matrix.scenario }})
403+ run : k6 run load-tests/run.js --env SCENARIO=${{ matrix.scenario }} --quiet
404+
405+ - name : Rename report for this scenario
406+ if : always()
407+ run : |
408+ for ext in json md html; do
409+ if [ -f "load-tests/reports/summary.$ext" ]; then
410+ mv "load-tests/reports/summary.$ext" "load-tests/reports/${{ matrix.scenario }}.$ext"
411+ fi
412+ done
413+
414+ - name : Upload load test report
415+ if : always()
416+ uses : actions/upload-artifact@v4
348417 with :
349- filename : load-tests/run.js
350- flags : --env SCENARIO=subscription
418+ name : load-test-report-${{ matrix.scenario }}
419+ path : load-tests/reports/
420+ if-no-files-found : ignore
351421
352422 # ─────────────────────────────────────────────────────────
353423 # Bundle Size Monitoring
@@ -370,12 +440,24 @@ jobs:
370440 - name : Install dependencies
371441 run : npm ci --legacy-peer-deps
372442
443+ - name : Patch metro exports for @expo/cli compatibility
444+ run : |
445+ node -e "
446+ const fs=require('fs');
447+ const p='node_modules/metro/package.json';
448+ if(!fs.existsSync(p)) process.exit(0);
449+ const m=JSON.parse(fs.readFileSync(p,'utf8'));
450+ if(!m.exports||m.exports['./src/lib/TerminalReporter']) process.exit(0);
451+ m.exports['./src/lib/TerminalReporter']='./src/lib/TerminalReporter.js';
452+ fs.writeFileSync(p,JSON.stringify(m,null,2));
453+ console.log('Patched metro exports to add ./src/lib/TerminalReporter');
454+ "
455+
373456 - name : Check bundle size (PR)
374457 if : github.event_name == 'pull_request'
375- uses : andresz1/size-limit-action@v1
376- with :
377- github_token : ${{ secrets.GITHUB_TOKEN }}
378- build_script : ' npm run build'
458+ run : npx size-limit
459+ env :
460+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
379461
380462 - name : Build app
381463 if : github.event_name != 'pull_request'
@@ -392,6 +474,36 @@ jobs:
392474 name : bundle-size-report-${{ github.sha }}
393475 path : bundle-size-report.json
394476
477+ # ─────────────────────────────────────────────────────────
478+ # Performance Monitoring
479+ # ─────────────────────────────────────────────────────────
480+ performance :
481+ name : Performance Budget Check
482+ runs-on : ubuntu-latest
483+ steps :
484+ - name : Checkout code
485+ uses : actions/checkout@v4
486+
487+ - name : Setup Node.js
488+ uses : actions/setup-node@v4
489+ with :
490+ node-version : ${{ env.NODE_VERSION }}
491+ cache : ' npm'
492+
493+ - name : Cache node modules
494+ uses : actions/cache@v4
495+ id : cache-node-modules
496+ with :
497+ path : node_modules
498+ key : ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
499+
500+ - name : Install dependencies
501+ if : steps.cache-node-modules.outputs.cache-hit != 'true'
502+ run : npm ci --legacy-peer-deps
503+
504+ - name : Run performance benchmark
505+ run : npm run performance:benchmark
506+
395507 # ─────────────────────────────────────────────────────────
396508 # Merge Protection (only on PRs)
397509 # ─────────────────────────────────────────────────────────
@@ -413,6 +525,7 @@ jobs:
413525 rust-build,
414526 load-test,
415527 bundle-size,
528+ performance,
416529 ]
417530 steps :
418531 - name : All checks passed
@@ -439,6 +552,7 @@ jobs:
439552 rust-build,
440553 load-test,
441554 bundle-size,
555+ performance,
442556 ]
443557 steps :
444558 - name : Check for failures
@@ -457,8 +571,9 @@ jobs:
457571 [ "${{ needs.rust-tests.result }}" != "success" ] || \
458572 [ "${{ needs.rust-build.result }}" != "success" ] || \
459573 [ "${{ needs.load-test.result }}" != "success" ] || \
460- [ "${{ needs.bundle-size.result }}" != "success" ]; then
574+ [ "${{ needs.bundle-size.result }}" != "success" ] || \
575+ [ "${{ needs.performance.result }}" != "success" ]; then
461576 echo "One or more CI checks failed"
462577 exit 1
463578 fi
464- echo "All CI checks passed successfully!"
579+ echo "All CI checks passed successfully!"
0 commit comments