Skip to content

Commit 4437a18

Browse files
authored
Prompt to update the docs by version page (#226)
1 parent 4a6cf47 commit 4437a18

File tree

2 files changed

+109
-9
lines changed

2 files changed

+109
-9
lines changed

run_release.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import argparse
1010
import asyncio
1111
import contextlib
12+
import datetime as dt
1213
import functools
1314
import getpass
1415
import json
@@ -1013,21 +1014,35 @@ def purge_the_cdn(db: ReleaseShelf) -> None:
10131014
raise RuntimeError("Failed to purge the python.org/downloads CDN")
10141015

10151016

1016-
def modify_the_release_to_the_prerelease_pages(db: ReleaseShelf) -> None:
1017-
pre_release_tags = {"rc", "b", "a"}
1018-
if any(tag in str(db["release"]) for tag in pre_release_tags):
1017+
def modify_the_prereleases_page(db: ReleaseShelf) -> None:
1018+
if db["release"].is_final:
10191019
if not ask_question(
1020-
"Have you already added the release to https://www.python.org/download/pre-releases/"
1020+
"Have you already removed the release from https://www.python.org/download/pre-releases/ ?"
10211021
):
10221022
raise ReleaseException(
1023-
"The release has not been added to the pre-release page"
1023+
"The release has not been removed from the pre-releases page"
10241024
)
10251025
else:
10261026
if not ask_question(
1027-
"Have you already removed the release from https://www.python.org/download/pre-releases/"
1027+
"Have you already added the release to https://www.python.org/download/pre-releases/ ?"
10281028
):
10291029
raise ReleaseException(
1030-
"The release has not been removed from the pre-release page"
1030+
"The release has not been added to the pre-releases page"
1031+
)
1032+
1033+
1034+
def modify_the_docs_by_version_page(db: ReleaseShelf) -> None:
1035+
if db["release"].is_final:
1036+
version = db["release"]
1037+
date = dt.datetime.now().strftime("%d %B %Y")
1038+
if not ask_question(
1039+
"Have you already added the docs to https://www.python.org/doc/versions/ ?\n"
1040+
"For example:\n"
1041+
f"* `Python {version} <https://docs.python.org/release/{version}/>`_, "
1042+
f"documentation released on {date}."
1043+
):
1044+
raise ReleaseException(
1045+
"The docs have not been added to the docs by version page"
10311046
)
10321047

10331048

@@ -1329,7 +1344,8 @@ def _api_key(api_key: str) -> str:
13291344
Task(remove_temporary_branch, "Removing temporary release branch"),
13301345
Task(run_add_to_python_dot_org, "Add files to python.org download page"),
13311346
Task(purge_the_cdn, "Purge the CDN of python.org/downloads"),
1332-
Task(modify_the_release_to_the_prerelease_pages, "Modify the pre-release page"),
1347+
Task(modify_the_prereleases_page, "Modify the pre-release page"),
1348+
Task(modify_the_docs_by_version_page, "Update docs by version page"),
13331349
]
13341350
automata = ReleaseDriver(
13351351
git_repo=args.repo,

tests/test_run_release.py

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_check_doc_unreleased_version_no_file_alpha(tmp_path: Path) -> None:
8888
run_release.check_doc_unreleased_version(cast(ReleaseShelf, db))
8989

9090

91-
def test_check_doc_unreleased_version_ok(monkeypatch, tmp_path: Path) -> None:
91+
def test_check_doc_unreleased_version_ok(tmp_path: Path) -> None:
9292
prepare_fake_docs(
9393
tmp_path,
9494
"<div>New in 3.13</div>",
@@ -124,3 +124,87 @@ def test_check_doc_unreleased_version_waived(monkeypatch, tmp_path: Path) -> Non
124124
}
125125
with fake_answers(monkeypatch, ["yes"]):
126126
run_release.check_doc_unreleased_version(cast(ReleaseShelf, db))
127+
128+
129+
@pytest.mark.parametrize(
130+
["tag", "expected"],
131+
[
132+
("3.14.0a7", "Have you already added the release to "),
133+
("3.13.3", "Have you already removed the release from "),
134+
],
135+
)
136+
def test_modify_the_prerelease_page_yes(
137+
capsys, monkeypatch, tag: str, expected: str
138+
) -> None:
139+
# Arrange
140+
db = {"release": Tag(tag)}
141+
142+
# Act
143+
with fake_answers(monkeypatch, ["yes"]):
144+
run_release.modify_the_prereleases_page(cast(ReleaseShelf, db))
145+
146+
# Assert
147+
assert expected in capsys.readouterr().out
148+
149+
150+
@pytest.mark.parametrize(
151+
["tag", "expected"],
152+
[
153+
("3.14.0a7", "The release has not been added to the pre-releases page"),
154+
("3.13.3", "The release has not been removed from the pre-releases page"),
155+
],
156+
)
157+
def test_modify_the_prerelease_page_no(monkeypatch, tag: str, expected: str) -> None:
158+
# Arrange
159+
db = {"release": Tag(tag)}
160+
161+
# Act
162+
with (
163+
fake_answers(monkeypatch, ["no"]),
164+
pytest.raises(run_release.ReleaseException, match=expected),
165+
):
166+
run_release.modify_the_prereleases_page(cast(ReleaseShelf, db))
167+
168+
169+
def test_modify_the_docs_by_version_page_prerelease(capsys) -> None:
170+
# Arrange
171+
db = {"release": Tag("3.14.0a7")}
172+
173+
# Act
174+
run_release.modify_the_docs_by_version_page(cast(ReleaseShelf, db))
175+
176+
# Assert
177+
assert capsys.readouterr().out == ""
178+
179+
180+
def test_modify_the_docs_by_version_page_final_no(capsys, monkeypatch) -> None:
181+
# Arrange
182+
db = {"release": Tag("3.13.3")}
183+
184+
# Act
185+
with (
186+
fake_answers(monkeypatch, ["no"]),
187+
pytest.raises(run_release.ReleaseException),
188+
):
189+
run_release.modify_the_docs_by_version_page(cast(ReleaseShelf, db))
190+
191+
# Assert
192+
assert (
193+
"* `Python 3.13.3 <https://docs.python.org/release/3.13.3/>`_, documentation released on"
194+
in capsys.readouterr().out
195+
)
196+
197+
198+
def test_modify_the_docs_by_version_page_final_yes(capsys, monkeypatch) -> None:
199+
# Arrange
200+
db = {"release": Tag("3.13.3")}
201+
202+
# Act
203+
with fake_answers(monkeypatch, ["yes"]):
204+
run_release.modify_the_docs_by_version_page(cast(ReleaseShelf, db))
205+
206+
# Assert
207+
assert (
208+
"* `Python 3.13.3 <https://docs.python.org/release/3.13.3/>`_, documentation released on"
209+
in capsys.readouterr().out
210+
)

0 commit comments

Comments
 (0)