Skip to content

feat(ci): auto-label pull requests and fix their titles - #3855

Open
spencer-tb wants to merge 13 commits into
ethereum:forks/bogotafrom
spencer-tb:ci/auto-pr-labels
Open

spencer-tb wants to merge 13 commits into
ethereum:forks/bogotafrom
spencer-tb:ci/auto-pr-labels

Conversation

@spencer-tb

@spencer-tb spencer-tb commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Description

We have 64 labels today. This brings that down to 20, plus stale and 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.

Used for Labels
Type of change feat, fix, refactor, perf, docs, test, chore
Area spec, tests, benchmark, framework, ci
Framework sub-area (labels only) fill, consume, execute, clients
Project zkevm, binary-trie
Issues tracker, good first issue

How 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 blocks gets the labels fix, spec and tests. To keep titles short, only the labels carry ci next 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_target without 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.py syncs the repository with it: a dry run by default, --apply to make the changes, --prune to delete labels the file does not list and --check to fail on drift.

We need agreement on the labels. Once this is approved, uv run .github/scripts/labels.py --apply --prune runs before the merge, so the labels exist when the templates and the bot go live. The from lists 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-bug becomes fix, and the A-spec-* labels become spec. 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_KEY to 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

@spencer-tb
spencer-tb marked this pull request as ready for review October 17, 2026 16:55
@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.10%. Comparing base (067505d) to head (8e21ba8).
⚠️ Report is 68 commits behind head on forks/bogota.

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     
Flag Coverage Δ
unittests 95.10% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LouisTsai-Csie
LouisTsai-Csie self-requested a review October 19, 2026 06:42

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 first from label if the new name does not exist yet, which keeps its assignments. For the other from labels, 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.

Comment thread .github/scripts/pr_title_and_labels.py Outdated
Comment on lines +198 to +205
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think docs are better here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, switched to docs in ee6022c.

"feature": "feat",
}

AREAS = ("spec", "tests", "benchmark", "framework", "ci")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/ → fill
  • cli/pytest_commands/plugins/consume/ → consume
  • cli/pytest_commands/plugins/execute/ → execute
  • client_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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added fill, consume, execute and clients by path in 010b28b, as labels only so the title keeps framework.

Comment thread .github/workflows/backport.yaml Outdated
Comment on lines +59 to +63
# 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)$'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, applied in ee6022c.

@spencer-tb

Copy link
Copy Markdown
Member Author

Thanks! Added .github/configs/labels.yaml and .github/scripts/labels.py (dry run by default, --apply, --prune, --check) in 96137dd, with a test that MANAGED_LABELS and the issue template labels are all in the file. Today's dry run gives 20 renames, 24 merges, 16 deletes with --prune and 4 kept, and I'll follow your rollout: --apply --prune once approved, merge with the from lists, then drop them in a follow-up.

@danceratopz danceratopz added C-feat Category: an improvement or new feature A-ci Area: Continuous Integration labels Nov 12, 2026
@danceratopz

Copy link
Copy Markdown
Member

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:

  1. Dry run and check the output: uv run .github/scripts/labels.py --prune
  2. Disable the backport workflow: gh workflow disable backport.yaml -R ethereum/execution-specs. The merges add labels to merged PRs with a personal token, which sends labeled events, so 7 merged PRs with a backport label (feat(test-rpc): add eth_getTransactionReceipt batching #3298, perf(test-forks): memoize per-fork gas costs #3303, refactor(test-rpc): unify batch request chunking #3327, perf(test-rpc, test-fill): fetch a block's receipts with single eth_getBlockReceipts #3345, perf(test-type): cache ecrecover and optimize function calls to ecrecover #3431, feat(spec-tests, spec-tools): run fork-transition fixtures through EELS #3564, fix(test-specs): keep a failing block's fixture to one defect #3698) would be backported again.
  3. Apply: uv run .github/scripts/labels.py --apply --prune. If a gh call fails, just run it again.
  4. Re-enable it: gh workflow enable backport.yaml -R ethereum/execution-specs
  5. Check: uv run .github/scripts/labels.py --check
  6. Merge with the from lists still in, then drop them in a follow-up.

Happy to chat it through when you have time.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci Area: Continuous Integration C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants