Skip to content
Open
Show file tree
Hide file tree
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
45 changes: 45 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Dependabot opens pull requests that move what this repository pins: the
# actions in .github/workflows (pinned by commit, with the version in a
# comment, which Dependabot keeps), the direct dependencies' pins in
# uv.lock, and the image's base. These version updates come monthly, one
# pull request per ecosystem. With Dependabot security updates on (a
# repository setting), a pull request also comes as soon as an advisory
# names a version pinned here.
#
# Each waits a week after a release before proposing it: a release that
# was compromised, or broken, is usually pulled within days.
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
groups:
actions:
patterns: ["*"]

# uv.lock alone. pyproject.toml's lower bounds are floors that CI installs
# and tests (the floors job), so they move by hand, with a reason.
# Version updates cover the direct dependencies, Dependabot's default.
- package-ecosystem: uv
directory: /
schedule:
interval: monthly
versioning-strategy: lockfile-only
cooldown:
default-days: 7
groups:
python:
patterns: ["*"]

# The Dockerfile's base image, tag and digest together. Its tag names the
# uv it ships, so this moves the image's uv too; the uv the workflows
# install is setup-uv's `version`, which Dependabot does not read.
- package-ecosystem: docker
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
79 changes: 43 additions & 36 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
# *does* gate merges is tests/test_performance.py, which counts operations
# rather than seconds and lives in the ordinary test job.
#
# Its own file rather than a job in publish.yml: at the `ci` tier this takes
# the better part of an hour, and hanging that off the release graph would
# either delay the PyPI publish or paint the release run red for a report.
# publish.yml starts it, by a dispatch from the tag, once a release is out:
# PyPI has the version and the release page exists. Up to 0.17.10 every tag
# pushed started it, beside publish.yml, so a tag publish.yml refused still
# had its results committed to main. Its own file rather than a job in
# publish.yml: at the `ci` tier this takes the better part of an hour, and
# hanging that off the release graph would hold the release run open, or
# paint it red, for a report.
name: Benchmark

on:
push:
tags: ["*"]
workflow_dispatch:
inputs:
tier:
Expand All @@ -21,16 +23,17 @@ on:
options: [smoke, ci, large]
default: ci
publish:
description: Commit the results to docs/ on main
description: Push the results to a branch, for a pull request into main
type: boolean
default: false

concurrency:
group: benchmark-${{ github.ref }}
cancel-in-progress: true

# None by default: the repository's default token can write. The job that
# measures reads; only the job that commits the results can write.
# None by default: a job that names no permissions gets the repository's
# default token. The job that measures reads; only the job that pushes the
# results can write.
permissions: {}

jobs:
Expand All @@ -55,7 +58,7 @@ jobs:
persist-credentials: false

# No cache: what is restored here would run in the job that produces
# the numbers committed to main.
# the numbers published in docs/.
- uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
with:
version: "0.13.1"
Expand Down Expand Up @@ -99,36 +102,44 @@ jobs:
# with nothing to compare it against says very little. The page is
# already served by Pages from docs/, so this needs no extra machinery.
#
# The results go to a branch, benchmark/<ref>, for a pull request into
# main. Up to 0.17.10 this job pushed to main itself, unreviewed, which
# the ruleset planned for main refuses. It cannot open the pull request:
# the repository lets no workflow open or approve one, and one opened by
# this token would start no checks. So it links the pull request to open,
# in the run's summary. Merge it before the next release: that release's
# "vs previous" and history read docs/benchmarks/ on main.
#
# This job holds the write token, so it installs nothing: the report is
# the standard library and benchmarks/ from main, and results.json is read
# as data. It renders its own summary rather than take the one above.
publish:
name: Commit the results to docs/
name: Push the results for a pull request
needs: [benchmark]
# A pushed tag, or a dispatch that asks. A dispatch from a tag that does
# not ask must not overwrite that release's results with another tier.
if: needs.benchmark.outputs.measured == 'true' && (github.event_name == 'push' || inputs.publish)
# A dispatch that asks, as publish.yml's does. One that does not ask must
# not overwrite a release's results with another tier.
if: needs.benchmark.outputs.measured == 'true' && inputs.publish
runs-on: ubuntu-latest
# 15 for the commit, and the 30 the notes step may wait for the release.
timeout-minutes: 45
timeout-minutes: 15
continue-on-error: true
permissions:
contents: write # push to main, and edit the release notes
contents: write # push the results' branch, and edit the release notes
steps:
# A tag build is on a detached HEAD; the page belongs on main. The
# credentials stay for the push, and nothing here is uploaded.
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: main
fetch-depth: 0
persist-credentials: true # zizmor: ignore[artipacked] it pushes to main
persist-credentials: true # zizmor: ignore[artipacked] it pushes the results' branch

- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: benchmark-results
path: ${{ runner.temp }}/results

- name: Publish to docs
- name: Push the results to a branch
id: push
env:
REF_NAME: ${{ github.ref_name }}
run: |
Expand All @@ -140,33 +151,29 @@ jobs:
if git diff --cached --quiet; then
echo "nothing to publish"; exit 0
fi
git commit -m "Benchmark results for $REF_NAME [skip ci]"
# Another job may have landed on main in the meantime.
for _ in 1 2 3; do
if git push origin main; then exit 0; fi
git pull --rebase origin main
done
echo "could not push benchmark results"; exit 1
branch="benchmark/$REF_NAME"
git switch -c "$branch"
# No [skip ci]: the pull request's checks must run before it merges.
git commit -m "Benchmark results for $REF_NAME"
# A re-run replaces what an earlier run pushed.
git push --force origin "HEAD:refs/heads/$branch"
url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/main...$branch?expand=1"
echo "::notice title=Benchmark results::open a pull request from $branch: $url"
echo "The results are on \`$branch\`: [open a pull request into main]($url)." >> "$GITHUB_STEP_SUMMARY"

# Best effort, and last. publish.yml creates the release once PyPI has
# the version, normally before this job gets here, but only by 7 to 13
# minutes (0.17.4 to 0.17.6): slow tests or a re-run in Publish would
# leave no release yet. So it waits up to 30 minutes for one; a failed
# publish leaves none. The docs page is authoritative either way, and
# re-running this job appends the summary later.
# Best effort, and last. publish.yml starts this run once the release
# exists; a dispatch from a tag with no release skips this. The docs
# page is authoritative either way, and re-running this job replaces
# the summary.
- name: Append to the release notes
if: github.ref_type == 'tag'
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
for _ in $(seq 30); do
gh release view "$TAG" >/dev/null 2>&1 && break
sleep 60
done
gh release view "$TAG" >/dev/null 2>&1 || {
echo "no release for $TAG after 30 minutes; skipping"; exit 0
echo "no release for $TAG; skipping"; exit 0
}
gh release view "$TAG" --json body -q .body > "$RUNNER_TEMP/body.md"
# Idempotent: replace any block this job wrote before.
Expand Down
Loading
Loading