Skip to content

Commit

Permalink
[ci] Look for any tags in issues before adding new tags (apache#10685)
Browse files Browse the repository at this point in the history
Previously this searched for a specific `cc @abc` line by itself before looking for people to tag. This led to a double-tag in apache#10679. The change here updates it to check for `@`-ed people anywhere in the PR/issue body and filters those out.
  • Loading branch information
driazati authored and altanh committed Apr 28, 2022
1 parent e30cf9f commit 71f2a2f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
41 changes: 38 additions & 3 deletions tests/python/ci/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ def run(type, data, check):
[temporary] opt-in: @person5
- something: @person1 @person2
- something3: @person1 @person2 @SOME1-ONE-
- something else @person1 @person2
- something else2: @person1 @person2
- something-else @person1 @person2
Expand Down Expand Up @@ -633,7 +634,7 @@ def run(type, data, check):
cc @person1 @person2 @person4"""
),
},
check="Everyone to cc is already cc'ed, no update needed",
check="No one to cc, exiting",
)

run(
Expand Down Expand Up @@ -671,7 +672,7 @@ def run(type, data, check):
cc @person1 @person2 @person4"""
),
},
check="Everyone to cc is already cc'ed, no update needed",
check="No one to cc, exiting",
)

run(
Expand All @@ -691,7 +692,7 @@ def run(type, data, check):
cc @person1 @person2 @person4"""
),
},
check="Everyone to cc is already cc'ed, no update needed",
check="No one to cc, exiting",
)

run(
Expand All @@ -714,6 +715,40 @@ def run(type, data, check):
check="Terminating since 1234 is a draft",
)

run(
type="ISSUE",
data={
"title": "[something] A title",
"number": 1234,
"user": {
"login": "person5",
},
"labels": [{"name": "something2"}],
"body": textwrap.dedent(
"""
`mold` and `lld` can be a much faster alternative to `ld` from gcc. We should modify our CMakeLists.txt to detect and use these when possible. cc @person1
cc @person4
"""
),
},
check="would have updated issues/1234 with {'body': '\\n`mold` and `lld` can be a much faster alternative to `ld` from gcc. We should modify our CMakeLists.txt to detect and use these when possible. cc @person1\\n\\ncc @person2 @person4\\n'}",
)

run(
type="ISSUE",
data={
"title": "[something3] A title",
"number": 1234,
"user": {
"login": "person5",
},
"labels": [{"name": "something2"}],
"body": "@person2 @SOME1-ONE-",
},
check="Dry run, would have updated issues/1234 with {'body': '@person2 @SOME1-ONE-\\n\\ncc @person1'}",
)


if __name__ == "__main__":
sys.exit(pytest.main([__file__] + sys.argv[1:]))
7 changes: 7 additions & 0 deletions tests/scripts/github_tag_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
from git_utils import git, GitHubRepo, parse_remote, find_ccs


GITHUB_NAME_REGEX = r"@[a-zA-Z0-9-]+"


def parse_line(line: str) -> Tuple[str, List[str]]:
line = line.lstrip(" -")
line = line.split()
Expand Down Expand Up @@ -244,6 +247,10 @@ def gen_cc_line(users):
to_cc = [teams.get(t, []) for t in tags]
to_cc = list(set(item for sublist in to_cc for item in sublist))
to_cc = [user for user in to_cc if user != author]
existing_tags = list(set(re.findall(GITHUB_NAME_REGEX, body)))
existing_tags = set(tag.replace("@", "") for tag in existing_tags)
print(f"Found existing tags: {existing_tags}")
to_cc = [user for user in to_cc if user not in existing_tags]
print("Users to cc based on labels", to_cc)

# Create the new PR/issue body
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/task_python_unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ run_pytest cython ${TVM_UNITTEST_TESTSUITE_NAME}-platform-minimal-test-1 tests/p
# Then run all unittests on both ctypes and cython.
run_pytest ctypes ${TVM_UNITTEST_TESTSUITE_NAME}-0 tests/python/unittest
run_pytest cython ${TVM_UNITTEST_TESTSUITE_NAME}-1 tests/python/unittest
run_pytest ctypes ${TVM_UNITTEST_TESTSUITE_NAME}-ci tests/python/ci

0 comments on commit 71f2a2f

Please sign in to comment.