Skip to content

Commit ed63311

Browse files
committed
Remove unused --git-ref, and drive-by changes.
1 parent 13da9cd commit ed63311

3 files changed

Lines changed: 20 additions & 248 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ jobs:
171171
- name: Checkout Source
172172
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
173173
with:
174-
fetch-depth: 1
175174
ref: ${{ inputs.git-tag }}
176-
persist-credentials: false
177175

178176
- name: Set up Python
179177
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0

‎ci/tools/check_release_notes.py‎

Lines changed: 20 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
66
Usage:
77
python check_release_notes.py --git-tag <tag> --component <component>
8-
python check_release_notes.py --git-tag <tag> --component <component> --git-ref refs/tags/<tag>
98
10-
By default, notes and release configuration come from the working tree.
11-
--git-ref reads those files from the given ref without changing the checkout,
12-
so the workflow's current checker can validate older release tags. Successful
13-
checks append the parsed version to GITHUB_OUTPUT when it is set.
9+
Notes and release configuration come from the working tree. Successful checks
10+
append the parsed version to GITHUB_OUTPUT when it is set.
1411
1512
Exit codes:
1613
0 — release-notes policy satisfied
@@ -23,7 +20,6 @@
2320
import argparse
2421
import os
2522
import re
26-
import subprocess
2723
import sys
2824
from pathlib import Path
2925

@@ -70,41 +66,16 @@ def is_post_release(version: str) -> bool:
7066
return ".post" in version
7167

7268

73-
def read_repo_file(path: Path, repo_root: Path, git_ref: str | None = None) -> bytes | None:
74-
"""Read a file from the working tree or an already-resolved Git commit."""
75-
if git_ref is None:
76-
full = repo_root / path
77-
return full.read_bytes() if full.is_file() else None
78-
79-
object_name = f"{git_ref}:{path.as_posix()}"
80-
result = subprocess.run(
81-
["git", "cat-file", "--batch-check=%(objecttype)"], # noqa: S607
82-
input=f"{object_name}\n",
83-
cwd=repo_root,
84-
check=True,
85-
capture_output=True,
86-
text=True,
87-
)
88-
object_type = result.stdout.strip()
89-
if object_type == f"{object_name} missing" or object_type == "tree":
90-
return None
91-
if object_type != "blob":
92-
raise ValueError(f"Cannot read release-notes source {object_name!r}: unexpected object type {object_type!r}")
93-
return subprocess.run( # noqa: S603 - the resolved commit and path are passed without a shell.
94-
["git", "show", object_name], # noqa: S607
95-
cwd=repo_root,
96-
check=True,
97-
capture_output=True,
98-
).stdout
99-
100-
101-
def load_backport_branch(repo_root: Path = Path("."), git_ref: str | None = None) -> str | None:
102-
contents = read_repo_file(Path("ci", "versions.yml"), repo_root, git_ref)
103-
if contents is not None:
104-
for line in contents.decode("utf-8").splitlines():
105-
m = BACKPORT_BRANCH_RE.match(line.strip())
106-
if m:
107-
return m.group("branch")
69+
def load_backport_branch(repo_root: Path = Path(".")) -> str | None:
70+
path = repo_root / "ci" / "versions.yml"
71+
try:
72+
with open(path, encoding="utf-8") as f:
73+
for line in f:
74+
m = BACKPORT_BRANCH_RE.match(line.strip())
75+
if m:
76+
return m.group("branch")
77+
except FileNotFoundError:
78+
pass
10879
github_ref_name = os.environ.get("GITHUB_REF_NAME", "")
10980
if BACKPORT_BRANCH_NAME_RE.match(github_ref_name):
11081
return github_ref_name
@@ -121,9 +92,7 @@ def notes_path(package: str, version: str) -> Path:
12192
return Path(package, "docs", "source", "release", f"{version}-notes.rst")
12293

12394

124-
def check_release_notes(
125-
git_tag: str, component: str, repo_root: Path = Path("."), git_ref: str | None = None
126-
) -> list[tuple[str | Path, str]]:
95+
def check_release_notes(git_tag: str, component: str, repo_root: Path = Path(".")) -> list[tuple[str | Path, str]]:
12796
"""Return a list of (path, reason) for missing or empty release notes.
12897
12998
``path`` is the repo-relative notes path, or a ``<placeholder>`` naming the
@@ -143,10 +112,10 @@ def check_release_notes(
143112
return []
144113

145114
path = notes_path(COMPONENT_TO_PACKAGE[component], version)
146-
contents = read_repo_file(path, repo_root, git_ref)
147-
if contents is None:
115+
full = repo_root / path
116+
if not full.is_file():
148117
return [(path, "missing")]
149-
if not contents and component != "cuda-pathfinder":
118+
if full.stat().st_size == 0 and component != "cuda-pathfinder":
150119
return [(path, "empty")]
151120
return []
152121

@@ -193,7 +162,6 @@ def validate_backport_decision(
193162
backport_git_tag: str,
194163
backport_branch: str | None,
195164
repo_root: Path,
196-
git_ref: str | None = None,
197165
) -> tuple[int | None, list[tuple[str | Path, str]]]:
198166
if component not in BACKPORT_PLANNING_COMPONENTS or is_post_release(version):
199167
return None, []
@@ -203,7 +171,7 @@ def validate_backport_decision(
203171
return 2, []
204172

205173
if is_backport_version(version, backport_branch):
206-
problems = check_release_notes(git_tag, component, repo_root, git_ref)
174+
problems = check_release_notes(git_tag, component, repo_root)
207175
if problems:
208176
warn_missing_backport_notes(git_tag, component, problems)
209177
else:
@@ -241,7 +209,7 @@ def validate_backport_decision(
241209
)
242210
return 2, []
243211

244-
problems = check_release_notes(decision, component, repo_root, git_ref)
212+
problems = check_release_notes(decision, component, repo_root)
245213
if problems:
246214
return 1, problems
247215
return None, []
@@ -252,9 +220,6 @@ def main(argv: list[str] | None = None) -> int:
252220
parser.add_argument("--git-tag", required=True)
253221
parser.add_argument("--component", required=True, choices=list(COMPONENT_TO_PACKAGE))
254222
parser.add_argument("--repo-root", default=Path("."), type=Path)
255-
parser.add_argument(
256-
"--git-ref", help="Read notes and release configuration from this Git ref without checking it out"
257-
)
258223
parser.add_argument("--backport-git-tag", default="")
259224
parser.add_argument("--backport-branch", default="")
260225
args = parser.parse_args(argv)
@@ -267,41 +232,19 @@ def main(argv: list[str] | None = None) -> int:
267232
)
268233
return 2
269234

270-
source_ref = args.git_ref
271-
try:
272-
if args.git_ref is not None:
273-
args.git_ref = subprocess.run( # noqa: S603 - --end-of-options prevents the ref from becoming an option.
274-
["git", "rev-parse", "--verify", "--end-of-options", f"{args.git_ref}^{{commit}}"], # noqa: S607
275-
cwd=args.repo_root,
276-
check=True,
277-
capture_output=True,
278-
text=True,
279-
).stdout.strip()
280-
return check_policy(args, version)
281-
except subprocess.CalledProcessError as exc:
282-
detail = exc.stderr.decode("utf-8") if isinstance(exc.stderr, bytes) else exc.stderr
283-
print(f"ERROR: cannot read Git release-notes source {source_ref!r}: {detail.strip()}", file=sys.stderr)
284-
return 2
285-
except ValueError as exc:
286-
print(f"ERROR: {exc}", file=sys.stderr)
287-
return 2
288-
289-
290-
def check_policy(args: argparse.Namespace, version: str) -> int:
291235
if is_post_release(version) and args.component != "cuda-pathfinder":
292236
print(f"Post-release tag ({args.git_tag}), skipping release-notes check.")
293237
write_version_output(version)
294238
return 0
295239

296-
backport_branch = args.backport_branch or load_backport_branch(args.repo_root, args.git_ref)
240+
backport_branch = args.backport_branch or load_backport_branch(args.repo_root)
297241
rc, problems = validate_backport_decision(
298242
git_tag=args.git_tag,
299243
component=args.component,
300244
version=version,
301245
backport_git_tag=args.backport_git_tag,
302246
backport_branch=backport_branch,
303247
repo_root=args.repo_root,
304-
git_ref=args.git_ref,
305248
)
306249
if rc is not None:
307250
if problems:
@@ -313,7 +256,7 @@ def check_policy(args: argparse.Namespace, version: str) -> int:
313256
return rc
314257

315258
if not problems:
316-
problems = check_release_notes(args.git_tag, args.component, args.repo_root, args.git_ref)
259+
problems = check_release_notes(args.git_tag, args.component, args.repo_root)
317260

318261
if not problems:
319262
print(f"Release notes present for tag {args.git_tag}, component {args.component}.")

‎ci/tools/tests/test_check_release_notes.py‎

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from __future__ import annotations
55

6-
import subprocess
76
import sys
87
from pathlib import Path
98

@@ -19,35 +18,6 @@
1918
)
2019

2120

22-
@pytest.fixture
23-
def git_source(tmp_path, monkeypatch):
24-
"""Model read-only Git commands without creating commits in test fixtures."""
25-
files = {}
26-
calls = []
27-
commit = "1" * 40
28-
29-
def run(command, **kwargs):
30-
assert kwargs["cwd"] == tmp_path
31-
assert kwargs["check"] is True
32-
calls.append(command)
33-
if command[1] == "rev-parse":
34-
return subprocess.CompletedProcess(command, 0, stdout=f"{commit}\n", stderr="")
35-
if command[1] == "cat-file":
36-
object_name = kwargs["input"].strip()
37-
ref, path = object_name.split(":", 1)
38-
assert ref == commit
39-
stdout = "blob\n" if path in files else f"{object_name} missing\n"
40-
return subprocess.CompletedProcess(command, 0, stdout=stdout, stderr="")
41-
if command[1] == "show":
42-
ref, path = command[2].split(":", 1)
43-
assert ref == commit
44-
return subprocess.CompletedProcess(command, 0, stdout=files[path], stderr=b"")
45-
pytest.fail(f"Unexpected Git command: {command}")
46-
47-
monkeypatch.setattr("check_release_notes.subprocess.run", run)
48-
return files, calls
49-
50-
5121
class TestParseVersionFromTag:
5222
def test_plain_tag_bindings(self):
5323
assert parse_version_from_tag("v13.1.0", "cuda-bindings") == "13.1.0"
@@ -430,142 +400,3 @@ def test_invalid_pathfinder_tags_do_not_expose_version(tmp_path, monkeypatch, ta
430400

431401
assert main(["--git-tag", tag, "--component", "cuda-pathfinder", "--repo-root", str(tmp_path)]) == 2
432402
assert not output.exists()
433-
434-
435-
@pytest.mark.parametrize("contents,expected", [(b"", 0), (b"Release notes.", 0), (None, 1)])
436-
@pytest.mark.agent_authored(model="gpt-6.1")
437-
def test_git_ref_reads_pathfinder_post_notes_instead_of_worktree(tmp_path, monkeypatch, git_source, contents, expected):
438-
files, calls = git_source
439-
path = "cuda_pathfinder/docs/source/release/1.5.2.post1-notes.rst"
440-
worktree_notes = tmp_path / path
441-
worktree_notes.parent.mkdir(parents=True)
442-
worktree_notes.write_text("Working tree notes must not decide the tagged release policy.")
443-
if contents is not None:
444-
files[path] = contents
445-
output = tmp_path / "output"
446-
monkeypatch.setenv("GITHUB_OUTPUT", str(output))
447-
448-
assert (
449-
main(
450-
[
451-
"--git-tag",
452-
"cuda-pathfinder-v1.5.2.post1",
453-
"--component",
454-
"cuda-pathfinder",
455-
"--repo-root",
456-
str(tmp_path),
457-
"--git-ref",
458-
"refs/tags/cuda-pathfinder-v1.5.2.post1",
459-
]
460-
)
461-
== expected
462-
)
463-
assert calls[0] == [
464-
"git",
465-
"rev-parse",
466-
"--verify",
467-
"--end-of-options",
468-
"refs/tags/cuda-pathfinder-v1.5.2.post1^{commit}",
469-
]
470-
assert worktree_notes.read_text() == "Working tree notes must not decide the tagged release policy."
471-
assert output.exists() == (expected == 0)
472-
473-
474-
@pytest.mark.parametrize("component", ["cuda-bindings", "cuda-python"])
475-
@pytest.mark.parametrize("backport_present,expected", [(True, 0), (False, 1)])
476-
@pytest.mark.agent_authored(model="gpt-6.1")
477-
def test_git_ref_reads_release_backport_configuration_and_both_notes(
478-
tmp_path, monkeypatch, git_source, component, backport_present, expected
479-
):
480-
files, _ = git_source
481-
files["ci/versions.yml"] = b'backport_branch: "12.9.x"\n'
482-
package = component.replace("-", "_")
483-
files[f"{package}/docs/source/release/13.3.0-notes.rst"] = b"Mainline notes."
484-
if backport_present:
485-
files[f"{package}/docs/source/release/12.9.7-notes.rst"] = b"Backport notes."
486-
(tmp_path / "ci").mkdir()
487-
(tmp_path / "ci" / "versions.yml").write_text('backport_branch: "12.8.x"\n')
488-
output = tmp_path / "output"
489-
monkeypatch.setenv("GITHUB_OUTPUT", str(output))
490-
491-
assert (
492-
main(
493-
[
494-
"--git-tag",
495-
"v13.3.0",
496-
"--component",
497-
component,
498-
"--repo-root",
499-
str(tmp_path),
500-
"--git-ref",
501-
"refs/tags/v13.3.0",
502-
"--backport-git-tag",
503-
"v12.9.7",
504-
]
505-
)
506-
== expected
507-
)
508-
assert output.exists() == (expected == 0)
509-
510-
511-
@pytest.mark.agent_authored(model="gpt-6.1")
512-
def test_missing_git_ref_is_an_error_not_missing_notes(tmp_path, monkeypatch, capsys):
513-
def run(command, **kwargs):
514-
assert command[1] == "rev-parse"
515-
raise subprocess.CalledProcessError(128, command, stderr="fatal: Needed a single revision\n")
516-
517-
monkeypatch.setattr("check_release_notes.subprocess.run", run)
518-
output = tmp_path / "output"
519-
monkeypatch.setenv("GITHUB_OUTPUT", str(output))
520-
521-
assert (
522-
main(
523-
[
524-
"--git-tag",
525-
"cuda-pathfinder-v1.5.2",
526-
"--component",
527-
"cuda-pathfinder",
528-
"--repo-root",
529-
str(tmp_path),
530-
"--git-ref",
531-
"refs/tags/missing",
532-
]
533-
)
534-
== 2
535-
)
536-
assert "cannot read Git release-notes source" in capsys.readouterr().err
537-
assert not output.exists()
538-
539-
540-
@pytest.mark.agent_authored(model="gpt-6.1")
541-
def test_git_read_failure_is_not_treated_as_missing_notes(tmp_path, monkeypatch, git_source, capsys):
542-
files, _ = git_source
543-
files["cuda_pathfinder/docs/source/release/1.5.2-notes.rst"] = b"Release notes."
544-
run = subprocess.run
545-
546-
def failing_show(command, **kwargs):
547-
if command[1] == "show":
548-
raise subprocess.CalledProcessError(128, command, stderr=b"fatal: cannot read blob\n")
549-
return run(command, **kwargs)
550-
551-
monkeypatch.setattr("check_release_notes.subprocess.run", failing_show)
552-
output = tmp_path / "output"
553-
monkeypatch.setenv("GITHUB_OUTPUT", str(output))
554-
555-
assert (
556-
main(
557-
[
558-
"--git-tag",
559-
"cuda-pathfinder-v1.5.2",
560-
"--component",
561-
"cuda-pathfinder",
562-
"--repo-root",
563-
str(tmp_path),
564-
"--git-ref",
565-
"refs/tags/cuda-pathfinder-v1.5.2",
566-
]
567-
)
568-
== 2
569-
)
570-
assert "cannot read blob" in capsys.readouterr().err
571-
assert not output.exists()

0 commit comments

Comments
 (0)