From 44fd64214bfaf8761076e026c78bf14584e40cba Mon Sep 17 00:00:00 2001 From: driazati Date: Thu, 27 Jan 2022 11:36:28 -0800 Subject: [PATCH] address comments --- .github/workflows/update_tag.yml | 2 +- tests/python/unittest/test_ci.py | 9 +++++++-- tests/scripts/update_tag.py | 9 ++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update_tag.yml b/.github/workflows/update_tag.yml index fc3474eadb2c..6348b9e3cd05 100644 --- a/.github/workflows/update_tag.yml +++ b/.github/workflows/update_tag.yml @@ -32,7 +32,7 @@ concurrency: jobs: update-last-successful-tag: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 with: diff --git a/tests/python/unittest/test_ci.py b/tests/python/unittest/test_ci.py index 7469183788bb..3e39989adc1f 100644 --- a/tests/python/unittest/test_ci.py +++ b/tests/python/unittest/test_ci.py @@ -68,10 +68,14 @@ def run(pr_body, expected_reviewers): ) -def test_update_tag(): +def test_update_tag(tmpdir_factory): update_script = REPO_ROOT / "tests" / "scripts" / "update_tag.py" def run(statuses, expected_rc, expected_output): + git = TempGit(tmpdir_factory.mktemp("tmp_git_dir")) + git.run("init") + git.run("checkout", "-b", "main") + git.run("remote", "add", "origin", "https://github.com/apache/tvm.git") commit = { "statusCheckRollup": {"contexts": {"nodes": statuses}}, "oid": "123", @@ -85,10 +89,11 @@ def run(statuses, expected_rc, expected_output): } } proc = subprocess.run( - [str(update_script), "--dry-run", "--json", json.dumps(data)], + [str(update_script), "--dry-run", "--testonly-json", json.dumps(data)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", + cwd=git.cwd, ) if proc.returncode != expected_rc: diff --git a/tests/scripts/update_tag.py b/tests/scripts/update_tag.py index d596e56da1ed..2ce0469da798 100755 --- a/tests/scripts/update_tag.py +++ b/tests/scripts/update_tag.py @@ -90,6 +90,7 @@ def commit_passed_ci(commit: Dict[str, Any]) -> bool: # GitHub Actions statuses are different from external GitHub statuses, so # unify them into 1 representation + # https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads unified_statuses = [] for status in statuses: if "context" in status: @@ -139,14 +140,16 @@ def update_tag(user: str, repo: str, sha: str, tag_name: str, message: str) -> N parser.add_argument( "--message", default="last 'main' commit that passed CI", help="label to add" ) - parser.add_argument("--json", help="(testing) data to use instead of fetching from GitHub") + parser.add_argument( + "--testonly-json", help="(testing) data to use instead of fetching from GitHub" + ) args = parser.parse_args() remote = git(["config", "--get", f"remote.{args.remote}.url"]) user, repo = parse_remote(remote) - if args.json: - r = json.loads(args.json) + if args.testonly_json: + r = json.loads(args.testonly_json) else: github = GitHubRepo(token=os.environ["GITHUB_TOKEN"], user=user, repo=repo) q = commits_query(user, repo)