#!/usr/bin/env bash # Chooses where a merge job keeps its dependency cache (scripts/contracts/ci-gates.ts DEPENDENCY_CACHE): the first # candidate folder on the checkout's filesystem, so pnpm hardlinks node_modules from the restored store. A store on # another filesystem is copied file by file, and a warm install took longer than a cold one (desktop: 2.1 s on the # same filesystem, 58.8 s across filesystems, 2026-11-13). A folder inside the checkout is never chosen: a cache # there would show in `git status`, the repository layout checks and the uploaded artifacts. # # scripts/ci/dependency-cache-root.sh ... # # Writes COREPACK_HOME, PNPM_CONFIG_STORE_DIR and PNPM_CONFIG_CACHE_DIR to $GITHUB_ENV and root= to # $GITHUB_OUTPUT, and logs one line: the folder, whether it shares the checkout's filesystem, each candidate's # device and the load average at the job's start (the runner shares the desktop with other work). With no # candidate on that filesystem it takes the first usable candidate, and the install still runs. set -euo pipefail workspace=$(cd "${GITHUB_WORKSPACE:?}" && pwd -P) checkout=$(stat -c %d "$workspace") chosen="" fallback="" devices="" for candidate in "$@"; do [ -n "$candidate" ] && [ -d "$candidate" ] && [ -w "$candidate" ] || continue real=$(cd "$candidate" && pwd -P) case "$real/" in "$workspace/"*) continue ;; esac device=$(stat -c %d "$real") devices="$devices $real=$device" [ -n "$fallback" ] || fallback=$real if [ -z "$chosen" ] && [ "$device" = "$checkout" ]; then chosen=$real; fi done same=yes if [ -z "$chosen" ]; then same=no chosen=${fallback:-/tmp} fi root="${chosen%/}/fe-dependency-cache" echo "dependency cache: $root (on the checkout's filesystem: $same; devices: checkout=$checkout$devices; load average at job start: $(cut -d' ' -f1-3 /proc/loadavg))" { echo "COREPACK_HOME=$root/corepack" echo "PNPM_CONFIG_STORE_DIR=$root/pnpm-store" echo "PNPM_CONFIG_CACHE_DIR=$root/pnpm-cache" } >> "${GITHUB_ENV:?}" echo "root=$root" >> "${GITHUB_OUTPUT:?}"