-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
183 lines (164 loc) · 6.75 KB
/
Copy pathaction.yml
File metadata and controls
183 lines (164 loc) · 6.75 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: 'Atupa Gas Regression Check'
description: |
Automated multi-VM gas regression detection for EVM, Arbitrum Stylus, Solana, Starknet, and Stellar.
Runs `atupa diff` between two transactions, uploads SVG flamegraph and JSON artifacts,
and posts a sticky Markdown report to the Pull Request.
author: 'One Block'
branding:
icon: 'zap'
color: 'orange'
# ─── Inputs ─────────────────────────────────────────────────────────────────────
inputs:
base_tx:
description: 'Baseline transaction hash or signature (e.g. last commit on main)'
required: true
target_tx:
description: 'Target transaction hash or signature (e.g. current PR branch)'
required: true
rpc_url:
description: 'RPC endpoint for the target network'
required: false
default: 'http://localhost:8545'
protocol:
description: 'Optional: protocol-specific deep diff (aave | lido)'
required: false
default: ''
vm:
description: 'Explicit VM target runtime (evm | stylus | starknet | solana | stellar)'
required: false
default: ''
threshold:
description: 'Simple gas increase threshold % (overrides atupa.toml)'
required: false
default: ''
config:
description: 'Path to atupa.toml config file'
required: false
default: 'atupa.toml'
post_comment:
description: 'Post diff as a sticky PR comment (true | false)'
required: false
default: 'true'
upload_svg:
description: 'Upload the SVG flamegraph as a workflow artifact (true | false)'
required: false
default: 'true'
upload_json:
description: 'Upload the raw JSON trace reports for Atupa Studio (true | false)'
required: false
default: 'false'
# ─── Outputs ────────────────────────────────────────────────────────────────────
outputs:
diff_md_path:
description: 'Path to the generated Markdown diff report'
value: ${{ steps.diff.outputs.md_path }}
diff_svg_path:
description: 'Path to the generated SVG flamegraph'
value: ${{ steps.diff.outputs.svg_path }}
regression_detected:
description: 'true if a gas regression threshold was exceeded'
value: ${{ steps.diff.outputs.regression_detected }}
# ─── Steps ──────────────────────────────────────────────────────────────────────
runs:
using: 'composite'
steps:
# 1. Source-aware binary setup
# - If inside the Atupa repository, build from source and cache.
# - If in a consumer repository, install from crates.io.
- name: Setup Atupa Binary
shell: bash
run: |
if [ -f "${{ github.workspace }}/bin/atupa/Cargo.toml" ]; then
echo "🏠 Running inside Atupa repository — building from source…"
if [ -d "${{ github.workspace }}/studio" ]; then
echo "🎨 Building Atupa Studio frontend…"
cd "${{ github.workspace }}/studio" && npm install && npm run build && cd "${{ github.workspace }}"
fi
cargo build --release -p atupa
echo "${{ github.workspace }}/target/release" >> $GITHUB_PATH
elif command -v atupa &>/dev/null; then
echo "✅ atupa already installed: $(atupa --version)"
else
echo "📦 Installing atupa from crates.io…"
cargo install atupa --locked
fi
# 2. Run diff — capture exit code without failing immediately
- name: Run Atupa Diff
id: diff
shell: bash
run: |
PROTO_FLAG=""
if [ -n "${{ inputs.protocol }}" ]; then
PROTO_FLAG="--protocol ${{ inputs.protocol }}"
fi
VM_FLAG=""
if [ -n "${{ inputs.vm }}" ]; then
VM_FLAG="--vm ${{ inputs.vm }}"
fi
THRESHOLD_FLAG=""
if [ -n "${{ inputs.threshold }}" ]; then
THRESHOLD_FLAG="--threshold ${{ inputs.threshold }}"
fi
CONFIG_FLAG=""
if [ -f "${{ inputs.config }}" ]; then
CONFIG_FLAG="--config ${{ inputs.config }}"
fi
JSON_FLAG=""
if [ "${{ inputs.upload_json }}" = "true" ]; then
JSON_FLAG="--output json"
fi
# Run the diff, allow non-zero exit so we can post the comment before failing
atupa diff \
-r "${{ inputs.rpc_url }}" \
--base "${{ inputs.base_tx }}" \
--target "${{ inputs.target_tx }}" \
--markdown \
--svg \
$PROTO_FLAG \
$VM_FLAG \
$THRESHOLD_FLAG \
$CONFIG_FLAG \
$JSON_FLAG && REGRESSION=false || REGRESSION=true
# Discover output paths
BASE_CLEAN="${{ inputs.base_tx }}"
TARGET_CLEAN="${{ inputs.target_tx }}"
MD_PATH="artifacts/diff/${BASE_CLEAN:0:10}_vs_${TARGET_CLEAN:0:10}.md"
SVG_PATH="artifacts/diff/${BASE_CLEAN:0:10}_vs_${TARGET_CLEAN:0:10}.svg"
echo "md_path=${MD_PATH}" >> $GITHUB_OUTPUT
echo "svg_path=${SVG_PATH}" >> $GITHUB_OUTPUT
echo "regression_detected=${REGRESSION}" >> $GITHUB_OUTPUT
# 3. Upload SVG flamegraph as a workflow artifact
- name: Upload SVG Flamegraph
if: inputs.upload_svg == 'true' && always()
uses: actions/upload-artifact@v4
with:
name: atupa-flamegraph-${{ inputs.base_tx != '' && inputs.base_tx || 'base' }}
path: ${{ steps.diff.outputs.svg_path }}
if-no-files-found: warn
retention-days: 30
# 3.5 Upload JSON and Diff Artifacts for Atupa Studio
- name: Upload Trace & Diff Artifacts
if: inputs.upload_json == 'true' && always()
uses: actions/upload-artifact@v4
with:
name: atupa-artifacts-${{ inputs.base_tx != '' && inputs.base_tx || 'base' }}
path: artifacts/
if-no-files-found: warn
retention-days: 30
# 4. Post sticky PR comment (updates in-place on every push to PR)
- name: Post Sticky PR Comment
if: inputs.post_comment == 'true' && github.event_name == 'pull_request' && always()
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@v2
with:
header: atupa-gas-diff
path: ${{ steps.diff.outputs.md_path }}
# 5. Enforce regression gate
- name: Enforce Regression Gate
shell: bash
run: |
if [ "${{ steps.diff.outputs.regression_detected }}" = "true" ]; then
echo "❌ Atupa detected a gas regression exceeding configured limits. See the PR comment for details."
exit 1
fi
echo "✅ No gas regressions detected."