Skip to content

Commit

Permalink
[Miscs] Enhance script about make release notes (#15234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysh329 authored Jul 5, 2023
1 parent 0bb390b commit 88701dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions tests/scripts/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
22 changes: 13 additions & 9 deletions tests/scripts/release/gather_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion tests/scripts/release/make_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 88701dc

Please sign in to comment.