Skip to content

fix(contrib): resolve slog.Default() lazily to respect LOG_LEVEL=debug #109

fix(contrib): resolve slog.Default() lazily to respect LOG_LEVEL=debug

fix(contrib): resolve slog.Default() lazily to respect LOG_LEVEL=debug #109

Workflow file for this run

# Copyright 2026 CloudBlue LLC
# SPDX-License-Identifier: Apache-2.0
name: Benchmark
on:
pull_request:
branches:
- master
- 'release/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
outputs:
code: ${{ steps.check.outputs.code }}
steps:
- name: Checkout action
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .github/actions
sparse-checkout-cone-mode: false
- name: Detect code changes
id: check
uses: ./.github/actions/detect-code-changes
benchmark:
name: Benchmark Comparison
needs: [changes]
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout PR
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache-dependency-path: |
go.sum
sdk/go.sum
plugins/contrib/go.sum
- name: Install benchstat
# golang.org/x/perf does not publish semver tags; pin to a pseudo-version
# for reproducible benchmark output. Update deliberately when needed.
run: go install golang.org/x/perf/cmd/benchstat@v0.0.0-20260211190930-8161c38c6cdc
- name: Run benchmarks on PR
run: go test -run='^$' -bench=. -benchmem -count=6 ./... > benchmark-pr.txt
- name: Checkout base branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.base_ref }}
path: base
- name: Run benchmarks on base
run: |
cd base
go work init . ./sdk 2>/dev/null || true
# Guard: skip comparison if base branch benchmarks don't compile or don't exist.
# This can happen when a merged PR changed an API signature but the bench
# file on the base branch still uses the old signature.
if go test -list 'Benchmark.*' ./... 2>/dev/null | grep -q 'Benchmark'; then
if go test -run='^$' -bench=. -benchmem -count=6 ./... > ../benchmark-base.txt 2>&1; then
echo "Base benchmarks completed successfully."
else
echo "⚠ Base branch benchmarks failed to run (likely API change). Skipping comparison."
echo "SKIP_COMPARE=true" >> $GITHUB_ENV
fi
else
echo "No benchmarks found on base branch. Skipping comparison."
echo "SKIP_COMPARE=true" >> $GITHUB_ENV
fi
- name: Compare benchmarks
if: env.SKIP_COMPARE != 'true'
run: |
echo "## Benchmark Comparison" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "benchstat compares base branch vs PR. Look for statistically significant changes (p < 0.05)." >> $GITHUB_STEP_SUMMARY
echo "Results marked with \`~\` are not statistically significant." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
benchstat benchmark-base.txt benchmark-pr.txt >> $GITHUB_STEP_SUMMARY 2>&1 || true
echo '```' >> $GITHUB_STEP_SUMMARY