diff --git a/.github/workflows/xml-validation.yml b/.github/workflows/xml-validation.yml index 4038c2d6183a..3e30b4746d5b 100644 --- a/.github/workflows/xml-validation.yml +++ b/.github/workflows/xml-validation.yml @@ -36,3 +36,30 @@ jobs: - uses: actions/checkout@v3 - run: sudo apt-get install -y moreutils parallel - run: find APIS -name "*.xml" | parallel --gnu --will-cite -X -j8 -u "java -jar Validation/jing.jar Validation/EpiDoc/8.13/tei-epidoc.rng {}" + parse-xml: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - run: pip install lxml + - uses: jannekem/run-python-script-action@v1 + with: + script: | + from pathlib import Path + from lxml.etree import parse, XMLSyntaxError + + encountered_errors = [] + root_path = Path.cwd() + + for file in root_path.rglob("*.xml"): + try: + parse(str(file)) + except XMLSyntaxError as e: + encountered_errors.append(f"{file.relative_to(root_path)}: {e.msg}") + + if encountered_errors: + print("\nInvalid XML encodings were found:") + print("---------------------------------") + print("\n".join(encountered_errors) + "\n") + raise SystemExit(1)