Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s

This commit is contained in:
2026-12-03 18:56:28 +01:00
parent 20c83f861f
commit 1ca2c8efe0
142 changed files with 1095 additions and 933 deletions
+27 -27
View File
@@ -21,7 +21,7 @@ class ConfigTest(unittest.TestCase):
made = tempfile.TemporaryDirectory()
self.addCleanup(made.cleanup)
self.home = pathlib.Path(made.name).resolve()
self.folder = self.home / ".claude-projects" / "do-epic"
self.folder = self.home / ".config/build-release" / "do-epic"
self.folder.mkdir(parents=True)
def write(self, settings: str | None = SETTINGS, rule: str | None = "A label that equals a repo's name names that repo.\n") -> None:
@@ -31,17 +31,17 @@ class ConfigTest(unittest.TestCase):
(self.folder / "repo-rule.md").write_text(rule, encoding="utf-8")
def failure(self) -> str:
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, Failure), found
return found.reason
def test_reads_the_settings_and_the_rule_and_defaults_the_clone_folder_and_language(self) -> None:
self.write()
self.assertEqual(load(self.home), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
self.assertEqual(load(self.home, {}), DoEpicConfig(self.folder, "https://acme.atlassian.net", self.home / "jira.env", self.home / "code", "English", "claude-opus-5-5", "A label that equals a repo's name names that repo.\n"))
def test_reads_the_teams_labels_for_its_repos(self) -> None:
self.write(SETTINGS + '[label-repos]\ntwu-4 = "tenant-web-ui-4"\n"core-4" = "core-4"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(dict(found.label_repos), {"twu-4": "tenant-web-ui-4", "core-4": "core-4"})
@@ -63,13 +63,13 @@ class ConfigTest(unittest.TestCase):
def test_reads_a_template_for_a_sub_tasks_summary(self) -> None:
self.write(SETTINGS + 'sub-task-summary = "{label}: {Summary}"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.sub_task_summary, "{label}: {Summary}")
def test_leaves_a_sub_tasks_summary_to_its_default_where_the_config_has_no_template(self) -> None:
self.write()
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertIsNone(found.sub_task_summary)
@@ -92,7 +92,7 @@ class ConfigTest(unittest.TestCase):
for template in ("{Summary}", "{Summary}{{", "{Summary} for {label} in Jira"):
with self.subTest(template=template):
self.write(SETTINGS + f'sub-task-summary = "{template}"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.sub_task_summary, template)
@@ -102,13 +102,13 @@ class ConfigTest(unittest.TestCase):
def test_reads_a_clone_folder_and_language_the_config_sets(self) -> None:
self.write(SETTINGS + 'clone-folder = "/srv/repos"\nlanguage = "Brazilian Portuguese"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.clone_folder, found.language), (pathlib.Path("/srv/repos"), "Brazilian Portuguese"))
def test_reads_how_a_finished_epic_closes_and_wants_both_names_or_neither(self) -> None:
self.write(SETTINGS + 'jira-finish-transition = "Mark as done"\njira-finish-status = "Done"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.finish, Finish("Mark as done", "Done"))
self.write(SETTINGS + 'jira-finish-status = " "\n')
@@ -116,11 +116,11 @@ class ConfigTest(unittest.TestCase):
def test_reads_how_a_starting_issue_moves_and_which_boards_sprint_it_joins(self) -> None:
self.write(SETTINGS)
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.start, Start(None, None))
self.write(SETTINGS + 'jira-start-transition = "In Progress"\njira-sprint-board = 1\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.start, Start("In Progress", 1))
for board, read in (('"6"', "'6'"), ("0", "0"), ("true", "True"), ("6.0", "6.0")):
@@ -130,11 +130,11 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_transition_that_moves_a_parent_whose_sub_tasks_have_all_landed(self) -> None:
self.write(SETTINGS)
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertIsNone(found.sub_tasks_landed_transition)
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = "Release Ready"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.sub_tasks_landed_transition, "Release Ready")
self.write(SETTINGS + 'jira-sub-tasks-landed-transition = 5\n')
@@ -142,23 +142,23 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_unblocking_statuses_and_that_the_teams_automation_moves_issues(self) -> None:
self.write(SETTINGS)
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.unblocking, found.automation_moves), ((), False))
self.write(SETTINGS + 'jira-unblocking-statuses = ["Release Ready", "Done"]\njira-automation-moves-issues = true\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.unblocking, found.automation_moves), (("Release Ready", "Done"), True))
def test_the_issue_types_of_a_finding_and_a_release_review_are_task_where_left_out(self) -> None:
self.write()
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.finding_type, found.review_type), ("Task", "Task"))
def test_reads_the_issue_types_of_a_finding_and_a_release_review(self) -> None:
self.write(SETTINGS + 'jira-finding-type = "Feature"\njira-review-type = "Chore"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.finding_type, found.review_type), ("Feature", "Chore"))
@@ -171,11 +171,11 @@ class ConfigTest(unittest.TestCase):
def test_reads_the_statuses_of_an_issue_whose_pull_request_into_an_epic_branch_opened_and_merged(self) -> None:
self.write(SETTINGS)
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.pull_open_status, found.pull_merged_status), (None, None))
self.write(SETTINGS + 'jira-unblocking-statuses = ["release ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual((found.pull_open_status, found.pull_merged_status), ("Code Review", "Release Ready"))
@@ -243,8 +243,8 @@ class ConfigTest(unittest.TestCase):
self.assertIn(f"`{name}` is", self.failure())
def test_keeps_the_credentials_outside_every_config_folder_and_the_clone_folder(self) -> None:
(self.home / ".claude-projects" / "acme").mkdir()
for env_file in ("~/.claude-projects/do-epic/jira.env", "~/.claude-projects/acme/jira.env", "~/code/acme/jira.env"):
(self.home / ".config/build-release" / "acme").mkdir()
for env_file in ("~/.config/build-release/do-epic/jira.env", "~/.config/build-release/acme/jira.env", "~/code/acme/jira.env"):
with self.subTest(env_file):
self.write(SETTINGS.replace("~/jira.env", env_file))
self.assertIn("`env-file` is", self.failure())
@@ -254,14 +254,14 @@ class ConfigTest(unittest.TestCase):
self.assertIn("`env-file` is", self.failure())
def test_accepts_credentials_beside_the_config_folders(self) -> None:
self.write(SETTINGS.replace("~/jira.env", "~/.claude-projects/do-epic.env"))
found = load(self.home)
self.write(SETTINGS.replace("~/jira.env", "~/.config/build-release/do-epic.env"))
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.env_file, self.home / ".claude-projects" / "do-epic.env")
self.assertEqual(found.env_file, self.home / ".config/build-release" / "do-epic.env")
def test_refuses_while_the_routing_ladder_cannot_be_read(self) -> None:
self.write()
found = load(self.home, self.home / "no-ladder.json")
found = load(self.home, {}, self.home / "no-ladder.json")
assert isinstance(found, Failure), found
self.assertIn("no-ladder.json", found.reason)
@@ -276,12 +276,12 @@ class ConfigTest(unittest.TestCase):
ladder = self.home / "ladder.json"
ladder.write_text('[{"model": "claude-sonnet-5-5", "effort": "low"}, {"model": "claude-opus-5-5", "effort": "low"}]', encoding="utf-8")
self.write(SETTINGS.replace("claude-opus-5-5", "claude-haiku-5-5"))
found = load(self.home, ladder)
found = load(self.home, {}, ladder)
assert isinstance(found, Failure), found
self.assertIn("not a model on the routing ladder: claude-opus-5-5, claude-sonnet-5-5.", found.reason)
def test_reads_the_rule_and_the_settings_as_utf8(self) -> None:
self.write(SETTINGS + 'language = "Svenska"\n', rule="Etiketten är repots namn.\n")
found = load(self.home)
found = load(self.home, {})
assert isinstance(found, DoEpicConfig), found
self.assertEqual(found.repo_rule, "Etiketten är repots namn.\n")