Skip to content

Commit ac3664e

Browse files
committed
Move changelog and CI over to GHI
fixes: #354
1 parent 51a2ff8 commit ac3664e

6 files changed

Lines changed: 22 additions & 91 deletions

File tree

.ci/scripts/release.py

Lines changed: 4 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,11 @@
66
# For more info visit https://github.com/pulp/plugin_template
77

88
import argparse
9-
import json
109
import re
1110
import os
1211
import textwrap
13-
from collections import defaultdict
14-
from pathlib import Path
1512

1613
from git import Repo
17-
from redminelib import Redmine
18-
from redminelib.exceptions import ResourceAttrError
19-
20-
21-
REDMINE_URL = "https://pulp.plan.io"
22-
REDMINE_QUERY_URL = f"{REDMINE_URL}/issues?set_filter=1&status_id=*&issue_id="
23-
24-
25-
def validate_redmine_data(redmine_query_url, redmine_issues):
26-
"""Validate redmine milestone."""
27-
redmine = Redmine("https://pulp.plan.io")
28-
project_set = set()
29-
stats = defaultdict(list)
30-
milestone_url = "\n[noissue]"
31-
milestone_id = None
32-
for issue in redmine_issues:
33-
redmine_issue = redmine.issue.get(int(issue))
34-
35-
project_name = redmine_issue.project.name
36-
project_set.update([project_name])
37-
stats[f"project_{project_name.lower().replace(' ', '_')}"].append(issue)
38-
39-
status = redmine_issue.status.name
40-
if "CLOSE" not in status and status != "MODIFIED":
41-
stats["status_not_modified"].append(issue)
42-
43-
try:
44-
milestone = redmine_issue.fixed_version.name
45-
milestone_id = redmine_issue.fixed_version.id
46-
stats[f"milestone_{milestone}"].append(issue)
47-
except ResourceAttrError:
48-
stats["without_milestone"].append(issue)
49-
50-
if milestone_id is not None:
51-
milestone_url = f"Redmine Milestone: {REDMINE_URL}/versions/{milestone_id}.json\n[noissue]"
52-
53-
print(f"\n\nRedmine stats: {json.dumps(stats, indent=2)}")
54-
error_messages = []
55-
if stats.get("status_not_modified"):
56-
error_messages.append(f"One or more issues are not MODIFIED {stats['status_not_modified']}")
57-
if stats.get("without_milestone"):
58-
error_messages.append(
59-
f"One or more issues are not associated with a milestone {stats['without_milestone']}"
60-
)
61-
if len(project_set) > 1:
62-
error_messages.append(f"Issues with different projects - {project_set}")
63-
if error_messages:
64-
error_messages.append(f"Verify at {redmine_query_url}")
65-
raise RuntimeError("\n".join(error_messages))
66-
67-
return milestone_url
6814

6915

7016
release_path = os.path.dirname(os.path.abspath(__file__))
@@ -81,17 +27,6 @@ def validate_redmine_data(redmine_query_url, redmine_issues):
8127
release_version = version.replace(".dev", "")
8228

8329

84-
issues_to_close = []
85-
for filename in Path(f"{plugin_path}/CHANGES").rglob("*"):
86-
if filename.stem.isdigit():
87-
issue = filename.stem
88-
issue_url = f"{REDMINE_URL}/issues/{issue}.json"
89-
issues_to_close.append(issue)
90-
91-
issues = ",".join(issues_to_close)
92-
redmine_final_query = f"{REDMINE_QUERY_URL}{issues}"
93-
milestone_url = validate_redmine_data(redmine_final_query, issues_to_close)
94-
9530
helper = textwrap.dedent(
9631
"""\
9732
Start the release process.
@@ -165,10 +100,9 @@ def validate_redmine_data(redmine_query_url, redmine_issues):
165100
git.add(f"{plugin_path}/setup.py")
166101
git.add(f"{plugin_path}/requirements.txt")
167102
git.add(f"{plugin_path}/.bumpversion.cfg")
168-
git.commit(
169-
"-m",
170-
f"Release {release_version}\n\nRedmine Query: {redmine_final_query}\n{milestone_url}",
171-
)
103+
104+
git.commit("-m", f"Release {release_version}")
105+
172106

173107
sha = repo.head.object.hexsha
174108
short_sha = git.rev_parse(sha, short=7)
@@ -199,6 +133,6 @@ def validate_redmine_data(redmine_query_url, redmine_issues):
199133
git.add(f"{plugin_path}/.bumpversion.cfg")
200134
git.commit("-m", f"Bump to {new_dev_version}\n\n[noissue]")
201135

202-
print(f"\n\nRedmine query of issues to close:\n{redmine_final_query}")
136+
203137
print(f"Release commit == {short_sha}")
204138
print(f"All changes were committed on branch: release_{release_version}")

.ci/scripts/validate_commit_message.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,30 @@
66
# For more info visit https://github.com/pulp/plugin_template
77

88
import re
9-
import requests
9+
1010
import subprocess
1111
import sys
1212
from pathlib import Path
1313

14-
KEYWORDS = ["fixes", "closes", "re", "ref"]
14+
from github import Github
15+
16+
KEYWORDS = ["fixes", "closes"]
1517
NO_ISSUE = "[noissue]"
16-
STATUSES = ["NEW", "ASSIGNED", "POST", "MODIFIED"]
17-
REDMINE_URL = "https://pulp.plan.io"
1818
CHANGELOG_EXTS = [".feature", ".bugfix", ".doc", ".removal", ".misc", ".deprecation"]
1919

2020
sha = sys.argv[1]
21-
project = ""
2221
message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8")
2322

23+
g = Github()
24+
repo = g.get_repo("pulp/pulp_python")
2425

25-
def __check_status(issue):
26-
response = requests.get(f"{REDMINE_URL}/issues/{issue}.json")
27-
response.raise_for_status()
28-
bug_json = response.json()
29-
status = bug_json["issue"]["status"]["name"]
30-
if status not in STATUSES:
31-
sys.exit(
32-
"Error: issue #{issue} has invalid status of {status}. Status must be one of "
33-
"{statuses}.".format(issue=issue, status=status, statuses=", ".join(STATUSES))
34-
)
3526

36-
if project:
37-
project_id = bug_json["issue"]["project"]["id"]
38-
project_json = requests.get(f"{REDMINE_URL}/projects/{project_id}.json").json()
39-
if project_json["project"]["identifier"] != project:
40-
sys.exit(f"Error: issue {issue} is not in the {project} project.")
27+
def __check_status(issue):
28+
gi = repo.get_issue(int(issue))
29+
if gi.pull_request:
30+
sys.exit(f"Error: issue #{issue} is a pull request.")
31+
if gi.closed_at:
32+
sys.exit(f"Error: issue #{issue} is closed.")
4133

4234

4335
def __check_changelog(issue):

.github/workflows/scripts/check_commit.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ set -euv
1414

1515
echo ::group::REQUESTS
1616
pip3 install requests
17+
18+
pip3 install pygithub
19+
1720
echo ::endgroup::
1821

1922
for sha in $(curl $GITHUB_CONTEXT | jq '.[].sha' | sed 's/"//g')

CHANGES/354.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move changelog template and issue checker workflow to GitHub Issues

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ filename = "CHANGES.rst"
44
directory = "CHANGES/"
55
title_format = "{version} ({project_date})"
66
template = "CHANGES/.TEMPLATE.rst"
7-
issue_format = "`#{issue} <https://pulp.plan.io/issues/{issue}>`_"
7+
issue_format = "`#{issue} <https://github.com/pulp/pulp_python/issues/{issue}>`_"
88

99
[tool.check-manifest]
1010
ignore = [

template_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ deploy_daily_client_to_rubygems: true
1616
deploy_to_pypi: true
1717
docker_fixtures: false
1818
docs_test: true
19+
issue_tracker: github
1920
plugin_app_label: python
2021
plugin_camel: PulpPython
2122
plugin_camel_short: Python

0 commit comments

Comments
 (0)