Skip to content

docs: add RC process checklist with sign-off, rollback, and release p… #21

docs: add RC process checklist with sign-off, rollback, and release p…

docs: add RC process checklist with sign-off, rollback, and release p… #21

Workflow file for this run

name: Benchmarks
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run benchmarks (bencher output)
run: cargo bench --bench benchmarks -- --output-format bencher 2>/dev/null | tee bench-output.txt
- name: Generate benchmark snapshot
shell: bash
run: |
set -euo pipefail
VERSION="$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')"
DATE="$(date -u '+%Y-%m-%d')"
TIMESTAMP="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
COMMIT="${{ github.sha }}"
COMMIT_SHORT="$(echo "${COMMIT}" | head -c 7)"
REF="${{ github.ref_name }}"
mkdir -p bench-results
JSON_FILE="bench-results/bench-snapshot-${VERSION}-${DATE}.json"
# --- Build structured JSON ---
{
echo "{"
echo " \"version\": \"${VERSION}\","
echo " \"date\": \"${DATE}\","
echo " \"timestamp\": \"${TIMESTAMP}\","
echo " \"commit\": \"${COMMIT}\","
echo " \"commit_short\": \"${COMMIT_SHORT}\","
echo " \"ref\": \"${REF}\","
echo " \"run_number\": ${{ github.run_number }},"
echo " \"rust_version\": \"$(rustc --version)\","
echo " \"os\": \"$(uname -s) $(uname -r)\","
echo " \"arch\": \"$(uname -m)\","
echo " \"benchmarks\": ["
FIRST=true
while IFS= read -r line; do
if [[ "${line}" =~ ^test[[:space:]]+(.+)[[:space:]]+\.\.\.[[:space:]]+bench:[[:space:]]+([0-9,]+)[[:space:]]+ns/iter[[:space:]]+\(\+/-[[:space:]]+([0-9,]+)\) ]]; then
NAME="${BASH_REMATCH[1]}"
NS="${BASH_REMATCH[2]//,/}"
DEV="${BASH_REMATCH[3]//,/}"
if [ "${FIRST}" = "true" ]; then
FIRST=false
else
echo ","
fi
printf ' {"name": "%s", "ns_per_iter": %s, "deviation": %s}' \
"${NAME}" "${NS}" "${DEV}"
fi
done < bench-output.txt
echo ""
echo " ]"
echo "}"
} > "${JSON_FILE}"
cp "${JSON_FILE}" bench-results/bench-latest.json
# --- Generate human-readable summary for PR / step summary ---
{
echo "# Benchmark Report"
echo ""
echo "- **Version:** ${VERSION}"
echo "- **Date:** ${DATE}"
echo "- **Commit:** [\`${COMMIT_SHORT}\`](https://github.com/${{ github.repository }}/commit/${COMMIT})"
echo "- **Ref:** \`${REF}\`"
echo "- **Rust:** $(rustc --version)"
echo "- **OS:** $(uname -s) $(uname -r) ($(uname -m))"
echo ""
echo "| Benchmark | ns/iter | ±deviation |"
echo "|-----------|--------:|----------:|"
while IFS= read -r line; do
if [[ "${line}" =~ ^test[[:space:]]+(.+)[[:space:]]+\.\.\.[[:space:]]+bench:[[:space:]]+([0-9,]+)[[:space:]]+ns/iter[[:space:]]+\(\+/-[[:space:]]+([0-9,]+)\) ]]; then
NAME="${BASH_REMATCH[1]}"
NS="${BASH_REMATCH[2]}"
DEV="${BASH_REMATCH[3]}"
echo "| ${NAME} | ${NS} | ${DEV} |"
fi
done < bench-output.txt
echo ""
echo "_Generated by CI run #${{ github.run_number }}_"
} > bench-results/bench-report.md
cat bench-results/bench-report.md
- name: Post benchmark summary
run: cat bench-results/bench-report.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: |
bench-output.txt
bench-results/
target/criterion/
retention-days: 90
- name: Compare with baseline (PR only)
if: github.event_name == 'pull_request'
shell: bash
run: |
set -euo pipefail
# Try to download the latest baseline from the default branch
echo "Checking for baseline benchmark data..."
# Use the artifact from this run as the current data
CURRENT="bench-results/bench-latest.json"
if [ ! -f "${CURRENT}" ]; then
echo "No current benchmark data found, skipping comparison."
exit 0
fi
# Extract current benchmarks into a simple comparison format
{
echo "## Benchmark Comparison"
echo ""
echo "Benchmarks from this PR (\`${{ github.head_ref }}\`):"
echo ""
echo "| Benchmark | ns/iter | ±deviation |"
echo "|-----------|--------:|----------:|"
# Parse from the JSON snapshot
python3 -c "
import json, sys
with open('${CURRENT}') as f:
data = json.load(f)
for b in data.get('benchmarks', []):
print(f'| {b[\"name\"]} | {b[\"ns_per_iter\"]:,} | {b[\"deviation\"]:,} |')
" 2>/dev/null || echo "_(Could not parse benchmark data)_"
echo ""
echo "> **Note:** Compare with the latest \`main\` branch run in the Actions tab for regression detection."
} >> "$GITHUB_STEP_SUMMARY"