fix(build): read the symbol graph from SwiftPM and say why a build fails

This commit is contained in:
Mihaela M 2026-11-03 12:38:42 +01:00
parent 7992c104a5
commit 1572307de9

View File

@ -13,17 +13,28 @@ set -euo pipefail
cd "$(dirname "$0")/.."
MANIFEST="scripts/validation-coverage.tsv"
GRAPH_DIR=".build/symbolgraph"
GRAPH_DIR=".build/out/symbolgraph"
if [[ ! -f "$MANIFEST" ]]; then
echo "check-validation-coverage: missing manifest $MANIFEST" >&2
exit 1
fi
mkdir -p "$GRAPH_DIR"
swift build --target PureYAML \
-Xswiftc -emit-symbol-graph \
-Xswiftc -emit-symbol-graph-dir -Xswiftc "$GRAPH_DIR" >/dev/null
# SwiftPM's own command writes the graph for every toolchain. Passing the compiler flags through
# -Xswiftc wrote nothing on Swift 6.4 and the gate then failed with no message. Its output is kept
# so a failed build says why, and a missing graph is named.
log=$(mktemp)
trap 'rm -f "$log"' EXIT
if ! swift package dump-symbol-graph >"$log" 2>&1; then
cat "$log" >&2
echo "check-validation-coverage: swift package dump-symbol-graph failed" >&2
exit 1
fi
if [[ ! -f "$GRAPH_DIR/PureYAML.symbols.json" ]]; then
cat "$log" >&2
echo "check-validation-coverage: no symbol graph at $GRAPH_DIR/PureYAML.symbols.json" >&2
exit 1
fi
python3 - "$GRAPH_DIR/PureYAML.symbols.json" "$MANIFEST" <<'PY'
import json