Skip to content

Commit 2d7014c

Browse files
committedJun 2, 2022
build: clean up ci helpers, use them more uniformly
1 parent 67e5e95 commit 2d7014c

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed
 

‎Makefile

+8-6
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ sample_html_beta: _sample_cog_html ## Generate sample HTML report for a beta rel
134134
.PHONY: kit kit_upload test_upload kit_local build_kits download_kits check_kits tag
135135
.PHONY: update_stable comment_on_fixes
136136

137+
REPO_OWNER = nedbat/coveragepy
138+
137139
kit: ## Make the source distribution.
138140
python -m build
139141

@@ -153,10 +155,10 @@ kit_local:
153155
find ~/Library/Caches/pip/wheels -name 'coverage-*' -delete
154156

155157
build_kits: ## Trigger GitHub to build kits
156-
python ci/trigger_build_kits.py nedbat/coveragepy
158+
python ci/trigger_build_kits.py $(REPO_OWNER)
157159

158160
download_kits: ## Download the built kits from GitHub.
159-
python ci/download_gha_artifacts.py nedbat/coveragepy
161+
python ci/download_gha_artifacts.py $(REPO_OWNER)
160162

161163
check_kits: ## Check that dist/* are well-formed.
162164
python -m twine check dist/*
@@ -169,9 +171,6 @@ update_stable: ## Set the stable branch to the latest release.
169171
git branch -f stable $$(python setup.py --version)
170172
git push origin stable
171173

172-
comment_on_fixes: ## Add a comment to issues that were fixed.
173-
python ci/comment_on_fixes.py
174-
175174

176175
##@ Documentation
177176

@@ -227,4 +226,7 @@ $(RELNOTES_JSON): $(CHANGES_MD)
227226
$(DOCBIN)/python ci/parse_relnotes.py tmp/rst_rst/changes.md $(RELNOTES_JSON)
228227

229228
github_releases: $(RELNOTES_JSON) ## Update GitHub releases.
230-
$(DOCBIN)/python ci/github_releases.py $(RELNOTES_JSON) nedbat/coveragepy
229+
$(DOCBIN)/python ci/github_releases.py $(RELNOTES_JSON) $(REPO_OWNER)
230+
231+
comment_on_fixes: $(RELNOTES_JSON) ## Add a comment to issues that were fixed.
232+
python ci/comment_on_fixes.py $(REPO_OWNER)

‎ci/comment_on_fixes.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2+
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3+
14
"""Add a release comment to all the issues mentioned in the latest release."""
25

36
import json
47
import re
8+
import sys
59

610
import requests
711

@@ -16,21 +20,20 @@
1620
)
1721
print(f"Comment will be:\n\n{comment}\n")
1822

19-
owner = "nedbat"
20-
repo = "coveragepy"
21-
for m in re.finditer(rf"https://github.com/{owner}/{repo}/(issues|pull)/(\d+)", latest["text"]):
23+
repo_owner = sys.argv[1]
24+
for m in re.finditer(rf"https://github.com/{repo_owner}/(issues|pull)/(\d+)", latest["text"]):
2225
kind, number = m.groups()
2326
do_comment = False
2427

2528
if kind == "issues":
26-
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}"
29+
url = f"https://api.github.com/repos/{repo_owner}/issues/{number}"
2730
issue_data = requests.get(url).json()
2831
if issue_data["state"] == "closed":
2932
do_comment = True
3033
else:
3134
print(f"Still open, comment manually: {m[0]}")
3235
else:
33-
url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{number}"
36+
url = f"https://api.github.com/repos/{repo_owner}/pulls/{number}"
3437
pull_data = requests.get(url).json()
3538
if pull_data["state"] == "closed":
3639
if pull_data["merged"]:
@@ -42,6 +45,6 @@
4245

4346
if do_comment:
4447
print(f"Commenting on {m[0]}")
45-
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments"
48+
url = f"https://api.github.com/repos/{repo_owner}/issues/{number}/comments"
4649
resp = requests.post(url, json={"body": comment})
4750
print(resp)

‎ci/github_releases.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env python3
2-
"""
3-
Upload release notes into GitHub releases.
4-
"""
1+
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2+
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3+
4+
"""Upload release notes into GitHub releases."""
55

66
import json
77
import shlex

‎ci/parse_relnotes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/usr/bin/env python3
1+
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2+
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3+
24
"""
35
Parse CHANGES.md into a JSON structure.
46

0 commit comments

Comments
 (0)
Please sign in to comment.