-
Notifications
You must be signed in to change notification settings - Fork 179
145 lines (114 loc) · 4.39 KB
/
Copy pathperformance.yml
File metadata and controls
145 lines (114 loc) · 4.39 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
145
name: Performance Regression Detection
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
CARGO_TERM_COLOR: always
jobs:
performance-regression:
name: Detect Performance Regressions
if: false
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Add WASM target
run: rustup target add wasm32-unknown-unknown
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-perf-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-contract
run: cargo install cargo-contract --locked
- name: Run performance benchmarks
id: run_benchmarks
run: |
echo Running performance benchmarks...
# Run security tests as performance benchmark substitute
cargo test --package propchain-tests --lib -- --nocapture 2>&1 | tee benchmark_output.txt
echo Benchmarks complete.
continue-on-error: true
- name: Run load tests (light config)
id: run_load_tests
run: |
echo Running load tests...
# Run security tests to validate system stability
cargo test --package propchain-tests --lib 2>&1 | tee load_test_output.txt
echo Load tests complete.
continue-on-error: true
- name: Run load tests (light config)
id: run_load_tests
run: |
echo "Running load tests..."
cargo test --package propchain-tests \
load_test_concurrent_registration_light \
stress_test_mass_registration \
--release -- --nocapture 2>&1 | tee load_test_output.txt
echo "Load tests complete."
continue-on-error: true
- name: Parse and evaluate benchmark results
id: evaluate
run: |
echo "Evaluating performance results..."
# Load the baseline thresholds
BASELINE_FILE=".github/perf-baseline.json"
if [ ! -f "$BASELINE_FILE" ]; then
echo "No baseline file found at $BASELINE_FILE — skipping regression check."
echo "regression_detected=false" >> $GITHUB_OUTPUT
exit 0
fi
# Read baseline values
MAX_REGISTER_MS=$(jq '.thresholds.max_register_ms' $BASELINE_FILE)
MAX_TRANSFER_MS=$(jq '.thresholds.max_transfer_ms' $BASELINE_FILE)
MAX_QUERY_MS=$(jq '.thresholds.max_query_ms' $BASELINE_FILE)
MIN_SUCCESS_RATE=$(jq '.thresholds.min_success_rate_percent' $BASELINE_FILE)
MIN_OPS_PER_SEC=$(jq '.thresholds.min_ops_per_second' $BASELINE_FILE)
echo "Baseline thresholds loaded:"
echo " Max register time: ${MAX_REGISTER_MS}ms"
echo " Max transfer time: ${MAX_TRANSFER_MS}ms"
echo " Max query time: ${MAX_QUERY_MS}ms"
echo " Min success rate: ${MIN_SUCCESS_RATE}%"
echo " Min ops/second: ${MIN_OPS_PER_SEC}"
REGRESSION=false
# Check if benchmarks produced failures
if grep -q "FAILED" benchmark_output.txt 2>/dev/null; then
echo "❌ REGRESSION DETECTED: One or more performance benchmarks failed!"
REGRESSION=true
else
echo "✅ Benchmark tests passed."
fi
# Check if load tests produced failures
if grep -q "FAILED" load_test_output.txt 2>/dev/null; then
echo "❌ REGRESSION DETECTED: One or more load tests failed!"
REGRESSION=true
else
echo "✅ Load tests passed."
fi
echo "regression_detected=$REGRESSION" >> $GITHUB_OUTPUT
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: performance-results-${{ github.sha }}
path: |
benchmark_output.txt
load_test_output.txt
retention-days: 30
- name: Fail pipeline if regression detected
if: steps.evaluate.outputs.regression_detected == 'true'
run: |
echo ❌ Performance regression detected. Pipeline failed.
exit 1