Menu
Public repository / 5526f1231762e5175b9d0a8a7a09a61be31302ef
AkurAI-IDP / scripts/lint-sibling-deps.sh
Latest change 8bb2011e5a8f4daabce95da310f1021e9529069c - OLI-188: roll out lint-config CI job and sibling-dep lint by Ólafur Búi Ólafsson
#!/bin/sh
# Fails when a Cargo.toml path dependency escapes the repo into a sibling that .akurai.yml never checks out.
set -eu
root="$(pwd -P)"
yml="${1:-.akurai.yml}"
status=0
missing="$(find . -name Cargo.toml -not -path '*/target/*' -not -path '*/node_modules/*' | while read -r manifest; do
dir="$(dirname "$manifest")"
sed -nE 's/.*path[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' "$manifest" | while read -r rel; do
target="$(realpath -m "$dir/$rel")"
case "$target" in "$root"|"$root"/*) continue ;; esac
rest="${target#"$(dirname "$root")"/}"
echo "${rest%%/*}"
done
done | sort -u)"
for sibling in $missing; do
grep -qF "../$sibling" "$yml" 2>/dev/null || { echo "lint-sibling-deps: path dependency on sibling '$sibling' but $yml never checks out ../$sibling" >&2; status=1; }
done
exit "$status"