Skip to content

chore(deps): bump the github-actions group across 1 directory with 3 updates #829

chore(deps): bump the github-actions group across 1 directory with 3 updates

chore(deps): bump the github-actions group across 1 directory with 3 updates #829

Workflow file for this run

on:
pull_request:
name: Benchmark
permissions:
contents: read
issues: write
pull-requests: write
jobs:
bench:
if: ${{ !github.event.pull_request.head.repo.fork }}
name: Benchmark (${{ matrix.title }})
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- label: rls
title: RLS
bench_args: "-bench=BenchmarkRLS"
- label: other
title: Other
bench_args: "-bench=. -skip=BenchmarkRLS"
env:
BENCH_SIZES: 15000
steps:
- name: Install Go
uses: buildjet/setup-go@555ce355a95ff01018ffcf8fbbd9c44654db8374 # v5.0.2
with:
go-version: 1.26.x
cache: false
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Post "benchmark running" comment
uses: actions/github-script@v9
with:
script: |
const marker = '<!-- benchstat-${{ matrix.label }}-report -->';
const body = [
marker,
'Benchmark (${{ matrix.title }}) running.',
'',
`Base: \`${{ github.event.pull_request.base.sha }}\``,
`Head: \`${{ github.event.pull_request.head.sha }}\``,
'',
'This comment will be updated when benchmarks complete.',
].join('\n');
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});
const existing = comments.find(c => (c.body || '').includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
- name: Install benchstat
run: |
GOBIN="$PWD/.bin" go install golang.org/x/perf/cmd/benchstat@latest
echo "$PWD/.bin" >> "$GITHUB_PATH"
- name: Prepare base worktree
run: |
mkdir -p .bench
git worktree add .bench/base "${{ github.event.pull_request.base.sha }}"
# Override the base's bench package with HEAD's so both runs execute
# the same benchmark suite — only the implementation under test differs.
rm -rf .bench/base/bench && cp -r bench/ .bench/base/bench/
- name: Benchmark base
run: |
cd .bench/base
# benchstat recommends at least 10 runs to gather a statistically significant sample.
# We use -count=6 because -count=10 is extremely slow on github actions.
DUTY_BENCH_SIZES="${BENCH_SIZES}" \
go test ${{ matrix.bench_args }} -count=6 -timeout 20m \
github.com/flanksource/duty/bench | tee "$GITHUB_WORKSPACE/bench-base.txt"
- name: Benchmark head
run: |
# benchstat recommends at least 10 runs to gather a statistically significant sample.
# We use -count=6 because -count=10 is extremely slow on github actions.
DUTY_BENCH_SIZES="${BENCH_SIZES}" \
go test ${{ matrix.bench_args }} -count=6 -timeout 20m \
github.com/flanksource/duty/bench | tee bench-head.txt
- name: Compare
run: |
benchstat bench-base.txt bench-head.txt > benchstat.txt
# Generate the summary (ignore exit code here; we check it in the next step)
python3 .github/scripts/benchstat-summary.py benchstat.txt > bench-summary.md || true
{
echo "<!-- benchstat-${{ matrix.label }}-report -->"
echo "## Benchstat (${{ matrix.title }})"
echo ""
echo "Base: \`${{ github.event.pull_request.base.sha }}\`"
echo "Head: \`${{ github.event.pull_request.head.sha }}\`"
echo ""
cat bench-summary.md
echo ""
echo '<details>'
echo '<summary>Full benchstat output</summary>'
echo ""
echo '```text'
cat benchstat.txt
echo '```'
echo ""
echo '</details>'
} > bench-report.md
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-results-${{ matrix.label }}
path: |
bench-base.txt
bench-head.txt
benchstat.txt
bench-report.md
retention-days: 14
- name: Post report to PR
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('bench-report.md', 'utf8');
const marker = '<!-- benchstat-${{ matrix.label }}-report -->';
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});
const existing = comments.find(c => (c.body || '').includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
- name: Check for regressions
run: python3 .github/scripts/benchstat-summary.py --threshold 5 benchstat.txt > /dev/null