feat: added basic benchmark and ci skeleton #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Benchmarks | |
on: | |
pull_request: {} | |
jobs: | |
benchmark: | |
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT || '60') }} | |
strategy: | |
matrix: | |
kong_image: | |
- 'kong:3.10' | |
env: | |
KONG_ANONYMOUS_REPORTS: "off" | |
KONG_IMAGE: ${{ matrix.kong_image }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout current branch | |
uses: actions/checkout@v4 | |
with: | |
path: current | |
- name: Checkout main branch | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
ref: main | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: current/go.mod | |
- name: Install benchstat | |
run: go install golang.org/x/perf/cmd/benchstat@latest | |
- name: Setup Kong | |
run: make setup-kong | |
- name: Run benchmarks on main branch | |
working-directory: main | |
run: | | |
make benchmark-save | |
mv benchmark_results.txt ../benchmark_results_main.txt | |
- name: Run benchmarks on current branch | |
working-directory: current | |
run: | | |
make benchmark-save | |
mv benchmark_results.txt ../benchmark_results_current.txt | |
- name: Compare benchmark results | |
run: | | |
benchstat -confidence 0.6 benchmark_results_main.txt benchmark_results_current.txt > benchmark_comparison.txt | |
cat benchmark_comparison.txt | |
- name: Comment on PR | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const comparison = fs.readFileSync('benchmark_comparison.txt', 'utf8'); | |
const comment = `## Benchmark Comparison Results | |
\`\`\` | |
${comparison} | |
\`\`\` | |
`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: comment | |
}); |