Skip to content

Fix all linting issues across Go and Rust codebases #233

Fix all linting issues across Go and Rust codebases

Fix all linting issues across Go and Rust codebases #233

Workflow file for this run

name: Benchmarks
on:
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
benchmark:
name: Run Benchmarks
runs-on: qnap-nas
steps:
- name: Checkout PR branch
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true
- name: Run benchmarks on PR branch
run: |
go test -bench=. -benchmem -count=5 ./internal/agent/router/... 2>&1 | tee new.bench
go test -bench=. -benchmem -count=5 ./internal/agent/lb/... 2>&1 | tee -a new.bench
go test -bench=. -benchmem -count=5 ./internal/agent/policy/... 2>&1 | tee -a new.bench
- name: Checkout main branch
run: |
git stash
git checkout origin/main
- name: Run benchmarks on main branch
run: |
go test -bench=. -benchmem -count=5 ./internal/agent/router/... 2>&1 | tee old.bench
go test -bench=. -benchmem -count=5 ./internal/agent/lb/... 2>&1 | tee -a old.bench
go test -bench=. -benchmem -count=5 ./internal/agent/policy/... 2>&1 | tee -a old.bench
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Compare benchmarks
id: compare
run: |
benchstat old.bench new.bench > benchstat.txt
cat benchstat.txt
# Check for significant regressions (>10% slower)
if grep -E '~\s+[0-9]+\.[0-9]+%\s+\+' benchstat.txt; then
echo "::warning::Potential performance regression detected"
fi
# Save output for PR comment
{
echo 'BENCHSTAT<<EOF'
cat benchstat.txt
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const benchstat = fs.readFileSync('benchstat.txt', 'utf8');
const body = `## 📊 Benchmark Results
\`\`\`
${benchstat}
\`\`\`
| Symbol | Meaning |
|--------|---------|
| ~ | No significant change |
| + | Performance improved |
| - | Performance regressed |
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
old.bench
new.bench
benchstat.txt
retention-days: 30