-
Notifications
You must be signed in to change notification settings - Fork 176
144 lines (125 loc) · 4.74 KB
/
Copy pathperformance-ci.yml
File metadata and controls
144 lines (125 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Performance CI
on:
pull_request:
branches: [main]
push:
branches: [main]
env:
NODE_VERSION: '20'
jobs:
# ── 1. Frontend performance budget ──────────────────────────────────────────
performance-budget:
name: Frontend Performance Budget
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- name: Run performance budget check
run: npm run performance:ci
env:
# Point at the CI artifact if one was produced by a prior E2E run.
# Falls back gracefully when no report exists (validates config only).
PERFORMANCE_REPORT: ${{ github.workspace }}/artifacts/performance-report.json
- name: Upload performance budget config
if: always()
uses: actions/upload-artifact@v4
with:
name: performance-budget-${{ github.sha }}
path: performance-budget.json
retention-days: 30
# ── 2. Soroban gas benchmarks ────────────────────────────────────────────────
gas-benchmarks:
name: Gas Benchmarks (Soroban)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy, rustfmt
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contracts/target
key: cargo-${{ runner.os }}-${{ hashFiles('contracts/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Restore gas baseline
uses: actions/cache@v4
with:
path: gas-benchmarks/baseline.json
key: gas-baseline-${{ hashFiles('contracts/subscription/src/**/*.rs', 'contracts/types/src/**/*.rs') }}
restore-keys: |
gas-baseline-
- name: Run gas benchmarks
id: gas_bench
run: bash scripts/gas-benchmark.sh
env:
GAS_REGRESSION_THRESHOLD: '0.10'
COMMIT_SHA: ${{ github.sha }}
COMMIT_TIME: ${{ github.event.head_commit.timestamp }}
continue-on-error: true
- name: Save updated baseline (main branch only)
if: github.ref == 'refs/heads/main'
uses: actions/cache@v4
with:
path: gas-benchmarks/baseline.json
key: gas-baseline-${{ hashFiles('contracts/subscription/src/**/*.rs', 'contracts/types/src/**/*.rs') }}
- name: Upload gas benchmark artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: gas-benchmarks-${{ github.sha }}
path: |
gas-benchmarks/baseline.json
gas-benchmarks/trends.json
gas-benchmarks/gas_trend.svg
if-no-files-found: ignore
retention-days: 90
- name: Post gas benchmark results to PR
if: github.event_name == 'pull_request' && always()
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const trendsPath = 'gas-benchmarks/trends.json';
if (!fs.existsSync(trendsPath)) return;
const trends = JSON.parse(fs.readFileSync(trendsPath, 'utf8'));
const latest = trends[trends.length - 1];
if (!latest?.results) return;
const rows = Object.entries(latest.results)
.map(([fn, m]) => {
const cpu = m.instructions ?? 0;
return `| \`${fn}\` | ${cpu.toLocaleString()} |`;
})
.join('\n');
const body = [
'### ⛽ Gas Benchmark Results',
'',
'| Function | CPU Instructions |',
'|----------|-----------------|',
rows,
'',
`Commit: \`${latest.sha}\``,
].join('\n');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});
- name: Fail if gas regressions detected
if: steps.gas_bench.outcome == 'failure'
continue-on-error: true
run: |
echo "::warning::Gas benchmarks detected regressions exceeding the 10% threshold."
echo "Download the gas-benchmarks artifact to see the full report."