You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/10 16:13:09 UTC
[GitHub] [tvm] driazati opened a new pull request, #12361: [ci][tvmbot] Trigger GitHub Actions after merging
driazati opened a new pull request, #12361:
URL: https://github.com/apache/tvm/pull/12361
This fixes the issue where merging from GitHub Actions (i.e. with the
default `GITHUB_TOKEN`) doesn't trigger post-merge GitHub Actions on
the commit it creates in `main`. Instead these jobs are triggered
manually by a call to the Actions API after the merge has taken place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati merged pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
driazati merged PR #12361:
URL: https://github.com/apache/tvm/pull/12361
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #12361:
URL: https://github.com/apache/tvm/pull/12361#discussion_r961193815
##########
tests/python/ci/test_utils.py:
##########
@@ -30,12 +31,41 @@ class TempGit:
def __init__(self, cwd):
self.cwd = cwd
+ # Jenkins git is too old and doesn't have 'git init --initial-branch'
+ self.run("init", stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.run("checkout", "-b", "main", stderr=subprocess.PIPE)
+ self.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
def run(self, *args, **kwargs):
+ """
+ Run a git command based on *args
+ """
proc = subprocess.run(
["git"] + list(args), encoding="utf-8", cwd=self.cwd, check=False, **kwargs
)
if proc.returncode != 0:
raise RuntimeError(f"git command failed: '{args}'")
return proc
+
+
+def run_script(command: List[Any], check: bool = True, **kwargs):
Review Comment:
`check_output` is kind of the same but not really, it enables stdout catching all the time but here usually we want to print out both streams on an error and none if its fine (unless otherwise requested)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
driazati commented on PR #12361:
URL: https://github.com/apache/tvm/pull/12361#issuecomment-1211083237
@tvm-bot rerun
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] github-actions[bot] commented on pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12361:
URL: https://github.com/apache/tvm/pull/12361#issuecomment-1211240890
<!---docs-bot-comment-->
Built docs for commit 23f2113d7acd6e1205141bf5f6ca694310446c95 can be found [here](https://pr-docs.tlcpack.ai/PR-12361/3/docs/index.html).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #12361:
URL: https://github.com/apache/tvm/pull/12361#discussion_r961195178
##########
tests/python/ci/test_tvmbot.py:
##########
@@ -37,167 +36,262 @@
""".strip()
-TEST_DATA = {
- "successful-merge": {
- "number": 10786,
- "filename": "pr10786-merges.json",
- "expected": SUCCESS_EXPECTED_OUTPUT,
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Everything is fine so this PR will merge",
- },
- "no-request": {
- "number": 10786,
- "filename": "pr10786-nottriggered.json",
- "expected": "Command 'do something else' did not match anything",
- "comment": "@tvm-bot do something else",
- "user": "abc",
- "detail": "A PR for which the mergebot runs but no merge is requested",
- },
- "bad-ci": {
- "number": 10786,
- "filename": "pr10786-badci.json",
- "expected": "Cannot merge, these CI jobs are not successful on",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR which failed CI and cannot merge",
- },
- "old-review": {
- "number": 10786,
- "filename": "pr10786-oldreview.json",
- "expected": "Cannot merge, did not find any approving reviews",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR with passing CI and approving reviews on an old commit so it cannot merge",
- },
- "missing-job": {
- "number": 10786,
- "filename": "pr10786-missing-job.json",
- "expected": "Cannot merge, missing expected jobs",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "PR missing an expected CI job and cannot merge",
- },
- "invalid-author": {
- "number": 10786,
- "filename": "pr10786-invalid-author.json",
- "expected": "Failed auth check 'collaborators', quitting",
- "comment": "@tvm-bot merge",
- "user": "not-abc",
- "detail": "Merge requester is not a committer and cannot merge",
- },
- "unauthorized-comment": {
- "number": 11244,
- "filename": "pr11244-unauthorized-comment.json",
- "expected": "Failed auth check 'collaborators'",
- "comment": "@tvm-bot merge",
- "user": "not-abc2",
- "detail": "Check that a merge comment not from a CONTRIBUTOR is rejected",
- },
- "no-review": {
- "number": 11267,
- "filename": "pr11267-no-review.json",
- "expected": "Cannot merge, did not find any approving reviews from users with write access",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request without any reviews is rejected",
- },
- "changes-requested": {
- "number": 10786,
- "filename": "pr10786-changes-requested.json",
- "expected": "Cannot merge, found [this review]",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with a 'Changes Requested' review is rejected",
- },
- "co-authors": {
- "number": 10786,
- "filename": "pr10786-co-authors.json",
- "expected": "Co-authored-by: Some One <so...@email.com>",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with co-authors generates the correct commit message",
- },
- "rerun-ci": {
- "number": 11442,
- "filename": "pr11442-rerun-ci.json",
- "expected": "Rerunning ci with",
- "comment": "@tvm-bot rerun",
- "user": "abc",
- "detail": "Start a new CI job",
- },
- "ignore-jobs": {
- "number": 10786,
- "filename": "pr10786-ignore-jobs.json",
- "expected": "Dry run, would have merged",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Ignore GitHub Actions jobs that don't start with CI / ",
- },
-}
+class _TvmBotTest:
Review Comment:
its not totally abstract since the standard `load_data` actually does something, I went ahead and deleted the no-op implementations in the subclasses
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
driazati commented on PR #12361:
URL: https://github.com/apache/tvm/pull/12361#issuecomment-1219828254
> possible to unit test this one? curious about bypassing the subsequent auth checks here.
it should have been an OR instead of an AND for the checks hence the break but i’ll add some better testing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on a diff in pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #12361:
URL: https://github.com/apache/tvm/pull/12361#discussion_r961766090
##########
tests/python/ci/test_utils.py:
##########
@@ -30,12 +31,41 @@ class TempGit:
def __init__(self, cwd):
self.cwd = cwd
+ # Jenkins git is too old and doesn't have 'git init --initial-branch'
+ self.run("init", stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.run("checkout", "-b", "main", stderr=subprocess.PIPE)
+ self.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
def run(self, *args, **kwargs):
+ """
+ Run a git command based on *args
+ """
proc = subprocess.run(
["git"] + list(args), encoding="utf-8", cwd=self.cwd, check=False, **kwargs
)
if proc.returncode != 0:
raise RuntimeError(f"git command failed: '{args}'")
return proc
+
+
+def run_script(command: List[Any], check: bool = True, **kwargs):
Review Comment:
ah fair enough. somehow i thought there was an extra arg for this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] github-actions[bot] commented on pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12361:
URL: https://github.com/apache/tvm/pull/12361#issuecomment-1233274227
It has been a while since this PR was updated, @gigiblender @Mousius @areusch please leave a review or address the outstanding comments. @driazati if this PR is still a work in progress, please [convert it to a draft](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#converting-a-pull-request-to-a-draft) until it is ready for review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on a diff in pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #12361:
URL: https://github.com/apache/tvm/pull/12361#discussion_r961195178
##########
tests/python/ci/test_tvmbot.py:
##########
@@ -37,167 +36,262 @@
""".strip()
-TEST_DATA = {
- "successful-merge": {
- "number": 10786,
- "filename": "pr10786-merges.json",
- "expected": SUCCESS_EXPECTED_OUTPUT,
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Everything is fine so this PR will merge",
- },
- "no-request": {
- "number": 10786,
- "filename": "pr10786-nottriggered.json",
- "expected": "Command 'do something else' did not match anything",
- "comment": "@tvm-bot do something else",
- "user": "abc",
- "detail": "A PR for which the mergebot runs but no merge is requested",
- },
- "bad-ci": {
- "number": 10786,
- "filename": "pr10786-badci.json",
- "expected": "Cannot merge, these CI jobs are not successful on",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR which failed CI and cannot merge",
- },
- "old-review": {
- "number": 10786,
- "filename": "pr10786-oldreview.json",
- "expected": "Cannot merge, did not find any approving reviews",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR with passing CI and approving reviews on an old commit so it cannot merge",
- },
- "missing-job": {
- "number": 10786,
- "filename": "pr10786-missing-job.json",
- "expected": "Cannot merge, missing expected jobs",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "PR missing an expected CI job and cannot merge",
- },
- "invalid-author": {
- "number": 10786,
- "filename": "pr10786-invalid-author.json",
- "expected": "Failed auth check 'collaborators', quitting",
- "comment": "@tvm-bot merge",
- "user": "not-abc",
- "detail": "Merge requester is not a committer and cannot merge",
- },
- "unauthorized-comment": {
- "number": 11244,
- "filename": "pr11244-unauthorized-comment.json",
- "expected": "Failed auth check 'collaborators'",
- "comment": "@tvm-bot merge",
- "user": "not-abc2",
- "detail": "Check that a merge comment not from a CONTRIBUTOR is rejected",
- },
- "no-review": {
- "number": 11267,
- "filename": "pr11267-no-review.json",
- "expected": "Cannot merge, did not find any approving reviews from users with write access",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request without any reviews is rejected",
- },
- "changes-requested": {
- "number": 10786,
- "filename": "pr10786-changes-requested.json",
- "expected": "Cannot merge, found [this review]",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with a 'Changes Requested' review is rejected",
- },
- "co-authors": {
- "number": 10786,
- "filename": "pr10786-co-authors.json",
- "expected": "Co-authored-by: Some One <so...@email.com>",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with co-authors generates the correct commit message",
- },
- "rerun-ci": {
- "number": 11442,
- "filename": "pr11442-rerun-ci.json",
- "expected": "Rerunning ci with",
- "comment": "@tvm-bot rerun",
- "user": "abc",
- "detail": "Start a new CI job",
- },
- "ignore-jobs": {
- "number": 10786,
- "filename": "pr10786-ignore-jobs.json",
- "expected": "Dry run, would have merged",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Ignore GitHub Actions jobs that don't start with CI / ",
- },
-}
+class _TvmBotTest:
Review Comment:
its not totally abstract since the standard `load_data` actually does something
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] areusch commented on a diff in pull request #12361: [ci][tvmbot] Trigger GitHub Actions after merging
Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #12361:
URL: https://github.com/apache/tvm/pull/12361#discussion_r961098378
##########
tests/python/ci/test_tvmbot.py:
##########
@@ -37,167 +36,262 @@
""".strip()
-TEST_DATA = {
- "successful-merge": {
- "number": 10786,
- "filename": "pr10786-merges.json",
- "expected": SUCCESS_EXPECTED_OUTPUT,
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Everything is fine so this PR will merge",
- },
- "no-request": {
- "number": 10786,
- "filename": "pr10786-nottriggered.json",
- "expected": "Command 'do something else' did not match anything",
- "comment": "@tvm-bot do something else",
- "user": "abc",
- "detail": "A PR for which the mergebot runs but no merge is requested",
- },
- "bad-ci": {
- "number": 10786,
- "filename": "pr10786-badci.json",
- "expected": "Cannot merge, these CI jobs are not successful on",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR which failed CI and cannot merge",
- },
- "old-review": {
- "number": 10786,
- "filename": "pr10786-oldreview.json",
- "expected": "Cannot merge, did not find any approving reviews",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR with passing CI and approving reviews on an old commit so it cannot merge",
- },
- "missing-job": {
- "number": 10786,
- "filename": "pr10786-missing-job.json",
- "expected": "Cannot merge, missing expected jobs",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "PR missing an expected CI job and cannot merge",
- },
- "invalid-author": {
- "number": 10786,
- "filename": "pr10786-invalid-author.json",
- "expected": "Failed auth check 'collaborators', quitting",
- "comment": "@tvm-bot merge",
- "user": "not-abc",
- "detail": "Merge requester is not a committer and cannot merge",
- },
- "unauthorized-comment": {
- "number": 11244,
- "filename": "pr11244-unauthorized-comment.json",
- "expected": "Failed auth check 'collaborators'",
- "comment": "@tvm-bot merge",
- "user": "not-abc2",
- "detail": "Check that a merge comment not from a CONTRIBUTOR is rejected",
- },
- "no-review": {
- "number": 11267,
- "filename": "pr11267-no-review.json",
- "expected": "Cannot merge, did not find any approving reviews from users with write access",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request without any reviews is rejected",
- },
- "changes-requested": {
- "number": 10786,
- "filename": "pr10786-changes-requested.json",
- "expected": "Cannot merge, found [this review]",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with a 'Changes Requested' review is rejected",
- },
- "co-authors": {
- "number": 10786,
- "filename": "pr10786-co-authors.json",
- "expected": "Co-authored-by: Some One <so...@email.com>",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with co-authors generates the correct commit message",
- },
- "rerun-ci": {
- "number": 11442,
- "filename": "pr11442-rerun-ci.json",
- "expected": "Rerunning ci with",
- "comment": "@tvm-bot rerun",
- "user": "abc",
- "detail": "Start a new CI job",
- },
- "ignore-jobs": {
- "number": 10786,
- "filename": "pr10786-ignore-jobs.json",
- "expected": "Dry run, would have merged",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Ignore GitHub Actions jobs that don't start with CI / ",
- },
-}
+class _TvmBotTest:
+ number = 10786
Review Comment:
consider NUMBER =?
##########
tests/python/ci/test_utils.py:
##########
@@ -30,12 +31,41 @@ class TempGit:
def __init__(self, cwd):
self.cwd = cwd
+ # Jenkins git is too old and doesn't have 'git init --initial-branch'
+ self.run("init", stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.run("checkout", "-b", "main", stderr=subprocess.PIPE)
+ self.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
def run(self, *args, **kwargs):
+ """
+ Run a git command based on *args
+ """
proc = subprocess.run(
["git"] + list(args), encoding="utf-8", cwd=self.cwd, check=False, **kwargs
)
if proc.returncode != 0:
raise RuntimeError(f"git command failed: '{args}'")
return proc
+
+
+def run_script(command: List[Any], check: bool = True, **kwargs):
Review Comment:
i thought subprocess.check_output did this, does that work?
##########
tests/python/ci/test_tvmbot.py:
##########
@@ -37,167 +36,262 @@
""".strip()
-TEST_DATA = {
- "successful-merge": {
- "number": 10786,
- "filename": "pr10786-merges.json",
- "expected": SUCCESS_EXPECTED_OUTPUT,
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Everything is fine so this PR will merge",
- },
- "no-request": {
- "number": 10786,
- "filename": "pr10786-nottriggered.json",
- "expected": "Command 'do something else' did not match anything",
- "comment": "@tvm-bot do something else",
- "user": "abc",
- "detail": "A PR for which the mergebot runs but no merge is requested",
- },
- "bad-ci": {
- "number": 10786,
- "filename": "pr10786-badci.json",
- "expected": "Cannot merge, these CI jobs are not successful on",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR which failed CI and cannot merge",
- },
- "old-review": {
- "number": 10786,
- "filename": "pr10786-oldreview.json",
- "expected": "Cannot merge, did not find any approving reviews",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR with passing CI and approving reviews on an old commit so it cannot merge",
- },
- "missing-job": {
- "number": 10786,
- "filename": "pr10786-missing-job.json",
- "expected": "Cannot merge, missing expected jobs",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "PR missing an expected CI job and cannot merge",
- },
- "invalid-author": {
- "number": 10786,
- "filename": "pr10786-invalid-author.json",
- "expected": "Failed auth check 'collaborators', quitting",
- "comment": "@tvm-bot merge",
- "user": "not-abc",
- "detail": "Merge requester is not a committer and cannot merge",
- },
- "unauthorized-comment": {
- "number": 11244,
- "filename": "pr11244-unauthorized-comment.json",
- "expected": "Failed auth check 'collaborators'",
- "comment": "@tvm-bot merge",
- "user": "not-abc2",
- "detail": "Check that a merge comment not from a CONTRIBUTOR is rejected",
- },
- "no-review": {
- "number": 11267,
- "filename": "pr11267-no-review.json",
- "expected": "Cannot merge, did not find any approving reviews from users with write access",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request without any reviews is rejected",
- },
- "changes-requested": {
- "number": 10786,
- "filename": "pr10786-changes-requested.json",
- "expected": "Cannot merge, found [this review]",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with a 'Changes Requested' review is rejected",
- },
- "co-authors": {
- "number": 10786,
- "filename": "pr10786-co-authors.json",
- "expected": "Co-authored-by: Some One <so...@email.com>",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with co-authors generates the correct commit message",
- },
- "rerun-ci": {
- "number": 11442,
- "filename": "pr11442-rerun-ci.json",
- "expected": "Rerunning ci with",
- "comment": "@tvm-bot rerun",
- "user": "abc",
- "detail": "Start a new CI job",
- },
- "ignore-jobs": {
- "number": 10786,
- "filename": "pr10786-ignore-jobs.json",
- "expected": "Dry run, would have merged",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Ignore GitHub Actions jobs that don't start with CI / ",
- },
-}
+class _TvmBotTest:
Review Comment:
confirming, is this an abstract base class?
##########
tests/python/ci/test_tvmbot.py:
##########
@@ -37,167 +36,262 @@
""".strip()
-TEST_DATA = {
- "successful-merge": {
- "number": 10786,
- "filename": "pr10786-merges.json",
- "expected": SUCCESS_EXPECTED_OUTPUT,
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Everything is fine so this PR will merge",
- },
- "no-request": {
- "number": 10786,
- "filename": "pr10786-nottriggered.json",
- "expected": "Command 'do something else' did not match anything",
- "comment": "@tvm-bot do something else",
- "user": "abc",
- "detail": "A PR for which the mergebot runs but no merge is requested",
- },
- "bad-ci": {
- "number": 10786,
- "filename": "pr10786-badci.json",
- "expected": "Cannot merge, these CI jobs are not successful on",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR which failed CI and cannot merge",
- },
- "old-review": {
- "number": 10786,
- "filename": "pr10786-oldreview.json",
- "expected": "Cannot merge, did not find any approving reviews",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR with passing CI and approving reviews on an old commit so it cannot merge",
- },
- "missing-job": {
- "number": 10786,
- "filename": "pr10786-missing-job.json",
- "expected": "Cannot merge, missing expected jobs",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "PR missing an expected CI job and cannot merge",
- },
- "invalid-author": {
- "number": 10786,
- "filename": "pr10786-invalid-author.json",
- "expected": "Failed auth check 'collaborators', quitting",
- "comment": "@tvm-bot merge",
- "user": "not-abc",
- "detail": "Merge requester is not a committer and cannot merge",
- },
- "unauthorized-comment": {
- "number": 11244,
- "filename": "pr11244-unauthorized-comment.json",
- "expected": "Failed auth check 'collaborators'",
- "comment": "@tvm-bot merge",
- "user": "not-abc2",
- "detail": "Check that a merge comment not from a CONTRIBUTOR is rejected",
- },
- "no-review": {
- "number": 11267,
- "filename": "pr11267-no-review.json",
- "expected": "Cannot merge, did not find any approving reviews from users with write access",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request without any reviews is rejected",
- },
- "changes-requested": {
- "number": 10786,
- "filename": "pr10786-changes-requested.json",
- "expected": "Cannot merge, found [this review]",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with a 'Changes Requested' review is rejected",
- },
- "co-authors": {
- "number": 10786,
- "filename": "pr10786-co-authors.json",
- "expected": "Co-authored-by: Some One <so...@email.com>",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with co-authors generates the correct commit message",
- },
- "rerun-ci": {
- "number": 11442,
- "filename": "pr11442-rerun-ci.json",
- "expected": "Rerunning ci with",
- "comment": "@tvm-bot rerun",
- "user": "abc",
- "detail": "Start a new CI job",
- },
- "ignore-jobs": {
- "number": 10786,
- "filename": "pr10786-ignore-jobs.json",
- "expected": "Dry run, would have merged",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Ignore GitHub Actions jobs that don't start with CI / ",
- },
-}
+class _TvmBotTest:
+ number = 10786
+
+ def load_data(self, data: Dict[str, Any]):
Review Comment:
should this and `number` be required to be declared in the test? consider `abc.abstractmethod` here. also, what if we call this preprocess_data?
##########
tests/python/ci/test_tvmbot.py:
##########
@@ -37,167 +36,262 @@
""".strip()
-TEST_DATA = {
- "successful-merge": {
- "number": 10786,
- "filename": "pr10786-merges.json",
- "expected": SUCCESS_EXPECTED_OUTPUT,
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Everything is fine so this PR will merge",
- },
- "no-request": {
- "number": 10786,
- "filename": "pr10786-nottriggered.json",
- "expected": "Command 'do something else' did not match anything",
- "comment": "@tvm-bot do something else",
- "user": "abc",
- "detail": "A PR for which the mergebot runs but no merge is requested",
- },
- "bad-ci": {
- "number": 10786,
- "filename": "pr10786-badci.json",
- "expected": "Cannot merge, these CI jobs are not successful on",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR which failed CI and cannot merge",
- },
- "old-review": {
- "number": 10786,
- "filename": "pr10786-oldreview.json",
- "expected": "Cannot merge, did not find any approving reviews",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "A PR with passing CI and approving reviews on an old commit so it cannot merge",
- },
- "missing-job": {
- "number": 10786,
- "filename": "pr10786-missing-job.json",
- "expected": "Cannot merge, missing expected jobs",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "PR missing an expected CI job and cannot merge",
- },
- "invalid-author": {
- "number": 10786,
- "filename": "pr10786-invalid-author.json",
- "expected": "Failed auth check 'collaborators', quitting",
- "comment": "@tvm-bot merge",
- "user": "not-abc",
- "detail": "Merge requester is not a committer and cannot merge",
- },
- "unauthorized-comment": {
- "number": 11244,
- "filename": "pr11244-unauthorized-comment.json",
- "expected": "Failed auth check 'collaborators'",
- "comment": "@tvm-bot merge",
- "user": "not-abc2",
- "detail": "Check that a merge comment not from a CONTRIBUTOR is rejected",
- },
- "no-review": {
- "number": 11267,
- "filename": "pr11267-no-review.json",
- "expected": "Cannot merge, did not find any approving reviews from users with write access",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request without any reviews is rejected",
- },
- "changes-requested": {
- "number": 10786,
- "filename": "pr10786-changes-requested.json",
- "expected": "Cannot merge, found [this review]",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with a 'Changes Requested' review is rejected",
- },
- "co-authors": {
- "number": 10786,
- "filename": "pr10786-co-authors.json",
- "expected": "Co-authored-by: Some One <so...@email.com>",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Check that a merge request with co-authors generates the correct commit message",
- },
- "rerun-ci": {
- "number": 11442,
- "filename": "pr11442-rerun-ci.json",
- "expected": "Rerunning ci with",
- "comment": "@tvm-bot rerun",
- "user": "abc",
- "detail": "Start a new CI job",
- },
- "ignore-jobs": {
- "number": 10786,
- "filename": "pr10786-ignore-jobs.json",
- "expected": "Dry run, would have merged",
- "comment": "@tvm-bot merge",
- "user": "abc",
- "detail": "Ignore GitHub Actions jobs that don't start with CI / ",
- },
-}
+class _TvmBotTest:
+ number = 10786
+
+ def load_data(self, data: Dict[str, Any]):
+ """
+ Used to pre-process PR data before running the test. Override as
+ necessary to edit data for specific test cases.
+ """
+ return data
+
+ @tvm.testing.skip_if_wheel_test
+ def test(self, tmpdir_factory):
+ """
+ Run the tvm-bot script using the data from load_data
+ """
+ mergebot_script = REPO_ROOT / "ci" / "scripts" / "github_tvmbot.py"
+ test_json_dir = Path(__file__).resolve().parent / "sample_prs"
+ with open(test_json_dir / f"pr{self.number}.json") as f:
+ test_data = json.load(f)
+
+ # Update testing data with replacements / additions
+ test_data = self.load_data(test_data)
+
+ git = TempGit(tmpdir_factory.mktemp("tmp_git_dir"))
+
+ comment = {
+ "body": self.comment,
+ "id": 123,
+ "user": {
+ "login": self.user,
+ },
+ }
+ allowed_users = [{"login": "abc"}, {"login": "other-abc"}]
+
+ proc = run_script(
+ [
+ mergebot_script,
+ "--pr",
+ self.number,
+ "--dry-run",
+ "--run-url",
+ "https://example.com",
+ "--testing-pr-json",
+ json.dumps(test_data),
+ "--testing-collaborators-json",
+ json.dumps(allowed_users),
+ "--testing-mentionable-users-json",
+ json.dumps(allowed_users),
+ "--trigger-comment-json",
+ json.dumps(comment),
+ ],
+ env={
+ "TVM_BOT_JENKINS_TOKEN": "123",
+ "GH_ACTIONS_TOKEN": "123",
+ },
+ cwd=git.cwd,
+ )
+
+ if self.expected not in proc.stderr:
+ raise RuntimeError(f"{proc.stderr}\ndid not contain\n{self.expected}")
+
+
+class TestNoRequest(_TvmBotTest):
+ """
+ A PR for which the mergebot runs but no merge is requested
+ """
+
+ comment = "@tvm-bot do something else"
+ user = "abc"
+ expected = "Command 'do something else' did not match anything"
+
+ def load_data(self, data: Dict[str, Any]):
+ data["reviews"]["nodes"][0]["body"] = "nothing"
+ return data
+
+
+class TestSuccessfulMerge(_TvmBotTest):
+ """
+ Everything is fine so this PR will merge
+ """
+
+ comment = "@tvm-bot merge"
Review Comment:
also wondering if these should be CONSTANT-style names?
##########
tests/python/ci/test_utils.py:
##########
@@ -30,12 +31,41 @@ class TempGit:
def __init__(self, cwd):
self.cwd = cwd
+ # Jenkins git is too old and doesn't have 'git init --initial-branch'
Review Comment:
maybe update the class docstring?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org