Skip to content

Commit

Permalink
[BE] Runner determinator: Expect usernames to be prefixed with '@' (p…
Browse files Browse the repository at this point in the history
…ytorch#129246)

Expect the username in the runner rollover issue (pytorch/test-infra#5132) to be prefixed with a "@".

This will make typos way less likely since github's autocomplete/autoformating will help out

For now, I've updated the issue to have usernames both with and without the @ while this change rolls out

Testing:
Ran the script locally on both this issue and a new test issue and verified they both had the expected output:
```
(venv) (base) ➜  ~/pytorch git:(zainr/improve-get-workflow-type)
python .github/scripts/get_workflow_type.py --github-token github_pat_***  --github-issue 5132 --github-user ZainRizvi --github-branch "zainr/stuff"
{"label_type": "lf.", "message": "LF Workflows are enabled for ZainRizvi. Using LF runners."}
```
Pull Request resolved: pytorch#129246
Approved by: https://github.com/zxiiro, https://github.com/huydhn
  • Loading branch information
ZainRizvi authored and pytorchmergebot committed Jun 25, 2024
1 parent 533395e commit 4d04203
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/scripts/get_workflow_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def is_exception_branch(branch: str) -> bool:


def get_workflow_type(issue: Issue, username: str) -> Tuple[str, str]:
formatted_username = (
f"@{username}" # Add the @ symbol to match the format in the issue body
)

try:
user_list = issue.get_comments()[0].body.split()

Expand All @@ -60,7 +64,7 @@ def get_workflow_type(issue: Issue, username: str) -> Tuple[str, str]:
elif user_list[0] == "*":
MESSAGE = "LF Workflows are enabled for everyone. Using LF runners."
return WORKFLOW_LABEL_LF, MESSAGE
elif username in user_list:
elif formatted_username in user_list:
MESSAGE = f"LF Workflows are enabled for {username}. Using LF runners."
return WORKFLOW_LABEL_LF, MESSAGE
else:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/_runner-determinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ jobs:
def get_workflow_type(issue: Issue, username: str) -> Tuple[str, str]:
formatted_username = (
f"@{username}" # Add the @ symbol to match the format in the issue body
)
try:
user_list = issue.get_comments()[0].body.split()
Expand All @@ -108,7 +112,7 @@ jobs:
elif user_list[0] == "*":
MESSAGE = "LF Workflows are enabled for everyone. Using LF runners."
return WORKFLOW_LABEL_LF, MESSAGE
elif username in user_list:
elif formatted_username in user_list:
MESSAGE = f"LF Workflows are enabled for {username}. Using LF runners."
return WORKFLOW_LABEL_LF, MESSAGE
else:
Expand Down

0 comments on commit 4d04203

Please sign in to comment.