Skip to content

The agent that grows with you

test(e2e): Windows journey teardown frees the install even when the artifact copy fails

Tekniumd815531ed7fd
diff --git a/.github/workflows/windows-install-update-e2e.yml b/.github/workflows/windows-install-update-e2e.yml
index 26b7075d90c..ed98a364082 100644
--- a/.github/workflows/windows-install-update-e2e.yml
+++ b/.github/workflows/windows-install-update-e2e.yml
@@ -109,6 +109,7 @@ jobs:
Get-Content -LiteralPath $manifest
- name: No machine install left behind
+ if: always()
# Each journey's teardown deletes its fake profile (a full install: checkout, venv with
# every extra, PM tools, caches) and its serve.git. All of them on the runner's one drive
# outgrew its free space once the suite reached 13 files (run 39853224877: 92 MB left).
diff --git a/tests/e2e/core/windows_update/_machine.py b/tests/e2e/core/windows_update/_machine.py
index 5be18a638dd..a8c6038082f 100644
--- a/tests/e2e/core/windows_update/_machine.py
+++ b/tests/e2e/core/windows_update/_machine.py
@@ -576,23 +576,27 @@ class Machine:
except OSError:
pass
artifacts = os.environ.get("HERMES_E2E_ARTIFACTS")
- if artifacts:
- dest = Path(artifacts) / self.root.name
- shutil.copytree(self.logs, dest / "transcripts", dirs_exist_ok=True)
- for sub in ("logs",):
- src = self.hermes_home / sub
- if src.is_dir():
- shutil.copytree(src, dest / sub, dirs_exist_ok=True,
- ignore=shutil.ignore_patterns("*.db", "*.db-*"))
- (dest / "evidence.txt").write_text(self.evidence(), encoding="utf-8", errors="replace")
- (dest / "timings.json").write_text(json.dumps(self.timings, indent=1), encoding="utf-8")
- # Every machine is a full install (checkout, venv with every extra, PM tools, caches) on the
- # runner's only drive; kept, they add up past its free space before the last file runs.
- # The transcripts stay (small, and the only record when no artifacts dir is set).
- leftovers = [note for tree in (self.profile, self.serve) if (note := _remove_tree(tree))]
- if leftovers: # the job's "No machine install left behind" step names these
- dest = Path(artifacts) / self.root.name if artifacts else self.logs
- (dest / "teardown-leftovers.txt").write_text("\n".join(leftovers) + "\n", encoding="utf-8")
+ try:
+ if artifacts:
+ dest = Path(artifacts) / self.root.name
+ shutil.copytree(self.logs, dest / "transcripts", dirs_exist_ok=True)
+ for sub in ("logs",):
+ src = self.hermes_home / sub
+ if src.is_dir():
+ shutil.copytree(src, dest / sub, dirs_exist_ok=True,
+ ignore=shutil.ignore_patterns("*.db", "*.db-*"))
+ (dest / "evidence.txt").write_text(self.evidence(), encoding="utf-8", errors="replace")
+ (dest / "timings.json").write_text(json.dumps(self.timings, indent=1), encoding="utf-8")
+ finally:
+ # Every machine is a full install (checkout, venv with every extra, PM tools, caches) on
+ # the runner's only drive; kept, they add up past its free space before the last file
+ # runs. A failed artifact copy (a full disk) must not keep the install. The transcripts
+ # stay (small, and the only record when no artifacts dir is set).
+ leftovers = [note for tree in (self.profile, self.serve) if (note := _remove_tree(tree))]
+ if leftovers: # the job's "No machine install left behind" step names these
+ dest = Path(artifacts) / self.root.name if artifacts else self.logs
+ dest.mkdir(parents=True, exist_ok=True)
+ (dest / "teardown-leftovers.txt").write_text("\n".join(leftovers) + "\n", encoding="utf-8")
def _remove_tree(path: Path) -> str | None: