mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
ci(block): refuse workspace aliases before cleanup
This commit is contained in:
1 parent
12b9f2f037
commit
58347a55f0
6 files changed
+156
-61
No files matched your search
@@ -21,7 +21,7 @@ def step(text, name):
|
||||
|
||||
|
||||
def code(block):
|
||||
return textwrap.dedent(block.split(" run: |\n", 1)[1]).split("python3 - <<'PY'\n", 1)[1].rsplit("\nPY", 1)[0]
|
||||
return textwrap.dedent(block.split(" run: |\n", 1)[1]).split("\n", 1)[1].rsplit("\nPY", 1)[0]
|
||||
|
||||
|
||||
def execute(source, workspace, temp, free=None):
|
||||
@@ -49,6 +49,8 @@ class RunnerWorkspaceTests(unittest.TestCase):
|
||||
self.assertNotIn("- name:", text.split("- name: Clean job workspace", 1)[1])
|
||||
self.assertIn("working-directory: ${{ runner.temp }}", before)
|
||||
self.assertIn("working-directory: ${{ runner.temp }}", after)
|
||||
self.assertIn("python3 -I -", before)
|
||||
self.assertIn("python3 -I -", after)
|
||||
|
||||
def test_low_space_refuses_and_boundary_admits(self):
|
||||
for path in WORKFLOWS:
|
||||
@@ -87,5 +89,18 @@ class RunnerWorkspaceTests(unittest.TestCase):
|
||||
alias = root / "alias"; alias.symlink_to(work, target_is_directory=True)
|
||||
self.assertEqual(execute(source, alias, root)[0], 1)
|
||||
|
||||
def test_cleanup_refuses_symlinked_ancestors_and_preserves_external_sentinel(self):
|
||||
for path in WORKFLOWS:
|
||||
with self.subTest(workflow=path.name), tempfile.TemporaryDirectory() as temp:
|
||||
base = Path(temp)
|
||||
external = base / "external/repo/repo"; external.mkdir(parents=True)
|
||||
sentinel = external / "keep"; sentinel.write_text("outside checkout")
|
||||
alias = base / "alias"; alias.symlink_to(base / "external", target_is_directory=True)
|
||||
source = code(step(path.read_text(), "Clean job workspace"))
|
||||
rc, out = execute(source, alias / "repo/repo", base)
|
||||
self.assertTrue(sentinel.is_file(), "cleanup followed a workspace ancestor outside the checkout")
|
||||
self.assertEqual(rc, 1, out)
|
||||
self.assertIn("runner_workspace_cleanup_refused", out)
|
||||
|
||||
|
||||
if __name__ == "__main__": unittest.main()
|
||||
Reference in new issue
Block a user