|
| 1 | +"""scripts/release_notes.py: what a line of the release notes shows of a pull request title. |
| 2 | +
|
| 3 | +The notes are for the reader of a release, so the notes that point at issues (`refs #388`, `closes #371`, `rank 2 of #388`) are left out of a line and a pull request that only merges a release line into main is not listed. Pure functions only: no network, no gh. |
| 4 | +""" |
| 5 | + |
| 6 | +from __future__ import annotations |
| 7 | + |
| 8 | +import importlib.util |
| 9 | +import sys |
| 10 | +from pathlib import Path |
| 11 | + |
| 12 | +import pytest |
| 13 | + |
| 14 | +SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "release_notes.py" |
| 15 | + |
| 16 | + |
| 17 | +def _load(): |
| 18 | + spec = importlib.util.spec_from_file_location("release_notes", SCRIPT) |
| 19 | + module = importlib.util.module_from_spec(spec) |
| 20 | + assert spec.loader is not None |
| 21 | + sys.modules["release_notes"] = module |
| 22 | + spec.loader.exec_module(module) |
| 23 | + return module |
| 24 | + |
| 25 | + |
| 26 | +notes = _load() |
| 27 | + |
| 28 | + |
| 29 | +@pytest.mark.parametrize( |
| 30 | + "title,number,shown", |
| 31 | + [ |
| 32 | + ( |
| 33 | + "Native count(): returns the rows (rank 2 of #388) (#389)", |
| 34 | + 389, |
| 35 | + "Native count(): returns the rows", |
| 36 | + ), |
| 37 | + ( |
| 38 | + "JVM Vertex.new_edge in one crossing (refs #388) (#396)", |
| 39 | + 396, |
| 40 | + "JVM Vertex.new_edge in one crossing", |
| 41 | + ), |
| 42 | + ( |
| 43 | + "Native: query by address (refs #388, #315) (#398)", |
| 44 | + 398, |
| 45 | + "Native: query by address", |
| 46 | + ), |
| 47 | + ( |
| 48 | + "Bulk step before json.dumps (closes #371) (#377)", |
| 49 | + 377, |
| 50 | + "Bulk step before json.dumps", |
| 51 | + ), |
| 52 | + ("Fix a thing (fixes #5) (#6)", 6, "Fix a thing"), |
| 53 | + ( |
| 54 | + "Docs: refs, rank and closes in a sentence (#7)", |
| 55 | + 7, |
| 56 | + "Docs: refs, rank and closes in a sentence", |
| 57 | + ), |
| 58 | + ( |
| 59 | + "A change that names (refs #1) in the middle and ends plain (#8)", |
| 60 | + 8, |
| 61 | + "A change that names (refs #1) in the middle and ends plain", |
| 62 | + ), |
| 63 | + ( |
| 64 | + "fix(#423): find_nearest(allowed_rids=[]) returns nothing (#425)", |
| 65 | + 425, |
| 66 | + "fix(#423): find_nearest(allowed_rids=[]) returns nothing", |
| 67 | + ), |
| 68 | + ("(refs #9) (#9)", 9, "(refs #9)"), |
| 69 | + ], |
| 70 | +) |
| 71 | +def test_a_line_leaves_out_the_notes_that_point_at_issues(title, number, shown): |
| 72 | + assert notes.clean_title(title, number) == shown |
| 73 | + |
| 74 | + |
| 75 | +@pytest.mark.parametrize( |
| 76 | + "title,is_merge", |
| 77 | + [ |
| 78 | + ("Merge the 26.11.1.post3 release line into main", True), |
| 79 | + ("Merge the 26.11.1.post2 release line into main (#351)", True), |
| 80 | + ("Merge branch main into a feature", False), |
| 81 | + ("Merge the vector index docs", False), |
| 82 | + ], |
| 83 | +) |
| 84 | +def test_a_pull_request_that_only_merges_a_release_line_is_not_listed(title, is_merge): |
| 85 | + assert bool(notes.MERGE_LINE.match(title)) is is_merge |
0 commit comments