ci: fix dependencies
This commit is contained in:
@@ -44,8 +44,8 @@ sh_test(
|
||||
size = "small",
|
||||
srcs = ["verify_data_shape.sh"],
|
||||
args = [
|
||||
"$(location //internal:bun_binary.bzl)",
|
||||
"$(location //tests/binary_test:BUILD.bazel)",
|
||||
"$(rlocationpath //internal:bun_binary.bzl)",
|
||||
"$(rlocationpath //tests/binary_test:BUILD.bazel)",
|
||||
],
|
||||
data = [
|
||||
"//internal:bun_binary.bzl",
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const pathValue = process.env.PATH ?? "";
|
||||
|
||||
function commandSucceeds(command: string, args: string[]): boolean {
|
||||
const result = spawnSync(command, args, {
|
||||
encoding: "utf8",
|
||||
env: process.env,
|
||||
});
|
||||
return result.status === 0;
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({
|
||||
hasHostSentinel: pathValue.includes("rules_bun_host_path_sentinel"),
|
||||
canRunBun: commandSucceeds("bun", ["-e", "process.exit(0)"]),
|
||||
canRunBunx: commandSucceeds("bunx", ["--version"]),
|
||||
canRunNode: commandSucceeds("node", ["-e", "process.exit(0)"]),
|
||||
}));
|
||||
|
||||
@@ -8,12 +8,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -7,12 +7,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
cmd.exe /c "${command}" | tr -d '\r'
|
||||
cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
"${launcher}" "$@"
|
||||
|
||||
@@ -8,12 +8,7 @@ run_launcher() {
|
||||
local launcher="$1"
|
||||
shift
|
||||
if [[ ${launcher} == *.cmd ]]; then
|
||||
local command
|
||||
printf -v command '"%s"' "${launcher}"
|
||||
for arg in "$@"; do
|
||||
printf -v command '%s "%s"' "${command}" "${arg}"
|
||||
done
|
||||
env PATH="rules_bun_host_path_sentinel:${PATH:-}" cmd.exe /c "${command}" | tr -d '\r'
|
||||
env PATH="rules_bun_host_path_sentinel:${PATH:-}" cmd.exe /c call "${launcher}" "$@" | tr -d '\r'
|
||||
return 0
|
||||
fi
|
||||
env PATH="rules_bun_host_path_sentinel:${PATH:-}" "${launcher}" "$@"
|
||||
@@ -22,12 +17,12 @@ run_launcher() {
|
||||
default_output="$(run_launcher "${default_binary}")"
|
||||
inherit_output="$(run_launcher "${inherit_binary}")"
|
||||
|
||||
if [[ ${default_output} != '{"hasHostSentinel":false}' ]]; then
|
||||
if [[ ${default_output} != '{"hasHostSentinel":false,"canRunBun":true,"canRunBunx":true,"canRunNode":true}' ]]; then
|
||||
echo "Expected default launcher to hide host PATH, got: ${default_output}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${inherit_output} != '{"hasHostSentinel":true}' ]]; then
|
||||
if [[ ${inherit_output} != '{"hasHostSentinel":true,"canRunBun":true,"canRunBunx":true,"canRunNode":true}' ]]; then
|
||||
echo "Expected inherit_host_path launcher to preserve host PATH, got: ${inherit_output}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,8 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
rule_file="$1"
|
||||
build_file="$2"
|
||||
if [[ -z ${RUNFILES_DIR:-} && -n ${TEST_SRCDIR:-} && -d ${TEST_SRCDIR} ]]; then
|
||||
RUNFILES_DIR="${TEST_SRCDIR}"
|
||||
fi
|
||||
if [[ -z ${RUNFILES_DIR:-} && -z ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
if [[ -d "$0.runfiles" ]]; then
|
||||
RUNFILES_DIR="$0.runfiles"
|
||||
elif [[ -f "$0.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
|
||||
elif [[ -f "$0.exe.runfiles_manifest" ]]; then
|
||||
RUNFILES_MANIFEST_FILE="$0.exe.runfiles_manifest"
|
||||
fi
|
||||
fi
|
||||
|
||||
resolve_runfile() {
|
||||
local path="${1:-}"
|
||||
local candidate
|
||||
local resolved
|
||||
|
||||
if [[ -z ${path} ]]; then
|
||||
echo "Error: missing runfile path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ${path} == /* || ${path} =~ ^[A-Za-z]:[\\/] ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -e ${path} ]]; then
|
||||
printf '%s\n' "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for candidate in \
|
||||
"${path}" \
|
||||
"${TEST_WORKSPACE:-}/${path}" \
|
||||
"_main/${path}"; do
|
||||
[[ -z ${candidate} ]] && continue
|
||||
if [[ -n ${RUNFILES_DIR:-} && -e "${RUNFILES_DIR}/${candidate}" ]]; then
|
||||
printf '%s\n' "${RUNFILES_DIR}/${candidate}"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n ${RUNFILES_MANIFEST_FILE:-} ]]; then
|
||||
resolved="$(
|
||||
awk -v key="${candidate}" 'index($0, key " ") == 1 { print substr($0, length(key) + 2); exit }' \
|
||||
"${RUNFILES_MANIFEST_FILE}"
|
||||
)"
|
||||
if [[ -n ${resolved} ]]; then
|
||||
printf '%s\n' "${resolved}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Error: unable to resolve runfile: ${path}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
rule_file="$(resolve_runfile "${1:-}")"
|
||||
build_file="$(resolve_runfile "${2:-}")"
|
||||
|
||||
grep -Eq 'extra_files = ctx\.files\.data \+ ctx\.files\.preload \+ ctx\.files\.env_files \+ \[bun_bin\]' "${rule_file}"
|
||||
grep -Eq 'name = "hello_js_with_data_bin"' "${build_file}"
|
||||
|
||||
Reference in New Issue
Block a user