Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ on:
description: 'Version label to record (defaults to package.json version)'
required: false
type: string
commit:
description: 'Commit the refreshed README back to the default branch'
open_pr:
description: 'Open a PR with the refreshed README'
required: false
default: true
type: boolean

permissions:
contents: write
pull-requests: write

jobs:
benchmark:
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
LAMBDA_API_VERSION: ${{ steps.ver.outputs.value }}
run: node run.js --md results/RESULTS.md --json results/raw.json --update-readme

# Keep the committed README Prettier-clean so the push doesn't break main's CI.
# Keep the committed README Prettier-clean so the PR doesn't fail main's CI.
- name: Format README
run: npx --yes prettier@2 --write README.md

Expand All @@ -74,15 +75,48 @@ jobs:
- name: Add results to job summary
run: cat benchmarks/results/RESULTS.md >> "$GITHUB_STEP_SUMMARY"

- name: Commit refreshed README
if: ${{ github.event_name == 'release' || inputs.commit }}
# The default branch doesn't accept direct pushes, so the refreshed README goes
# through a PR. Each run gets its own branch so concurrent or repeated runs never
# clobber one another.
- name: Open PR with refreshed README
if: ${{ github.event_name == 'release' || inputs.open_pr }}
env:
GH_TOKEN: ${{ github.token }}
BASE: ${{ github.event.repository.default_branch }}
VERSION: ${{ steps.ver.outputs.value }}
run: |
if git diff --quiet -- README.md; then
echo 'README.md unchanged — nothing to commit'
echo 'README.md unchanged — no PR needed'
exit 0
fi

LABEL="${VERSION:-manual}"
BRANCH="benchmarks/refresh-${LABEL}-${GITHUB_RUN_ID}"

git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git switch -c "$BRANCH"
git add README.md
git commit -m 'docs: update benchmark results [skip ci]'
git push origin HEAD:${{ github.event.repository.default_branch }}
git commit -m "docs: update benchmark results for ${LABEL}"
git push origin "$BRANCH"

{
echo "Automated refresh of the Benchmarks section of the README, generated by [this run](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})."
echo
echo "Version label: \`${LABEL}\` · Trigger: \`${GITHUB_EVENT_NAME}\`"
echo
echo "Perf numbers come from a shared GitHub-hosted runner and are noisy between runs, so treat"
echo "movement within a few percent as noise rather than a regression."
echo
echo '<details><summary>Full results</summary>'
echo
cat benchmarks/results/RESULTS.md
echo
echo '</details>'
} > /tmp/pr-body.md

gh pr create \
--base "$BASE" \
--head "$BRANCH" \
--title "docs: refresh benchmark results for ${LABEL}" \
--body-file /tmp/pr-body.md
Loading