mirror of
https://github.com/Theodor-Springmann-Stiftung/KGPZ.git
synced 2025-10-29 00:55:31 +00:00
+ Github annotations
This commit is contained in:
16
.github/workflows/XML_lint.yml
vendored
16
.github/workflows/XML_lint.yml
vendored
@@ -25,7 +25,17 @@ jobs:
|
||||
pip install lxml
|
||||
|
||||
- name: XSD-Schema-Validierung
|
||||
run: python Scripts/lint_validation.py
|
||||
run: python Scripts/lint_validation.py | tee validation_output.txt
|
||||
continue-on-error: true
|
||||
|
||||
- name: GitHub-Anmerkungen für XSD-Validierung erstellen
|
||||
run: cat validation_output.txt | python Scripts/annotations_validation.py
|
||||
|
||||
- name: Prüfe auf Validierungsfehler
|
||||
run: |
|
||||
if grep -q "Validierung fehlgeschlagen" validation_output.txt; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Verweise:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -44,3 +54,7 @@ jobs:
|
||||
|
||||
- name: Verweise prüfen
|
||||
run: python Scripts/lint_verweise.py
|
||||
|
||||
- name: GitHub-Anmerkungen für Referenzprüfung erstellen
|
||||
if: failure()
|
||||
run: python Scripts/annotations_references.py
|
||||
|
||||
17
Scripts/annotations_references.py
Normal file
17
Scripts/annotations_references.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
def main():
|
||||
if not os.path.exists('reference_check_errors.txt'):
|
||||
print("Keine Referenzprüfungs-Ergebnisse gefunden.")
|
||||
return
|
||||
|
||||
with open('reference_check_errors.txt', 'r') as f:
|
||||
for line in f:
|
||||
parts = line.strip().split(', Zeile ')
|
||||
if len(parts) == 2:
|
||||
file_path, rest = parts
|
||||
line_number, message = rest.split(': ', 1)
|
||||
print(f"::error file={file_path},line={line_number}::{message}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
34
Scripts/annotations_validation.py
Normal file
34
Scripts/annotations_validation.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import sys
|
||||
import re
|
||||
|
||||
def parse_error_message(line):
|
||||
match = re.match(r"Validierungsfehler in (.*?):\s*", line)
|
||||
if match:
|
||||
return match.group(1), None, None, None
|
||||
|
||||
match = re.match(r"\s*Zeile (\d+), Spalte (\d+): (.*)", line)
|
||||
if match:
|
||||
return None, int(match.group(1)), int(match.group(2)), match.group(3)
|
||||
|
||||
match = re.match(r"XML-Syntaxfehler in (.*?):\s*", line)
|
||||
if match:
|
||||
return match.group(1), None, None, None
|
||||
|
||||
match = re.match(r"\s*Zeile (\d+), Spalte (\d+): (.*)", line)
|
||||
if match:
|
||||
return None, int(match.group(1)), int(match.group(2)), match.group(3)
|
||||
|
||||
return None, None, None, None
|
||||
|
||||
def main():
|
||||
current_file = None
|
||||
for line in sys.stdin:
|
||||
file, line_num, column, message = parse_error_message(line.strip())
|
||||
|
||||
if file:
|
||||
current_file = file
|
||||
elif line_num and column and message and current_file:
|
||||
print(f"::error file={current_file},line={line_num},col={column}::{message}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -11,7 +11,7 @@ def parse_xml_file(filepath):
|
||||
tree = etree.parse(filepath, parser)
|
||||
return tree.getroot()
|
||||
except etree.ParseError as e:
|
||||
print(f"Error parsing {filepath}: {e}")
|
||||
print(f"Fehler beim Parsen von {filepath}: {e}")
|
||||
return None
|
||||
|
||||
def get_all_ids(root, tag):
|
||||
@@ -26,7 +26,7 @@ def check_references(beitrag_root, reference_data, filepath):
|
||||
ref_id = ref.get('ref')
|
||||
if ref_id not in reference_data[ref_type]:
|
||||
line_number = ref.sourceline
|
||||
errors.append(f"{relative_path}, Line {line_number}: INVALID REFERENCE ({ref_type}:{ref_id})")
|
||||
errors.append(f"{relative_path}, Zeile {line_number}: UNGÜLTIGER VERWEIS ({ref_type}:{ref_id})")
|
||||
return errors
|
||||
|
||||
def main():
|
||||
@@ -51,12 +51,15 @@ def main():
|
||||
all_errors.sort()
|
||||
|
||||
if all_errors:
|
||||
print("Linter found the following errors:")
|
||||
print("Der Linter hat folgende Fehler gefunden:")
|
||||
for error in all_errors:
|
||||
print(error)
|
||||
exit(1) # Exit with error code if there are any errors
|
||||
with open('reference_check_errors.txt', 'w') as f:
|
||||
for error in all_errors:
|
||||
f.write(f"{error}\n")
|
||||
exit(1) # Beenden mit Fehlercode, wenn Fehler gefunden wurden
|
||||
else:
|
||||
print("No errors found.")
|
||||
print("Keine Fehler gefunden.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import os
|
||||
|
||||
def main():
|
||||
if not os.path.exists('linter_results.txt'):
|
||||
print("No linter results found.")
|
||||
return
|
||||
|
||||
with open('linter_results.txt', 'r') as f:
|
||||
for line in f:
|
||||
parts = line.strip().split(':', 2)
|
||||
if len(parts) == 3:
|
||||
filename, line_number, error_message = parts
|
||||
print(f"::error file={filename},line={line_number}::{error_message}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user