Skip to content

Auto add CICD label when PR author is a member or owner of flutter organization#4997

Open
gmackall wants to merge 13 commits intoflutter:mainfrom
gmackall:try_letting_ci_run_for_members
Open

Auto add CICD label when PR author is a member or owner of flutter organization#4997
gmackall wants to merge 13 commits intoflutter:mainfrom
gmackall:try_letting_ci_run_for_members

Conversation

@gmackall
Copy link
Copy Markdown
Member

@gmackall gmackall commented Mar 24, 2026

/// `OWNER` indicate the PR author belongs to the organization.
static bool _isOrgMember(PullRequest pr) {
final association = pr.authorAssociation;
return association == 'MEMBER' || association == 'OWNER';
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.

Are any of these valid:

COLLABORATOR, CONTRIBUTOR, FIRST_TIMER, FIRST_TIME_CONTRIBUTOR, MANNEQUIN, MEMBER, NONE, OWNER

I'm not sure what COLLABORATOR vs CONTRIBUTOR

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.

I think we want MEMBER or OWNER only here, as that maps to the flutter hackers group, as I understand

@jtmcdole
Copy link
Copy Markdown
Member

I can get some pull_request events so we can validate the collaborator field

await _addCICDForRollers(pullRequestEvent);
if (pullRequestEvent.changes != null &&
pullRequestEvent.changes!.base != null) {
await _addCICDForRollersAndMembers(pullRequestEvent);
Copy link
Copy Markdown
Member Author

@gmackall gmackall Mar 25, 2026

Choose a reason for hiding this comment

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

This is a slight behavior change, I made it this way because before the path for scheduling tests checked these conditions:
363e9cd#diff-4d5f5e21f5b7eda8e7775b9a678fb60bb6cfba3321799948fb2b9a55cefbe439L202-L206
And I figured it was also fine to apply those checks for the roller case. Let me know if not

@gmackall gmackall marked this pull request as ready for review March 26, 2026 00:02
@gmackall gmackall changed the title Auto schedule tests when PR author is a member of flutter organization Auto add CICD label when PR author is a member of flutter organization Mar 26, 2026
@gmackall gmackall changed the title Auto add CICD label when PR author is a member of flutter organization Auto add CICD label when PR author is a member or owner of flutter organization Mar 26, 2026
@gmackall gmackall requested a review from jtmcdole March 26, 2026 00:03
@jtmcdole jtmcdole requested a review from ievdokdm March 26, 2026 16:26
@jtmcdole
Copy link
Copy Markdown
Member

I checked the logs for the last 30 days matching the exact string:

protoPayload.line.logMessage =~ "\"author_association\":\"MEMBER\""
# or
protoPayload.line.logMessage =~ "\"author_association\":\"CONTRIBUTOR\""
# or
protoPayload.line.logMessage =~ "\"author_association\":\"OWNER\""
# or
protoPayload.line.logMessage =~ "\"author_association\":\"NONE\""
author log count
CONTRIBUTOR 31,057
NONE 9,583
MEMBER 5,037
OWNER 0

I think we should limit this to just MEMBER. I'm assuming @Piinks can confirm that "MEMBER" is the correct 'person with write access'?

@gmackall
Copy link
Copy Markdown
Member Author

I checked the logs for the last 30 days matching the exact string:

protoPayload.line.logMessage =~ "\"author_association\":\"MEMBER\""
# or
protoPayload.line.logMessage =~ "\"author_association\":\"CONTRIBUTOR\""
# or
protoPayload.line.logMessage =~ "\"author_association\":\"OWNER\""
# or
protoPayload.line.logMessage =~ "\"author_association\":\"NONE\""

author log count
CONTRIBUTOR 31,057
NONE 9,583
MEMBER 5,037
OWNER 0
I think we should limit this to just MEMBER. I'm assuming @Piinks can confirm that "MEMBER" is the correct 'person with write access'?

Yeah I figure if OWNER does matter it will matter for probably only 1 person. But I'm fine removing

@Piinks
Copy link
Copy Markdown
Contributor

Piinks commented Mar 26, 2026

I am not sure that MEMBER == folks with write access. There are Flutter GitHub org members without write access

@Piinks
Copy link
Copy Markdown
Contributor

Piinks commented Mar 26, 2026

Yeah, AFAICT, there are 426 people that are org members, and only 289 are flutter-hackers (our current equivalent to write access)

@gmackall
Copy link
Copy Markdown
Member Author

Yeah, AFAICT, there are 426 people that are org members, and only 289 are flutter-hackers (our current equivalent to write access)

Hmm can all of those people add labels to issues? Or are labels restricted by write access?

@jtmcdole
Copy link
Copy Markdown
Member

Ok, if that's the case, then we still need to build the "members with write access" list that I talked about before.

@Piinks
Copy link
Copy Markdown
Contributor

Piinks commented Mar 26, 2026

Hmm can all of those people add labels to issues? Or are labels restricted by write access?

Currently, only folks with write access can apply labels. 'Triage' access also allows people to apply labels, but we do not use the triage role currently.

@gmackall
Copy link
Copy Markdown
Member Author

gmackall commented Mar 26, 2026

When you say our "current equivalent to write access", that is mechanically enforced? I.e. there are members of https://github.com/orgs/flutter/people?query=role%3Aowner, which, if they tried, could not add labels?

I'm sort of confused how write access is conferred, is it somehow synched with an external list, or is it tied to a github property we can query?

@Piinks
Copy link
Copy Markdown
Contributor

Piinks commented Mar 26, 2026

It is enforced by Github, not anything bespoke. Owners can apply labels. We don't assign roles individually, we manage them through Github teams. Owner is a special case, it is separate from the read|triage|write|maintain|admin roles Github provides for permissions management.

https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization#permissions-for-each-role

I'm sort of confused how write access is conferred, is it somehow synched with an external list, or is it tied to a github property we can query?

We manage the 'write' role through the flutter-hackers Github team, which I think should be something that can be queried?

@gmackall
Copy link
Copy Markdown
Member Author

It is enforced by Github, not anything bespoke. Owners can apply labels. We don't assign roles individually, we manage them through Github teams. Owner is a special case, it is separate from the read|triage|write|maintain|admin roles Github provides for permissions management.

https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization#permissions-for-each-role

I'm sort of confused how write access is conferred, is it somehow synched with an external list, or is it tied to a github property we can query?

We manage the 'write' role through the flutter-hackers Github team, which I think should be something that can be queried?

It looks like we currently have logic already doing this for determining if the pr is actually approved

https://github.com/flutter/cocoon/blob/fa4caccb12b57bf8df8885ea2f7959a4431730d5/auto_submit/lib/validations/approval.dart#L49C57-L53

I will just use that logic here instead of the current author association check i have

///
/// Note that we catch here as the api returns a 404 if the user has no
/// membership in general or is not a member of the team.
Future<bool> isTeamMember(String team, String user, String org) async {
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.

I copied this from

Future<bool> isTeamMember(String team, String user, String org) async {

as there are duplicate github_service.darts and this one did not have the method. It may be good to de-dupe these at some point

) async {
final pr = pullRequestEvent.pullRequest!;
final slug = pr.base!.repo!.slug();
final author = pr.user!.login!;
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.

I double checked that this returns the author's user, and not the user of the person interacting with the PR:
https://pub.dev/documentation/github/latest/github/PullRequest/user.html

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.

Investigate allowing PRs from flutter-hackers to autorun ci

4 participants