Skip to content

Conversation

monutwilio
Copy link
Contributor

@monutwilio monutwilio commented Aug 28, 2025

This PR adds a step in label-pr workflow to assign a reviewer for PRs assigned to stratconn team and renames the workflow to configure-pr.

Summary

This PR introduce changes to assign reviewers to PR based on below logic.

  1. Triggers: Runs when non-draft PRs are opened or draft PRs are marked "Ready for review"
  2. Skip Conditions: Skips if PR already has users assigned; external contributors get joe-ayoub-segment as PR reviewer.
  3. Team Detection: Uses github.rest.pulls.listRequestedReviewers() to find teams already assigned by GitHub's CODEOWNERS evaluation.
  4. Special Rules: Strategic-connections-team PRs from non-team members go to joe-ayoub-segment; all other teams get 2 reviewers from the target team
  5. Selection: Assigns 2 consecutive team members (excluding PR author) using random starting position with wrap-around.

Testing

Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

@monutwilio monutwilio marked this pull request as ready for review August 28, 2025 09:46
const script = require('./scripts/github-action/assign-reviewer.js')
await script({github, context, core})
- name: Log Skip Reviewer Assign Reaso
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- name: Log Skip Reviewer Assign Reaso
- name: Log Skip Reviewer Assign Reason

Comment on lines 40 to 44
if (teamToAssign !== 'strategic-connections-team') {
core.setOutput('skip', 'true')
core.setOutput('reason', `only assigning for strategic-connections-team, found ${teamToAssign || 'none'}`)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the team is actions:mappingkit? How do they get notified of the change? Will they be monitoring the repo themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewrote the logic based on codeowners file.

return
}

// Get a random team member
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @monutwilio
Apart from mappingkit (and possibly some other components) the All PRs raised by people outside of our immediate team should be reviewed by me.
So there's no need to assign those PRs randomly.

My role is to work with 3rd party Developers to build Integrations, so I need those PRs to be assigned to me. Currently I do this assignment manually.

Copy link
Contributor

@varadarajan-tw varadarajan-tw left a comment

Choose a reason for hiding this comment

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

This looks great! ✨ . Left couple of questions.

Comment on lines 29 to 31
if (allLabels.includes('actions:mappingkit')) {
return 'libraries-web-team'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be our team or https://github.com/orgs/segmentio/teams/data-activation-namer team. Not libraries-web-team

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might conflict with .CODEOWNERS. should we instead look at codeowners for the team and then pick one or two from that team. we can have a special rule for @joe-ayoub-segment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change, now the flow is.

  1. When the PR status is not draft (either open as ready for review, or changed the status from draft), github assigns the team as reviewer based on .codeowners file.
  2. We pick the assigned team to assign the reviewers.


if (teams.length > 0) {
// Return the first team
const selectedTeam = teams[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Sill this always select libraries-web-team for browser-destinations? Is this deliberate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can edit codeowners file if we want to assign browser-destination PRs to some other team.

@joe-ayoub-segment
Copy link
Contributor

Looks good to me. Is it possible to put a summary at the top as a comment to explain the entire flow? @varadarajan-tw is that OK or bad practice?

@monutwilio monutwilio merged commit 97e3ce9 into main Sep 11, 2025
12 checks passed
@monutwilio monutwilio deleted the assign_PR_reviewer_stratconn branch September 11, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants