Adds a Gihub Actions workflow to test for XML encoding errors #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Quality Assurance | |
on: | |
pull_request: | |
push: | |
branches: master | |
jobs: | |
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) | |
... |