Skip to content

Commit 1a668df

Browse files
authored
Add regression coverage for Copilot AWF chroot-home cleanup (#42736)
1 parent 3678d9c commit 1a668df

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

actions/setup/js/chroot_home_cleanup.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { fileURLToPath } from "url";
88
const __dirname = path.dirname(fileURLToPath(import.meta.url));
99
const POST_SCRIPT_PATH = path.join(__dirname, "..", "post.js");
1010
const CLEAN_SCRIPT_PATH = path.join(__dirname, "..", "clean.sh");
11+
const INSTALL_COPILOT_CLI_SCRIPT_PATH = path.join(__dirname, "..", "sh", "install_copilot_cli.sh");
1112

1213
const tempDirs = [];
1314

@@ -136,3 +137,19 @@ describe("clean.sh chroot-home cleanup", () => {
136137
expect(fs.readFileSync(logPath, "utf8")).toContain("-exec rm -rf -- {} +");
137138
});
138139
});
140+
141+
describe("install_copilot_cli.sh chroot-home cleanup", () => {
142+
it("cleans stale chroot-home directories before starting Copilot CLI installation", () => {
143+
const script = fs.readFileSync(INSTALL_COPILOT_CLI_SCRIPT_PATH, "utf8");
144+
145+
const ownershipFixIndex = script.indexOf('sudo chown -R "$(id -u):$(id -g)" "$COPILOT_DIR"');
146+
const cleanupBannerIndex = script.indexOf('echo "Cleaning up stale AWF chroot home directories..."');
147+
const cleanupCommandIndex = script.indexOf(
148+
"sudo find /tmp -maxdepth 1 -name 'awf-*-chroot-home' -type d -exec rm -rf -- {} + 2>/dev/null || true"
149+
);
150+
151+
expect(ownershipFixIndex).toBeGreaterThanOrEqual(0);
152+
expect(cleanupBannerIndex).toBeGreaterThan(ownershipFixIndex);
153+
expect(cleanupCommandIndex).toBeGreaterThan(cleanupBannerIndex);
154+
});
155+
});

0 commit comments

Comments
 (0)