From 88701dc82a2ffa90d82d236a361984c1b1206edd Mon Sep 17 00:00:00 2001 From: ysh329 Date: Thu, 6 Jul 2023 00:34:41 +0800 Subject: [PATCH] [Miscs] Enhance script about make release notes (#15234) --- tests/scripts/release/README.md | 2 ++ tests/scripts/release/gather_prs.py | 22 +++++++++++++--------- tests/scripts/release/make_notes.py | 12 +++++++++++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/tests/scripts/release/README.md b/tests/scripts/release/README.md index ba71c7fe1190..5d068c65f9ea 100644 --- a/tests/scripts/release/README.md +++ b/tests/scripts/release/README.md @@ -30,6 +30,8 @@ Once done, you can download the csv file assuming with name `out_pr_gathered_cor ```bash # example: use a csv of tags-corrected PRs to create a markdown file +# If you want to export monthly report on forum, you need append arg +# `--is-pr-with-link true`. python make_notes.py --notes-csv out_pr_gathered_corrected.csv > out.md ``` diff --git a/tests/scripts/release/gather_prs.py b/tests/scripts/release/gather_prs.py index b85989428769..5df8721bdf5c 100644 --- a/tests/scripts/release/gather_prs.py +++ b/tests/scripts/release/gather_prs.py @@ -98,15 +98,19 @@ def fetch_pr_data(args, cache): cursor = f"{args.from_commit} {i}" while True: - r = github.graphql( - query=PRS_QUERY, - variables={ - "owner": user, - "name": repo, - "after": cursor, - "pageSize": page_size, - }, - ) + try: + r = github.graphql( + query=PRS_QUERY, + variables={ + "owner": user, + "name": repo, + "after": cursor, + "pageSize": page_size, + }, + ) + except RuntimeError as e: + print(f"{e}\nPlease check enviroment variable GITHUB_TOKEN whether is valid.") + exit(1) data = r["data"]["repository"]["defaultBranchRef"]["target"]["history"] if not data["pageInfo"]["hasNextPage"]: break diff --git a/tests/scripts/release/make_notes.py b/tests/scripts/release/make_notes.py index 81aedebf048a..aa034b1d113c 100644 --- a/tests/scripts/release/make_notes.py +++ b/tests/scripts/release/make_notes.py @@ -157,6 +157,11 @@ def categorize_csv_file(csv_path: str): help = "List out commits with attached PRs since a certain commit" parser = argparse.ArgumentParser(description=help) parser.add_argument("--notes-csv", required=True, help="csv file of categorized PRs in order") + parser.add_argument( + "--is-pr-with-link", + required=False, + help="exported pr number with hyper-link for forum format", + ) args = parser.parse_args() user = "apache" repo = "tvm" @@ -204,7 +209,12 @@ def pr_title(number, heading): misc += value.get("n/a", []) misc += value.get("Misc", []) for pr_number in misc: - output += f" * #{pr_number} - {pr_title(pr_number, '[' + key + ']')}\n" + if args.is_pr_with_link: + pr_number_str = f"[#{pr_number}](https://github.com/apache/tvm/pull/{pr_number})" + else: + pr_number_str = f"#{pr_number}" + pr_str = f" * {pr_number_str} - {pr_title(pr_number, '[' + key + ']')}\n" + output += pr_str for subheading, pr_numbers in value.items(): if subheading == "DO NOT INCLUDE":