Skip to content

Add workflow to auto-label PRs with plugin labels and assign dominant-plugin milestone#2525

Closed
sarthak-19 wants to merge 1 commit into
WordPress:trunkfrom
sarthak-19:Feat/prerenderer_until_script
Closed

Add workflow to auto-label PRs with plugin labels and assign dominant-plugin milestone#2525
sarthak-19 wants to merge 1 commit into
WordPress:trunkfrom
sarthak-19:Feat/prerenderer_until_script

Conversation

@sarthak-19

@sarthak-19 sarthak-19 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Closes : #2484

Summary

This PR implements automated plugin labelling and milestone assignment for pull requests in the WordPress Performance monorepo, as requested in the linked issue.

Changes

.github/workflows/auto-label-milestone.yml (new file)

A pull_request_target workflow that runs on every PR opened, synchronize, and reopened event against trunk, release/**, and feature/** branches.

Label synchronisation

  • Fetches all files changed in the PR via the GitHub API (paginated).
  • Maps each changed path under plugins/<slug>/ to its corresponding [Plugin] … label using a hardcoded slug → label table derived from each plugin's Plugin Name header.
  • Adds any plugin labels not yet present on the PR.
  • Removes plugin labels that are currently on the PR but no longer correspond to a changed path (e.g. after a force-push that drops plugin-specific changes).

Milestone assignment

  • Counts changed lines (additions + deletions) per plugin to identify the dominant plugin.
  • Finds the open milestone whose title starts with <dominant-plugin-slug> (convention: embed-optimizer n.e.x.t).
  • Assigns that milestone to the PR, replacing the previous one if the dominant plugin has changed.

The full slug → label mapping:

Plugin folder Label
auto-sizes [Plugin] Enhanced Responsive Images
dominant-color-images [Plugin] Image Placeholders
embed-optimizer [Plugin] Embed Optimizer
image-prioritizer [Plugin] Image Prioritizer
optimization-detective [Plugin] Optimization Detective
performance-lab [Plugin] Performance Lab
speculation-rules [Plugin] Speculative Loading
view-transitions [Plugin] View Transitions
web-worker-offloading [Plugin] Web Worker Offloading
webp-uploads [Plugin] Modern Image Formats

bin/plugin/commands/changelog.js (updated)

Implements the bonus changelog enhancement described in the issue.

  • Adds PLUGIN_SLUG_TO_LABEL_MAP constant (same mapping as the workflow).
  • Adds an optional --plugin-label / -l CLI argument. When omitted the plugin label is automatically derived from the milestone title by extracting the leading slug (e.g. embed-optimizer n.e.x.tembed-optimizer[Plugin] Embed Optimizer).
  • Adds fetchCrossPluginPullRequests() which queries the GitHub API for closed, merged PRs that carry the plugin label and are assigned to any currently-open milestone.
  • Updates fetchAllPullRequests() to merge cross-plugin PRs into the primary result set, deduplicating by PR number. This ensures a PR that touches embed-optimizer and image-prioritizer but was milestoned under embed-optimizer n.e.x.t will also appear in the image-prioritizer changelog automatically.

Use of AI Tools

I used copilot for scoping and PoA and documentation.

@westonruter

Copy link
Copy Markdown
Member

@sarthak-19 thanks for the PR, but one is already open for this: #2513

Please review that PR and suggest any changes.

@westonruter westonruter closed this Jun 8, 2026
@sarthak-19

Copy link
Copy Markdown
Contributor Author

@westonruter Sure, but as mentioned here : #2513 (comment)

This PR only addresses half of the issue. Could we open a separate PR for the Assign Milestone part, or would you prefer to handle both fixes in a single PR?

I tried to cover the whole issue.
Should I just add the feedback or we'll handle the rest of the issue separately ?

@westonruter

Copy link
Copy Markdown
Member

Ah, ok. Yeah, let's first get that PR reciewed and merged. The. We can follow up with a PR that assigns the milestone. The milestone is trickier

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add workflow to automatically add plugin labels (and assign milestone)

2 participants