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
16 changes: 12 additions & 4 deletions scripts/clean-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,20 @@ clean_aube_metadata_cache() {
fi
}

# Function to safely clean ALL aube caches — metadata cache, package index,
# virtual-store (all under ~/.cache/aube/) AND the global content-addressable
# store (~/.aube-store/). Used in "clean" (fully cold) variations.
# Function to safely clean ALL aube caches, including the configured store.
# Current releases put content and package indexes under the XDG data directory;
# metadata and the global virtual store live under the XDG cache directory.
# Keep cleaning ~/.aube-store for older releases too.
clean_aube_cache() {
clean_aube_metadata_cache
safe_remove "$HOME/.cache/aube"
if command -v aube &> /dev/null; then
local store_path
store_path="$(aube store path 2>/dev/null)" || store_path=""
if [ -n "$store_path" ]; then
safe_remove "$store_path"
fi
fi
safe_remove "${XDG_CACHE_HOME:-$HOME/.cache}/aube"
safe_remove "$HOME/.aube-store"
}

Expand Down
88 changes: 88 additions & 0 deletions scripts/clean-helpers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const { spawnSync } = require("node:child_process");
const test = require("node:test");

for (const scenario of [
{
name: "configured store with spaces",
command: "clean_aube_cache",
store: true,
},
{ name: "unavailable store path", command: "clean_aube_cache", store: false },
{
name: "metadata-only cleanup",
command: "clean_aube_metadata_cache",
store: true,
},
]) {
test(`aube cache cleanup: ${scenario.name}`, (t) => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "aube-clean-test-"));
t.after(() => fs.rmSync(tempDir, { recursive: true, force: true }));
const binDir = path.join(tempDir, "bin");
const store = path.join(tempDir, "custom store", "v1");
const cache = path.join(tempDir, "xdg cache");
const removeLog = path.join(tempDir, "removed.txt");
const commandLog = path.join(tempDir, "commands.txt");
fs.mkdirSync(binDir);
fs.writeFileSync(removeLog, "");
fs.writeFileSync(
path.join(binDir, "aube"),
`#!/bin/sh
printf '%s\\n' "$*" >> "$COMMAND_LOG"
if [ "$1" = store ]; then
[ "$STORE_AVAILABLE" = 1 ] || exit 1
printf '%s\\n' "$TEST_STORE"
fi
`,
{ mode: 0o755 },
);

// Record deletion targets so the test never touches the user's caches.
const result = spawnSync(
"bash",
[
"-c",
`
source "$HELPERS" >/dev/null
safe_remove() { printf '%s\\n' "$1" >> "$REMOVE_LOG"; }
"$CLEAN_COMMAND"
`,
],
{
encoding: "utf8",
env: {
...process.env,
PATH: `${binDir}${path.delimiter}${process.env.PATH}`,
HELPERS: path.join(__dirname, "clean-helpers.sh"),
TEST_STORE: store,
STORE_AVAILABLE: scenario.store ? "1" : "0",
XDG_CACHE_HOME: cache,
REMOVE_LOG: removeLog,
COMMAND_LOG: commandLog,
CLEAN_COMMAND: scenario.command,
},
},
);
assert.equal(result.status, 0, result.stderr);
const removed = fs
.readFileSync(removeLog, "utf8")
.trim()
.split("\n")
.filter(Boolean);
const commands = fs.readFileSync(commandLog, "utf8").trim().split("\n");
if (scenario.command === "clean_aube_metadata_cache") {
assert.deepEqual(removed, []);
assert.deepEqual(commands, ["cache delete *"]);
} else {
assert.deepEqual(removed, [
...(scenario.store ? [store] : []),
path.join(cache, "aube"),
path.join(os.homedir(), ".aube-store"),
]);
assert.deepEqual(commands, ["cache delete *", "store path"]);
}
});
}
4 changes: 2 additions & 2 deletions scripts/variations/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BENCH_CI_PACQUET="/tmp/pnpm12/bin/pnpm install --frozen-lockfile --ignore-script
BENCH_CI_VLT="vlt ci --view=silent"
BENCH_CI_BUN="bun install --frozen-lockfile --ignore-scripts --silent"
BENCH_CI_DENO="deno install --frozen --quiet"
BENCH_CI_AUBE="aube ci --silent"
BENCH_CI_AUBE="aube ci --ignore-scripts --silent"

# Override BENCH_COMMAND_* with CI commands + log redirection
BENCH_COMMAND_NPM="timeout $BENCH_TIMEOUT $BENCH_CI_NPM >> $BENCH_OUTPUT_FOLDER/npm-output-\${HYPERFINE_ITERATION}.log 2>&1"
Expand Down Expand Up @@ -93,7 +93,7 @@ BENCH_PREPARE_PACQUET="$(ci_prepare "$BENCH_SETUP_PACQUET" "/tmp/pnpm12/bin/pnpm
BENCH_PREPARE_VLT="$(ci_prepare "$BENCH_SETUP_VLT" "vlt install --view=silent")"
BENCH_PREPARE_BUN="$(ci_prepare "$BENCH_SETUP_BUN" "bun install --ignore-scripts --silent")"
BENCH_PREPARE_DENO="$(ci_prepare "$BENCH_SETUP_DENO" "deno install --quiet")"
BENCH_PREPARE_AUBE="$(ci_prepare "$BENCH_SETUP_AUBE" "aube install --silent")"
BENCH_PREPARE_AUBE="$(ci_prepare "$BENCH_SETUP_AUBE" "aube install --ignore-scripts --silent")"

# Run the benchmark suite
hyperfine --ignore-failure \
Expand Down
3 changes: 2 additions & 1 deletion scripts/variations/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ BENCH_SETUP_NODE=""
# measure dependency resolution + linking only (not arbitrary postinstall work).
# npm, yarn classic, bun: run scripts by default → --ignore-scripts
# pnpm v11+: errors on ignored build scripts (ERR_PNPM_IGNORED_BUILDS) → --ignore-scripts
# aube: runs scripts for its default trusted dependencies → --ignore-scripts
# berry, zpm, vlt: don't run scripts by default → no flag needed
# deno: doesn't run scripts by default → removed --allow-scripts
BENCH_INSTALL_NPM="npm install --no-audit --no-fund --ignore-scripts --silent"
Expand All @@ -103,7 +104,7 @@ BENCH_INSTALL_PACQUET="/tmp/pnpm12/bin/pnpm install --ignore-scripts --silent"
BENCH_INSTALL_VLT="vlt install --view=silent"
BENCH_INSTALL_BUN="bun install --ignore-scripts --silent"
BENCH_INSTALL_DENO="deno install --quiet"
BENCH_INSTALL_AUBE="aube install --silent"
BENCH_INSTALL_AUBE="aube install --ignore-scripts --silent"

BENCH_COMMAND_NPM="timeout $BENCH_TIMEOUT $BENCH_INSTALL_NPM >> $BENCH_OUTPUT_FOLDER/npm-output-\${HYPERFINE_ITERATION}.log 2>&1"
BENCH_COMMAND_YARN="timeout $BENCH_TIMEOUT $BENCH_INSTALL_YARN > $BENCH_OUTPUT_FOLDER/yarn-output-\${HYPERFINE_ITERATION}.log 2>&1"
Expand Down
Loading