"""Keep the documents' release status in step with the published tags. A release is listed in PUBLISHED once its tag is pushed; a published tag is never moved or rebuilt. Documents may describe a release as proposed or not yet tagged only while it is absent from PUBLISHED.""" import re import unittest from pathlib import Path from tests.test_overriding import codes, section, table_rows ROOT = Path(__file__).resolve().parents[1] CONTRACT = ROOT / "docs/authoritative/instruction-package-contract.md" PUBLISHED = ("v0.15.0", "v0.16.0", "v0.17.0", "v0.18.0") DOCUMENTS = ("README.md", "OVERRIDING.md", "RELEASE-NOTES.md", "docs/authoritative/instruction-package-contract.md") def flat(path): return " ".join((ROOT / path).read_text().split()) class ReleaseStatusTests(unittest.TestCase): def test_documents_never_call_a_published_release_unpublished(self): for document in DOCUMENTS: text = flat(document) for tag in PUBLISHED: escaped = re.escape(tag) unpublished = ( rf"not[- ]yet[- ]tagged `?{escaped}", rf"`?{escaped}`?,? \(?not yet tagged", rf"proposed `?{escaped}", rf"`?{escaped}`?, proposed", rf"`?{escaped}`? release and are not yet tagged", rf"`?{escaped}`?, a proposed release", ) for pattern in unpublished: with self.subTest(document=document, tag=tag, pattern=pattern): self.assertIsNone(re.search(pattern, text, re.I)) def test_package_matrix_names_published_releases_plainly(self): rows = table_rows(section((ROOT / "OVERRIDING.md").read_text(), "Package matrix")) for row in rows: release = codes(row[6])[0] if release in PUBLISHED: with self.subTest(package=codes(row[0])[0]): self.assertEqual(row[6], f"`{release}`") def test_contract_adoption_table_marks_releases_published(self): adoption = section(CONTRACT.read_text(), "RelayView adoption of the Tester and Coordinator pairs") releases = [row[0] for row in table_rows(adoption)] self.assertEqual(releases, ["`v0.15.0`, published", "`v0.17.0`, published", "`v0.18.0`, published"]) def test_contract_explains_the_shared_v0_16_0_and_v0_17_0_commit(self): releases = " ".join(section(CONTRACT.read_text(), "Releases are immutable").split()) self.assertIn("`v0.16.0` and `v0.17.0` tag the same commit", releases) self.assertIn("A bundle for either tag takes only the packages that declare it.", releases) def test_release_notes_headings_carry_no_pending_marker(self): notes = (ROOT / "RELEASE-NOTES.md").read_text() headings = re.findall(r"^## (.+)$", notes, re.M) self.assertEqual(headings[:2], ["v0.18.0", "v0.16.0"]) class DesignerAdoptionTests(unittest.TestCase): """RelayView pins v0.15.0 and assigns specification-designer-default.""" def test_package_matrix_names_the_pinned_specification_designer_default(self): rows = {codes(row[0])[0]: row[7] for row in table_rows(section((ROOT / "OVERRIDING.md").read_text(), "Package matrix"))} self.assertTrue(rows["specification-designer-default"].startswith("Pinned Designer default")) self.assertFalse(rows["issue-designer-default"].startswith("Pinned Designer default")) def test_documents_drop_the_pending_designer_adoption(self): for document in ("README.md", "OVERRIDING.md"): text = flat(document) for phrase in ("until it pins `v0.15.0`", "until it pins v0.15.0", "not yet pinned", "RelayView still pins `issue-designer-default`", "keeps assigning `issue-designer-default`"): with self.subTest(document=document, phrase=phrase): self.assertNotIn(phrase, text) adoption = section(CONTRACT.read_text(), "RelayView adoption of the Specification Designer default") self.assertNotIn("Before RelayView pins", adoption) self.assertIn("first-party-skills/v0.15.0/", adoption) if __name__ == "__main__": unittest.main()