feat(gitea): add the gitea role #284

Merged
Defame1297 merged 3 commits from feat/gitea-role into main 2026-11-21 22:44:08 +00:00
Showing only changes of commit a197536ba6 - Show all commits
+26 -10
View File
@@ -98,24 +98,40 @@ ALL = [
class SelectTest(unittest.TestCase):
# A fixture tree with the roles of ALL and no use of one role by another, so that the
# expectations do not depend on which roles of this repository use which (UsersTest
# covers the users).
def setUp(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
self.root = tmp.name
for scenario in ALL:
pathlib.Path(self.root, scenario).mkdir(parents=True)
pathlib.Path(self.root, scenario, "molecule.yml").write_text("---\n")
if scenario.startswith("roles/"):
tasks = pathlib.Path(self.root, *scenario.split("/")[:2], "tasks")
tasks.mkdir()
(tasks / "main.yml").write_text("---\n")
def select(self, changed):
return sel.select(ALL, changed, self.root)
def test_role_change_selects_only_that_role(self):
chosen, _reason = sel.select(
ALL,
chosen, _reason = self.select(
["roles/docker/tasks/main.yml", "roles/docker/molecule/default/verify.yml"],
)
self.assertEqual(chosen, ["roles/docker/molecule/default"])
def test_two_roles(self):
chosen, _reason = sel.select(
ALL, ["roles/fail2ban/defaults/main.yml", "roles/docker/meta/main.yml"]
chosen, _reason = self.select(
["roles/fail2ban/defaults/main.yml", "roles/docker/meta/main.yml"]
)
self.assertEqual(
chosen, ["roles/docker/molecule/default", "roles/fail2ban/molecule/default"]
)
def test_ignored_only_selects_nothing(self):
chosen, _reason = sel.select(
ALL,
chosen, _reason = self.select(
[
"docs/x.md",
"changelogs/fragments/a.yml",
@@ -126,7 +142,7 @@ class SelectTest(unittest.TestCase):
self.assertEqual(chosen, [])
def test_ignored_does_not_mask_a_role(self):
chosen, _reason = sel.select(ALL, ["docs/x.md", "roles/docker/tasks/main.yml"])
chosen, _reason = self.select(["docs/x.md", "roles/docker/tasks/main.yml"])
self.assertEqual(chosen, ["roles/docker/molecule/default"])
def test_anything_else_selects_everything(self):
@@ -141,15 +157,15 @@ class SelectTest(unittest.TestCase):
"new_top_level_file",
"roles/README.md",
):
chosen, _reason = sel.select(ALL, ["roles/docker/tasks/main.yml", path])
chosen, _reason = self.select(["roles/docker/tasks/main.yml", path])
self.assertEqual(chosen, ALL, path)
def test_deleted_role_selects_nothing_of_its_own(self):
chosen, _reason = sel.select(ALL, ["roles/gone/tasks/main.yml"])
chosen, _reason = self.select(["roles/gone/tasks/main.yml"])
self.assertEqual(chosen, [])
def test_ignored_patterns_are_not_prefix_tricks(self):
chosen, _reason = sel.select(ALL, ["docsx/y"])
chosen, _reason = self.select(["docsx/y"])
self.assertEqual(chosen, ALL)