Skip to content

Commit 7e77145

Browse files
committed
CI: Add xmllint for XML schemas
This patch adds a CI linter for our XML schemas, which would have caught the style issues fixed by the two previous patches. The linter does two separate checks: first, it verifies that all the schemas are valid XML, and then it verifies that they are all valid XML schemas. Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
1 parent 872005b commit 7e77145

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,67 @@ jobs:
9191
9292
echo "✅ All .mem files are sorted."
9393
94+
xsd_schema_check:
95+
runs-on: ubuntu-slim
96+
name: XSD Schema Check
97+
steps:
98+
- name: Checkout repository
99+
uses: actions/checkout@v6
100+
101+
- name: Install xmllint
102+
run: |
103+
sudo apt-get update
104+
sudo apt-get install -y --no-install-recommends libxml2-utils
105+
106+
- name: Validate XSD schemas with xmllint
107+
run: |
108+
#!/usr/bin/env bash
109+
set -euo pipefail
110+
111+
echo "Validating all .xsd files under src/ with xmllint..."
112+
113+
# Find all XSD schemas tracked in the source tree.
114+
files=$(find src -type f -name "*.xsd" | sort)
115+
116+
if [ -z "$files" ]; then
117+
echo "No .xsd files found under src/."
118+
exit 0
119+
fi
120+
121+
failed=0
122+
123+
for f in $files; do
124+
echo "→ $f"
125+
126+
# 1. Well-formedness: the file must be valid XML.
127+
if ! xmllint --noout "$f"; then
128+
echo "❌ Not well-formed XML: $f"
129+
failed=1
130+
continue
131+
fi
132+
133+
# 2. Schema validity: compile the file as an XML Schema. Loading it
134+
# via --schema forces libxml2 to compile the schema, surfacing
135+
# structural XSD errors (unknown types, dangling refs, etc.). The
136+
# file is passed as its own instance document only because
137+
# xmllint requires one; the instance result is irrelevant, so we
138+
# key on schema *compilation* failures alone.
139+
out=$(xmllint --noout --schema "$f" "$f" 2>&1 || true)
140+
if echo "$out" | grep -Eq "parser error|failed to compile"; then
141+
echo "❌ Invalid XML Schema: $f"
142+
echo "$out" | grep -E "parser error|failed to compile" || true
143+
failed=1
144+
fi
145+
done
146+
147+
if [ "$failed" -ne 0 ]; then
148+
echo
149+
echo "Some XSD schemas failed validation."
150+
exit 1
151+
fi
152+
153+
echo "✅ All XSD schemas are well-formed and valid."
154+
94155
cpp_formatting_check:
95156
name: C++ Formatting Check
96157
runs-on: ubuntu-26.04

0 commit comments

Comments
 (0)