Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/gas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Gas Budget Regression Gate

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
gas-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Gas Regression Script
run: |
chmod +x scripts/gas-regression.sh
# Replace these with actual gas fetching commands in real usage
BASELINE_GAS=1000000
NEW_GAS=1040000
./scripts/gas-regression.sh $BASELINE_GAS $NEW_GAS
28 changes: 28 additions & 0 deletions scripts/gas-regression.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

if [ "$#" -ne 2 ]; then
echo "Usage: $0 <baseline_gas> <new_gas>"
exit 1
fi

BASELINE=$1
NEW=$2

echo "Comparing baseline gas ($BASELINE) with new gas ($NEW)..."

awk -v base="$BASELINE" -v new="$NEW" 'BEGIN {
if (base == 0) {
print "Baseline gas is 0. Cannot compute regression."
exit 1
}
diff = new - base
pct = (diff / base) * 100
printf "Gas change: %.2f%%\n", pct
if (pct > 5.0) {
print "Error: Gas regression exceeds 5% CPU/instruction budget!"
exit 1
}
print "Gas budget check passed."
exit 0
}'
Loading