summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-06-02 08:47:13 -0400
committerNed Batchelder <ned@nedbatchelder.com>2022-06-02 08:47:13 -0400
commit2d7014cb861b00ac32c2ae8b5d3401be494b256d (patch)
treea8fb663a9f543773dbe3bfad9aa04295c66515ab
parent67e5e95c133cf970c0706d2084f7e1c65d1c1b3a (diff)
downloadpython-coveragepy-git-2d7014cb861b00ac32c2ae8b5d3401be494b256d.tar.gz
build: clean up ci helpers, use them more uniformly
-rw-r--r--Makefile14
-rw-r--r--ci/comment_on_fixes.py15
-rw-r--r--ci/github_releases.py8
-rw-r--r--ci/parse_relnotes.py4
4 files changed, 24 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index f2c67095..6c70e578 100644
--- a/Makefile
+++ b/Makefile
@@ -134,6 +134,8 @@ sample_html_beta: _sample_cog_html ## Generate sample HTML report for a beta rel
.PHONY: kit kit_upload test_upload kit_local build_kits download_kits check_kits tag
.PHONY: update_stable comment_on_fixes
+REPO_OWNER = nedbat/coveragepy
+
kit: ## Make the source distribution.
python -m build
@@ -153,10 +155,10 @@ kit_local:
find ~/Library/Caches/pip/wheels -name 'coverage-*' -delete
build_kits: ## Trigger GitHub to build kits
- python ci/trigger_build_kits.py nedbat/coveragepy
+ python ci/trigger_build_kits.py $(REPO_OWNER)
download_kits: ## Download the built kits from GitHub.
- python ci/download_gha_artifacts.py nedbat/coveragepy
+ python ci/download_gha_artifacts.py $(REPO_OWNER)
check_kits: ## Check that dist/* are well-formed.
python -m twine check dist/*
@@ -169,9 +171,6 @@ update_stable: ## Set the stable branch to the latest release.
git branch -f stable $$(python setup.py --version)
git push origin stable
-comment_on_fixes: ## Add a comment to issues that were fixed.
- python ci/comment_on_fixes.py
-
##@ Documentation
@@ -227,4 +226,7 @@ $(RELNOTES_JSON): $(CHANGES_MD)
$(DOCBIN)/python ci/parse_relnotes.py tmp/rst_rst/changes.md $(RELNOTES_JSON)
github_releases: $(RELNOTES_JSON) ## Update GitHub releases.
- $(DOCBIN)/python ci/github_releases.py $(RELNOTES_JSON) nedbat/coveragepy
+ $(DOCBIN)/python ci/github_releases.py $(RELNOTES_JSON) $(REPO_OWNER)
+
+comment_on_fixes: $(RELNOTES_JSON) ## Add a comment to issues that were fixed.
+ python ci/comment_on_fixes.py $(REPO_OWNER)
diff --git a/ci/comment_on_fixes.py b/ci/comment_on_fixes.py
index 2c9a424d..de064c49 100644
--- a/ci/comment_on_fixes.py
+++ b/ci/comment_on_fixes.py
@@ -1,7 +1,11 @@
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
+
"""Add a release comment to all the issues mentioned in the latest release."""
import json
import re
+import sys
import requests
@@ -16,21 +20,20 @@ comment = (
)
print(f"Comment will be:\n\n{comment}\n")
-owner = "nedbat"
-repo = "coveragepy"
-for m in re.finditer(rf"https://github.com/{owner}/{repo}/(issues|pull)/(\d+)", latest["text"]):
+repo_owner = sys.argv[1]
+for m in re.finditer(rf"https://github.com/{repo_owner}/(issues|pull)/(\d+)", latest["text"]):
kind, number = m.groups()
do_comment = False
if kind == "issues":
- url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}"
+ url = f"https://api.github.com/repos/{repo_owner}/issues/{number}"
issue_data = requests.get(url).json()
if issue_data["state"] == "closed":
do_comment = True
else:
print(f"Still open, comment manually: {m[0]}")
else:
- url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{number}"
+ url = f"https://api.github.com/repos/{repo_owner}/pulls/{number}"
pull_data = requests.get(url).json()
if pull_data["state"] == "closed":
if pull_data["merged"]:
@@ -42,6 +45,6 @@ for m in re.finditer(rf"https://github.com/{owner}/{repo}/(issues|pull)/(\d+)",
if do_comment:
print(f"Commenting on {m[0]}")
- url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments"
+ url = f"https://api.github.com/repos/{repo_owner}/issues/{number}/comments"
resp = requests.post(url, json={"body": comment})
print(resp)
diff --git a/ci/github_releases.py b/ci/github_releases.py
index 86dd7d1c..9f21d027 100644
--- a/ci/github_releases.py
+++ b/ci/github_releases.py
@@ -1,7 +1,7 @@
-#!/usr/bin/env python3
-"""
-Upload release notes into GitHub releases.
-"""
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
+
+"""Upload release notes into GitHub releases."""
import json
import shlex
diff --git a/ci/parse_relnotes.py b/ci/parse_relnotes.py
index ba5089eb..cdb8526c 100644
--- a/ci/parse_relnotes.py
+++ b/ci/parse_relnotes.py
@@ -1,4 +1,6 @@
-#!/usr/bin/env python3
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
+
"""
Parse CHANGES.md into a JSON structure.