Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/action/run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ writeEnv("INTEGRATION_TEST_NITRO_CONTRACTS_BRANCH", state.contractsVersion);

const networkConfigPaths = (process.env["INPUT_NETWORK_CONFIG_PATH"] || "")
.split(",")
.map(p => p.trim())
.map((p) => p.trim())
.filter(Boolean);
for (const dest of networkConfigPaths) {
mkdirSync(dirname(dest), { recursive: true });
Expand Down
58 changes: 34 additions & 24 deletions src/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ const PROJECT_ROOT = resolve(import.meta.dirname, "../..");
const CONFIG_DIR = resolve(PROJECT_ROOT, "config");
const COMPOSE_FILE = resolve(PROJECT_ROOT, "docker/docker-compose.yaml");

function stopAllServices(): void {
console.log("[clean] Stopping Docker...");
composeDown({ composeFile: COMPOSE_FILE, projectName: "arbitrum-testnode" });
exec("docker", ["compose", "-f", COMPOSE_FILE, "-p", "arbitrum-testnode", "down", "-v"]);

console.log("[clean] Killing Anvil...");
exec("pkill", ["-f", "anvil.*--port.*8545"]);
exec("pkill", ["-f", "testnode-l1-heartbeat"]);
}

function removeConfigDirPreservingSnapshots(): void {
for (const entry of readdirSync(CONFIG_DIR)) {
if (entry === SNAPSHOTS_DIRNAME) {
continue;
}
rmSync(join(CONFIG_DIR, entry), { recursive: true, force: true });
}
}

function cleanConfigDir(purgeSnapshots: boolean): void {
if (!existsSync(CONFIG_DIR)) {
return;
}
if (purgeSnapshots) {
console.log("[clean] Removing config directory...");
rmSync(CONFIG_DIR, { recursive: true, force: true });
return;
}
console.log("[clean] Removing runtime data and preserving snapshots...");
removeConfigDirPreservingSnapshots();
}

export const cleanCli = Cli.create("clean", {
description: "Stop and remove all testnode data",
options: z.object({
Expand All @@ -20,30 +52,8 @@ export const cleanCli = Cli.create("clean", {
}),
run(c) {
stopCurrentRun(CONFIG_DIR);

console.log("[clean] Stopping Docker...");
composeDown({ composeFile: COMPOSE_FILE, projectName: "arbitrum-testnode" });
exec("docker", ["compose", "-f", COMPOSE_FILE, "-p", "arbitrum-testnode", "down", "-v"]);

console.log("[clean] Killing Anvil...");
exec("pkill", ["-f", "anvil.*--port.*8545"]);
exec("pkill", ["-f", "testnode-l1-heartbeat"]);

if (existsSync(CONFIG_DIR)) {
if (c.options.purgeSnapshots) {
console.log("[clean] Removing config directory...");
rmSync(CONFIG_DIR, { recursive: true, force: true });
} else {
console.log("[clean] Removing runtime data and preserving snapshots...");
for (const entry of readdirSync(CONFIG_DIR)) {
if (entry === SNAPSHOTS_DIRNAME) {
continue;
}
rmSync(join(CONFIG_DIR, entry), { recursive: true, force: true });
}
}
}

stopAllServices();
cleanConfigDir(c.options.purgeSnapshots ?? false);
console.log("[clean] Done.");
return { success: true };
},
Expand Down
Loading
Loading