diff --git a/docs/modules/ROOT/pages/development/release.adoc b/docs/modules/ROOT/pages/development/release.adoc index a778ff4..fcce172 100644 --- a/docs/modules/ROOT/pages/development/release.adoc +++ b/docs/modules/ROOT/pages/development/release.adoc @@ -191,6 +191,7 @@ A release does not end on PyPI: it ends with a GitHub Release, as in the upstrea * `A.B.C.devN` becomes a GitHub pre-release. `A.B.C` and `A.B.C.postN` become a normal release, marked as the latest. * The notes come from `scripts/release_notes.py`. The milestone is named after the base `A.B.C` (`26.11.1` for `26.11.1`, `26.11.1.dev2` and `26.11.1.post1`). A pull request is listed when it is merged, has that milestone and its merge commit is in the tag, grouped by its first matching label: `bug` (Bug fixes), `performance` (Performance), `enhancement` (Features), `documentation` (Documentation), everything else under Other. Each line is the title and `(#N)`. The notes also have the install lines, the engine version and the PyPI pages of both packages. +* The notes of a final or `devN` release start with a *Changed behaviour* line that links `docs/modules/ROOT/pages/upgrading.adoc` in the tag, only when the title of that page is `Upgrading to A.B.C` for the release. Write the page, or move its title to the new version, before the tag. * A final release lists the whole milestone. A `devN` lists only what is not in the previous dev tag of the same base. A pull request without the milestone is not in the notes of a final or dev release, so check the milestone before the tag. * A `postN` does not use a milestone, because the final release closed it. Its notes list every pull request merged between the previous tag of the same base (the final or `post(N-1)`) and the tag, found from the commits of that range, whatever milestone the pull request has or none. * After a final release (not `devN`, not `postN`) the milestone `A.B.C` is closed, after what is still open in it moves to the next milestone. The next milestone is the open one with the earliest due date after this one; an open milestone without a due date counts as the latest, as it does for the auto-assignment, so it is taken when no dated one follows. When there is none, the workflow creates one named after the next upstream engine version (the base of the upstream `main` version, the same command as in <>) and due 30 days after the closed one. When that version cannot be read, or is the same version, nothing is moved or closed and the run fails with a message: create the next milestone with a due date and re-run the workflow. Every move is logged. The milestone auto-assignment of merged pull requests, where it is set up, then picks the next milestone, because the closed one is no longer open. diff --git a/docs/modules/ROOT/pages/upgrading.adoc b/docs/modules/ROOT/pages/upgrading.adoc index 67682a3..689009a 100644 --- a/docs/modules/ROOT/pages/upgrading.adoc +++ b/docs/modules/ROOT/pages/upgrading.adoc @@ -1,6 +1,13 @@ = Upgrading to 26.12.1 :description: What behaves differently in 26.12.1 for a program written against 26.11.1 or one of its post releases, and what is new in the two Python packages. +// The title names the release: scripts/release_notes.py links this page from the GitHub Release notes of that release. +// GitHub shows this file without the attributes of antora.yml, so the two that the page uses are set for GitHub here. +ifdef::env-github[] +:native-pkg-name: arcadedb +:jvm-pkg-name: arcadedb-jvm +endif::[] + // Sources: the pull requests ArcadeData/arcadedb-python #479 to #483. Pinned by tests/test_auto_transaction_default.py, tests/test_error_codes_table.py, tests/test_error_codes_parity.py and tests/test_lazy_import.py. Read this page before you move a program from 26.11.1, or from one of its post releases, to 26.12.1. It covers both packages, `{native-pkg-name}` and `{jvm-pkg-name}`. The changes of the engine itself are listed with the https://github.com/ArcadeData/arcadedb/releases[releases of ArcadeDB]. diff --git a/scripts/release_notes.py b/scripts/release_notes.py index 48bc1df..aa75765 100644 --- a/scripts/release_notes.py +++ b/scripts/release_notes.py @@ -2,7 +2,9 @@ """Write the notes of the GitHub Release of one tag from the milestone of its version. The tag is a bare version (docs page "Release"): `A.B.C.devN`, `A.B.C` or `A.B.C.postN`. The notes list merged pull requests grouped -by label, then the install lines, the engine version and the PyPI pages of the two packages. The pull requests of a `devN` and of a +by label, then the install lines, the engine version and the PyPI pages of the two packages. The notes of a `devN` and of a final +release start with a `Changed behaviour` line that links the docs page `upgrading.adoc` as it is in the tag, when the title of that +page is `Upgrading to A.B.C` for the base of the tag. The pull requests of a `devN` and of a final release come from the milestone named after the base `A.B.C`; a `postN` does not use a milestone (see below). Which pull requests a tag lists: @@ -53,6 +55,8 @@ ("Documentation", "documentation"), ] OTHER = "Other" +# what behaves differently in a release; the title of the page names the release it is about +UPGRADE_PAGE = "docs/modules/ROOT/pages/upgrading.adoc" class ApiError(Exception): @@ -240,6 +244,17 @@ def engine_of(repo, kind, base, ref): return None, "dev" +def upgrade_page_url(repo, base, tag, ref): + """The upgrade page in the tag, or None when the page at `ref` is missing or is about another release than `base`.""" + data = gh_api(f"repos/{repo}/contents/{UPGRADE_PAGE}?ref={quote(ref, safe='')}") + if not data or not data.get("content"): + return None + text = base64.b64decode(data["content"]).decode() + if not re.search(rf"^= Upgrading to {re.escape(base)}[ \t\r]*$", text, re.M): + return None + return f"https://github.com/{repo}/blob/{tag}/{UPGRADE_PAGE}" + + def build_notes(repo, tag): base, kind, n = parse_tag(tag) default_branch = (gh_api(f"repos/{repo}") or {}).get("default_branch", "main") @@ -281,6 +296,12 @@ def build_notes(repo, tag): engine, engine_kind = engine_of(repo, kind, base, ref) lines = [] + url = None if kind == "post" else upgrade_page_url(repo, base, tag, ref) + if url: + lines.append( + f"**Changed behaviour:** read [Upgrading to {base}]({url}) before you upgrade." + ) + lines.append("") if kind == "dev": lines.append( f"Pre-release of `{base}`: a preview built from the engine release named below, for trying the next release early." diff --git a/tests/test_release_notes_changed_behaviour.py b/tests/test_release_notes_changed_behaviour.py new file mode 100644 index 0000000..0bba377 --- /dev/null +++ b/tests/test_release_notes_changed_behaviour.py @@ -0,0 +1,73 @@ +"""scripts/release_notes.py: the "Changed behaviour" line at the start of the notes. + +It links the upgrade page of the docs as it is in the tag, and only when that page is about the release. No network: the API calls are faked. +""" + +from __future__ import annotations + +import base64 +import importlib.util +import re +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parents[1] + + +def _load(): + spec = importlib.util.spec_from_file_location( + "release_notes_changed_behaviour", ROOT / "scripts" / "release_notes.py" + ) + module = importlib.util.module_from_spec(spec) + assert spec.loader is not None + spec.loader.exec_module(module) + return module + + +notes = _load() + + +def _notes(monkeypatch, tag, page): + """The notes of `tag` in a repository with no tags and no milestone, whose upgrade page is `page` (None: no page).""" + + def gh_api(path): + if path.startswith(f"repos/o/r/contents/{notes.UPGRADE_PAGE}?"): + if page is None: + return None + return {"content": base64.b64encode(page.encode()).decode()} + return {"default_branch": "main"} if path == "repos/o/r" else None + + monkeypatch.setattr(notes, "gh_api", gh_api) + monkeypatch.setattr(notes, "gh_pages", lambda path: []) + return notes.build_notes("o/r", tag) + + +@pytest.mark.parametrize("tag", ["26.12.1", "26.12.1.dev3"]) +def test_the_notes_start_with_a_link_to_the_upgrade_page_in_the_tag(monkeypatch, tag): + text = _notes(monkeypatch, tag, "= Upgrading to 26.12.1\n:description: x\n") + assert text.splitlines()[0] == ( + "**Changed behaviour:** read [Upgrading to 26.12.1]" + f"(https://github.com/o/r/blob/{tag}/docs/modules/ROOT/pages/upgrading.adoc) before you upgrade." + ) + assert text.splitlines()[1] == "" + + +@pytest.mark.parametrize( + "tag,page", + [ + ("26.12.1", None), + ("27.1.1", "= Upgrading to 26.12.1\n"), + ("26.12.1", "= Upgrading to 26.12.10\n"), + ("26.12.1", "= Upgrading\n\nUpgrading to 26.12.1 is described elsewhere.\n"), + # a post release is a fix of a release that is out: its notes do not send the reader to the upgrade page + ("26.12.1.post1", "= Upgrading to 26.12.1\n"), + ], +) +def test_no_line_without_an_upgrade_page_for_the_release(monkeypatch, tag, page): + assert "Changed behaviour" not in _notes(monkeypatch, tag, page) + + +def test_the_title_of_the_page_in_the_repository_names_a_release(): + page = (ROOT / notes.UPGRADE_PAGE).read_text(encoding="utf-8") + assert re.match(r"= Upgrading to \d+\.\d+\.\d+\n", page)