Repository navigation
feat(ci): auto-label pull requests and fix their titles - #3855
spencer-tb wants to merge 13 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/bogota #3855 +/- ##
================================================
+ Coverage 94.99% 95.10% +0.11%
================================================
Files 673 673
Lines 40888 40904 +16
Branches 3769 3778 +9
================================================
+ Hits 38842 38903 +61
+ Misses 1429 1393 -36
+ Partials 617 608 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
danceratopz
left a comment
There was a problem hiding this comment.
Nice! The title fixes will make me sooo happy! I rarely use labels apart from as a quick visual orientation (I don't use them when filtering searches, for example), so I think it makes sense to reduce them.
Area: Labels
Priority: Important
Could we add the label set to the repo as .github/configs/labels.yaml, plus a small helper that applies it from the command line? The file then becomes the source of truth, and the migration becomes part of this PR instead of a separate script.
Today the 20 new labels only exist as names, spread over TYPES, AREAS and PROJECT_LABELS in the script, the issue templates, CONTRIBUTING.md and the regex in backport.yaml. Their colours and descriptions only exist in the migration script, which is not in this PR, and that script deletes 44 labels. With the file, reviewers see the end state before anything is deleted, and any collaborator or agent can restore the labels later with one command.
# Source of truth for the repository's labels.
# Apply with: uv run .github/scripts/labels.py [--apply] [--prune] [--check]
#
# `from` lists are for the one-off migration only. They name the old labels
# this label replaces: the first is renamed (keeping its assignments), the
# rest are merged into it and then deleted. Remove them once it has run.
# Type of change, matching the PR title type.
- name: feat
color: c5def5
description: An improvement or new feature, including new test cases.
from: [C-feat]
- name: fix
color: c5def5
description: A bug fix.
from: [C-bug]
- name: refactor
color: c5def5
description: Code changes that neither fix a bug nor add a feature.
from: [C-refactor]
- name: perf
color: c5def5
description: A performance optimization.
from: [C-perf]
- name: docs
color: c5def5
description: Documentation-only changes.
from: [C-docs, A-doc]
- name: test
color: c5def5
description: Changes to unit tests only.
from: [C-test]
- name: chore
color: c5def5
description: Routine maintenance, such as cleanups and dependency bumps.
from: [C-chore]
# Area, matching the PR title areas.
- name: spec
color: fbca04
description: The specification and its tooling (`src/`).
from: [A-spec-specs, A-spec-tools, A-spec-tests, A-spec-rpc]
- name: tests
color: fbca04
description: Consensus tests (`tests/`).
from: [A-tests]
- name: benchmark
color: fbca04
description: Benchmark tests and the benchmark framework.
from: [A-test-benchmark]
- name: framework
color: fbca04
description: The testing framework (`packages/`).
from:
- A-test-cli
- A-test-config
- A-test-devp2p
- A-test-eest
- A-test-evm-tools
- A-test-exceptions
- A-test-execution
- A-test-fixtures
- A-test-forks
- A-test-gentest
- A-test-logging
- A-test-make
- A-test-rpc
- A-test-specs
- A-test-tests
- A-test-types
- A-test-vm
- A-packaging
# Framework sub-areas, added by path next to `framework` (labels only, the
# title keeps `framework`).
- name: fill
color: fef2c0
description: The `fill` command and its plugins.
from: [A-test-fill]
- name: consume
color: fef2c0
description: The `consume` command and its plugins.
from: [A-test-consume]
- name: execute
color: fef2c0
description: The `execute` command and its plugins.
from: [A-test-execute]
- name: clients
color: fef2c0
description: Client CLI wrappers (`execution_testing.client_clis`).
from: [A-test-client-clis]
- name: ci
color: fbca04
description: CI, tooling and repository configuration.
from: [A-ci, A-tooling, A-deps]
# Project, from the PR's base branch.
- name: zkevm
color: 17a8e4
description: zkEVM project (`projects/zkevm*`).
from: [zkEVM]
- name: binary-trie
color: 5319e7
description: Binary trie project (`projects/binary-trie`, `projects/ubt`).
from: [C-binary]
# Issues only.
- name: tracker
color: c5def5
description: Meta-issue that tracks progress, for example of an EIP.
from: [C-tracker, C-eip]
- name: good first issue
color: 0e8a16
description: Good for newcomers.
from: [E-easy]
# Used by other workflows.
- name: stale
color: bfd4f2
description: The Issue/PR has not had any activity for 60 days. PRs will be automatically closed.
- name: backport forks/amsterdam
color: ac7fd3
description: On merge, bot cherry-picks the squash commit to `forks/amsterdam` and opens a PR. Squash only.
- name: backport forks/bogota
color: ac7fd3
description: On merge, bot cherry-picks the squash commit to `forks/bogota` and opens a PR. Squash only.
- name: backport benchmarks/amsterdam
color: ac7fd3
description: On merge, bot cherry-picks the squash commit to `benchmarks/amsterdam` and opens a PR. Squash only.
# Deleted by `--prune` (not listed above): E-hard, E-medium, P-urgent,
# P-high, P-medium, P-low, S-needs-attention, S-needs-discussion,
# C-question, C-hegota, Finalize Weld, help wanted, Interop, report,
# automated issue, Requires Backport.Rollout: once this PR is approved, run the helper with --apply from the PR branch (labels are repo wide, so the branch doesn't matter), so the new labels exist when the templates and the bot go live. Merge with the from lists still in the file, then remove them in a short follow-up PR. That keeps the old-to-new mapping in the history of forks/bogota, which a squash merge would lose if they were removed inside this PR.
Details
Helper behaviour, for example uv run .github/scripts/labels.py or a just labels recipe:
- Default: dry run. Print the creates, updates, renames, merges and deletes, change nothing.
--apply: create or update each label (gh label create --force). Rename the firstfromlabel if the new name does not exist yet, which keeps its assignments. For the otherfromlabels, add the new label to every issue and PR that has the old one (closed ones too), then delete the old label.--prune: delete labels the file does not list. A separate flag, so a normal run never deletes anything.--check: exit non-zero if the repo does not match the file. CI or a weekly job could run it, so drift is noticed.
Why a command and not a sync workflow: labels are repo wide, but workflows run per branch and this repo has many long lived branches, so two copies of the file could undo each other. Sync actions such as crazy-max/ghaction-github-labeler can rename but not merge, so the migration would still need a script.
Why run it before merge: the issue templates already use tracker, fix, spec and framework, and CONTRIBUTING.md links good first issue. None of these exist yet. If this merges before the migration runs, the templates apply nothing, and the bot's first label POST either creates a grey label with no description or fails, depending on whether the workflow token can create labels (I have not checked which). Running the helper first avoids both.
The mapping above is a guess from the current 64 labels and the PR description (16 renamed, 28 merged, 16 deleted, 4 kept). With the four framework sub-labels (inline comment on AREAS) it becomes 20 renamed, 24 merged, 16 deleted and 4 kept. Please swap in the colours and mapping from your migration script where they differ. A test could load the file and check that MANAGED_LABELS is a subset of its names, so the script and the file stay in step.
backport labels are added by hand when a new branch needs backports. With --prune, a new one has to be added to the file first.
| def title_areas(touched: list[str]) -> list[str]: | ||
| """ | ||
| Return the areas a title names for the touched areas. | ||
|
|
||
| Name the code areas, or `ci` when no code is touched. Docs-only | ||
| changes name no area. | ||
| """ | ||
| return [area for area in touched if area in CODE_AREAS] or touched |
There was a problem hiding this comment.
Area: Bot
Priority: Question
Is it intended that any changed file adds its area to the title, even a one-line edit? Then squash commits for focused PRs can end up with long area lists.
In a rules-only dry run of this script on the last 25 merged PRs into forks/bogota, 19 titles changed. Most were the expected rename to the new area names. Two gained an area from a tiny edit:
- chore(tests): remove fourteen consensus test skips #3795
chore(tests): remove fourteen consensus test skipsbecamechore(spec,tests,framework): ..., withspecfrom a one-line deletion intests/json_loader/helpers/exceptional_test_patterns.py. - perf(test-fill, test-forks): cut per-test and collection overhead #3785
perf(test-fill, test-forks): cut per-test and collection overheadbecameperf(spec,framework): ..., withspecfrom two added lines insrc/ethereum_spec_tools/utils.py.
Related: ci is dropped from the title and the labels whenever code is also touched. So a PR that changes a pull_request_target workflow together with packages/ gets no ci label, and workflow changes can't be found by label.
Details
If this is the trade-off we want (complete over short), it may be enough to say in CONTRIBUTING.md that the bot replaces the areas in the title. One alternative: keep the author's areas in the title when they are all valid and all touched, and use the full set of touched areas for the labels. That gives up the one-to-one match between title and labels that the PR aims for, so it's a design call.
Dry run, run by a reviewing agent with ANTHROPIC_API_KEY unset: uv run --script .github/scripts/pr_title_and_labels.py --pr <n> --dry-run for each of the 25 most recent PRs from gh pr list --state merged --base forks/bogota. All 25 ran without errors, and none needed a rules-only rewrite.
There was a problem hiding this comment.
Thanks! Yes, complete over short is the trade-off we want, so CONTRIBUTING.md now says the areas come from every touched file even through a one-line change, and ci stays as a label next to code areas in 010b28b.
| about: Report that the documentation is wrong or incomplete | ||
| title: '' | ||
| labels: C-bug, A-doc | ||
| labels: fix |
There was a problem hiding this comment.
Area: Issue templates
Priority: Minor
Could this template use docs instead of fix? With only fix, documentation reports look like any other bug report, since documentation has no area label.
The old template used C-bug, A-doc, so documentation issues could be filtered. docs is also the type the fixing PR would get (docs: ...), so it matches the title convention.
Details
labels: docs (or labels: docs, fix if bug reports should all carry fix). The other templates map cleanly: fix, spec for specification bugs and fix, framework for tooling problems.
There was a problem hiding this comment.
Yeah, I think docs are better here.
| "feature": "feat", | ||
| } | ||
|
|
||
| AREAS = ("spec", "tests", "benchmark", "framework", "ci") |
There was a problem hiding this comment.
Area: Labels
Priority: Normal
Could we keep four framework sub-labels: fill, consume, execute and clients? The bot would add them by path, next to framework, and the title would keep framework only.
They are among the most used of the old framework labels (A-test-fill 49 PRs, A-test-client-clis 48, A-test-consume 40, A-test-execute 21), and they make it easier to find work in the parts of the framework that change most.
Details
Paths, under packages/testing/src/execution_testing/:
cli/pytest_commands/plugins/filler/→fillcli/pytest_commands/plugins/consume/→consumecli/pytest_commands/plugins/execute/→executeclient_clis/→clients
They would join MANAGED_LABELS, so the bot removes them when a PR stops touching those paths. With the copy_labels_pattern suggestion in backport.yaml, backport PRs pick them up with no further change. The labels file in the review body already includes them, each with from: [A-test-<name>]. This is an exception to labels matching the title one to one, kept to labels only so titles stay short.
PR counts from gh api search/issues -f q="repo:ethereum/execution-specs is:pr label:<label>". For comparison, A-test-specs and A-test-forks have 23 each, so the cut-off is a judgement call.
There was a problem hiding this comment.
Thanks! Added fill, consume, execute and clients by path in 010b28b, as labels only so the title keeps framework.
| # Carry the labels `pr-title-and-labels.yaml` manages over to the | ||
| # backport PR. The action excludes labels matching `label_pattern`, | ||
| # so the `backport …` trigger label is never copied (no re-backport | ||
| # loop). | ||
| copy_labels_pattern: '^(feat|fix|refactor|perf|docs|test|chore|spec|tests|benchmark|framework|ci|zkevm|binary-trie)$' |
There was a problem hiding this comment.
Area: CI
Priority: Minor
Could we copy every label except stale here, instead of listing the 14 names? It copies the same labels today and needs no updates when labels change.
| # Carry the labels `pr-title-and-labels.yaml` manages over to the | |
| # backport PR. The action excludes labels matching `label_pattern`, | |
| # so the `backport …` trigger label is never copied (no re-backport | |
| # loop). | |
| copy_labels_pattern: '^(feat|fix|refactor|perf|docs|test|chore|spec|tests|benchmark|framework|ci|zkevm|binary-trie)$' | |
| # Carry every label except `stale` over to the backport PR. The | |
| # action excludes labels matching `label_pattern`, so the | |
| # `backport …` trigger label is never copied (no re-backport loop). | |
| copy_labels_pattern: '^(?!stale$)' |
The action builds the pattern with JavaScript's new RegExp, so the lookahead works, and it already skips labels matching label_pattern, so backport … labels are never copied. After the label cleanup a PR only has bot labels, stale and backport labels, so the result is the same as the list, including any sub-labels we add.
Details
korthout/backport-action at 2e830a1d: main.ts:129 builds source_labels_pattern from label_pattern, and backport.ts:276-278 copies a label only if it matches copy_labels_pattern and not that pattern. Checked with node: ^(?!stale$) matches feat, framework and binary-trie, and not stale.
If we want the labels file to drive this instead, a step can build the pattern with yq from labels marked managed: true and pass it as ${{ steps.labels.outputs.pattern }}. The bot could then read MANAGED_LABELS from the same file.
|
Thanks! Added |
|
Thanks, Spencer! I think this is in a good place. Could you raise it in today's team meeting to get a temperature check on the new labels? We also need to agree how we roll it out, since the label migration has to run before we merge. I'm holding off on approving for now, so it doesn't get merged by accident before those steps are done. As I understand it, they are:
Happy to chat it through when you have time. |
Description
We have 64 labels today. This brings that down to 20, plus
staleand the three backport labels, for 24 in total. Fewer labels should make it easier to find work and keep PRs organised. The bot handles the routine title and label updates.feat,fix,refactor,perf,docs,test,chorespec,tests,benchmark,framework,cifill,consume,execute,clientszkevm,binary-trietracker,good first issueHow it works
The bot runs when a PR is opened, reopened, updated, retargeted or marked ready for review. It works out the areas from the changed files, even a one-line change, and puts them in the title. A title such as
fix(spec,tests): reject invalid blocksgets the labelsfix,specandtests. To keep titles short, only the labels carrycinext to a code area and the framework sub-areas.Valid types and descriptions are kept. If the title has no recognised type, Claude suggests one and a short description. Simple rules take over if Claude fails or no API key is set. Project labels come from the target branch; other labels are left alone.
It uses
pull_request_targetwithout running PR code. If GitHub cuts off the file list, the bot keeps any areas already named in the title or labels.Labels file and rollout
The labels are defined in
.github/configs/labels.yaml..github/scripts/labels.pysyncs the repository with it: a dry run by default,--applyto make the changes,--pruneto delete labels the file does not list and--checkto fail on drift.We need agreement on the labels. Once this is approved,
uv run .github/scripts/labels.py --apply --pruneruns before the merge, so the labels exist when the templates and the bot go live. Thefromlists stay in the file for the merge and are removed in a short follow-up, which keeps the old-to-new mapping in the history.Today's dry run renames 20 labels, combines 24 into the new names, deletes 16 unlisted labels and keeps 4. For example,
C-bugbecomesfix, and theA-spec-*labels becomespec. This updates labels on all affected issues and PRs, including closed ones. Replacements are added before old labels are deleted. If a new name already exists, the assignments are combined.An admin can add
ANTHROPIC_API_KEYto enable Claude. The bot works without it. Existing PR titles are updated when the workflow next runs on them.Cost
Claude should cost about $0.30 a month at recent activity levels: 196 PRs from 17 September to 16 October 2026, about 3% needing a rewrite, and an estimated $0.05 each. Larger prompts or repeated rewrites can cost more; pricing is per token. Without the key, there is no API cost. Standard GitHub-hosted runner time is free for public repositories.
Related Issues or PRs
N/A.
Checklist
just staticpasses, and all 165 CI script tests pass.