Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
driazati committed Feb 11, 2022
1 parent 612dc35 commit 0a55924
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions tests/python/unittest/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions tests/scripts/update_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0a55924

Please sign in to comment.