feat: add phase 2 bun_install repository rule bootstrap

This commit is contained in:
Eriyc
2026-03-04 03:05:01 +00:00
committed by copilot-swe-agent[bot]
parent 14b7e8175a
commit fe21208ddf
7 changed files with 186 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
sh_test(
name = "bun_install_clean_install_test",
srcs = ["clean_install.sh"],
args = ["$(location @bun_linux_x64//:bun)"],
data = ["@bun_linux_x64//:bun"],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)
sh_test(
name = "bun_install_stale_lockfile_test",
srcs = ["stale_lockfile.sh"],
args = ["$(location @bun_linux_x64//:bun)"],
data = ["@bun_linux_x64//:bun"],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
],
)

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
bun_path="$1"
workdir="$(mktemp -d)"
trap 'rm -rf "${workdir}"' EXIT
cat > "${workdir}/package.json" <<'JSON'
{
"name": "clean-install-test",
"version": "1.0.0"
}
JSON
"${bun_path}" install --cwd "${workdir}" >/dev/null
rm -rf "${workdir}/node_modules"
"${bun_path}" install --cwd "${workdir}" --frozen-lockfile >/dev/null
if [[ ! -d "${workdir}/node_modules" ]]; then
echo "Expected node_modules to be created" >&2
exit 1
fi

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
bun_path="$1"
workdir="$(mktemp -d)"
trap 'rm -rf "${workdir}"' EXIT
cat > "${workdir}/package.json" <<'JSON'
{
"name": "stale-lockfile-test",
"version": "1.0.0"
}
JSON
"${bun_path}" install --cwd "${workdir}" >/dev/null
cat > "${workdir}/package.json" <<'JSON'
{
"name": "stale-lockfile-test",
"version": "1.0.0",
"dependencies": {
"left-pad": "1.3.0"
}
}
JSON
set +e
output="$(${bun_path} install --cwd "${workdir}" --frozen-lockfile 2>&1)"
code=$?
set -e
if [[ ${code} -eq 0 ]]; then
echo "Expected frozen lockfile install to fail when package.json changes" >&2
exit 1
fi
if [[ "${output}" != *"lockfile"* && "${output}" != *"frozen"* ]]; then
echo "Expected lockfile-related error, got:" >&2
echo "${output}" >&2
exit 1
fi