Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(scripts): handle cargo tree failures in TLS dependency check

Steven Enamakel4b56cd8e21b3
diff --git a/scripts/__tests__/check-linux-tls-dependencies.test.mjs b/scripts/__tests__/check-linux-tls-dependencies.test.mjs
index d6c773c2c2..ba5f2df91d 100644
--- a/scripts/__tests__/check-linux-tls-dependencies.test.mjs
+++ b/scripts/__tests__/check-linux-tls-dependencies.test.mjs
@@ -37,7 +37,7 @@ const CLEAN_TREE = [
/**
* A temporary tree holding the cargo stub and the fixtures it answers from.
*
- * @param {{core?: string, tauri?: string, owners?: Record<string, string>}} fixtures
+ * @param {{core?: string, tauri?: string, owners?: Record<string, string>, failCore?: boolean, failInvert?: string}} fixtures
* `core` / `tauri` are the `cargo tree --prefix none` output for each
* Cargo world; `owners` maps a `--invert` target to its output.
*/
@@ -49,6 +49,10 @@ function makeTree(fixtures) {
fs.mkdirSync(owners, { recursive: true });
fs.writeFileSync(path.join(root, "tree.core"), fixtures.core ?? CLEAN_TREE);
fs.writeFileSync(path.join(root, "tree.tauri"), fixtures.tauri ?? CLEAN_TREE);
+ if (fixtures.failCore) fs.writeFileSync(path.join(root, "fail-core"), "");
+ if (fixtures.failInvert) {
+ fs.writeFileSync(path.join(root, "fail-invert"), fixtures.failInvert);
+ }
for (const [target, text] of Object.entries(fixtures.owners ?? {})) {
fs.writeFileSync(path.join(owners, target), text);
}
@@ -68,11 +72,20 @@ while [ $# -gt 0 ]; do
shift
done
if [ -n "$inverted" ]; then
+ if [ -f "${root}/fail-invert" ] && [ "$inverted" = "$(cat "${root}/fail-invert")" ]; then
+ echo "cargo tree failed" >&2
+ exit 7
+ fi
[ -f "${owners}/$inverted" ] && cat "${owners}/$inverted"
exit 0
fi
case "$manifest" in
- Cargo.toml) cat "${root}/tree.core" ;;
+ Cargo.toml)
+ if [ -f "${root}/fail-core" ]; then
+ echo "cargo tree failed" >&2
+ exit 7
+ fi
+ cat "${root}/tree.core" ;;
*) cat "${root}/tree.tauri" ;;
esac
`,
@@ -164,4 +177,31 @@ for (const interpreter of interpreters) {
assert.equal(result.status, 1);
assert.match(result.stderr, /aws-lc dependencies found in core/);
});
+
+ test(`[${interpreter} ${version}] a failed dependency tree is a check error`, SKIP, () => {
+ const tree = makeTree({ failCore: true });
+ const result = run(interpreter, tree);
+ assert.equal(result.status, 2);
+ assert.match(result.stderr, /could not check core dependency tree/);
+ });
+
+ test(`[${interpreter} ${version}] a failed reqwest owner query is a check error`, SKIP, () => {
+ const tree = makeTree({
+ tauri: "reqwest v0.13.2",
+ failInvert: "[email protected]",
+ });
+ const result = run(interpreter, tree);
+ assert.equal(result.status, 2);
+ assert.match(result.stderr, /could not check reqwest 0\.13\.2 owners in tauri/);
+ });
+
+ test(`[${interpreter} ${version}] a failed TLS owner query is a check error`, SKIP, () => {
+ const tree = makeTree({
+ tauri: "native-tls v0.2.14",
+ failInvert: "native-tls",
+ });
+ const result = run(interpreter, tree);
+ assert.equal(result.status, 2);
+ assert.match(result.stderr, /could not check native-tls owners in tauri/);
+ });
}
diff --git a/scripts/check-linux-tls-dependencies.sh b/scripts/check-linux-tls-dependencies.sh
index 17067265e7..5412c7710e 100755
--- a/scripts/check-linux-tls-dependencies.sh
+++ b/scripts/check-linux-tls-dependencies.sh
@@ -8,7 +8,10 @@ check_world() {
local label="$1"
local manifest="$2"
local tree
- tree="$(cargo tree --locked --manifest-path "$manifest" --target "$target" --prefix none)"
+ if ! tree="$(cargo tree --locked --manifest-path "$manifest" --target "$target" --prefix none)"; then
+ printf 'error: could not check %s dependency tree for %s\n' "$label" "$target" >&2
+ exit 2
+ fi
if matches="$(printf '%s\n' "$tree" | grep -E "$forbidden")"; then
printf 'error: aws-lc dependencies found in %s for %s:\n%s\n' \
"$label" "$target" "$matches" >&2
@@ -42,10 +45,13 @@ check_world() {
sort -u
)
for version in ${reqwest_013_versions[@]+"${reqwest_013_versions[@]}"}; do
- owners="$(
+ if ! owners="$(
cargo tree --locked --manifest-path "$manifest" --target "$target" \
- --prefix none --invert "reqwest@$version" 2>/dev/null || true
- )"
+ --prefix none --invert "reqwest@$version"
+ )"; then
+ printf 'error: could not check reqwest %s owners in %s\n' "$version" "$label" >&2
+ exit 2
+ fi
if printf '%s\n' "$owners" | grep -Eq '^sentry v'; then
printf 'error: Sentry owns reqwest %s in %s\n%s\n' \
"$version" "$label" "$owners" >&2
@@ -54,10 +60,17 @@ check_world() {
done
for package in native-tls openssl openssl-sys; do
- owners="$(
+ # Cargo returns an error for --invert when the package is absent.
+ if ! printf '%s\n' "$tree" | grep -Eq "^${package} v"; then
+ continue
+ fi
+ if ! owners="$(
cargo tree --locked --manifest-path "$manifest" --target "$target" \
- --prefix none --invert "$package" 2>/dev/null || true
- )"
+ --prefix none --invert "$package"
+ )"; then
+ printf 'error: could not check %s owners in %s\n' "$package" "$label" >&2
+ exit 2
+ fi
if printf '%s\n' "$owners" | grep -Eq '^sentry v'; then
printf 'error: Sentry owns %s in %s\n%s\n' \
"$package" "$label" "$owners" >&2