Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .github/workflows/schema-validation.v3.2.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/validate-xml.v3.2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# GitHub Actions Workflow: Validate iTop datamodel XML v3.2
#
# This workflow runs on every pull request to the 'main' branch.
# It validates an XML data model against the corresponding XSD schema.
# The validation logic is implemented in a separate Python script.
#

name: Validate iTop datamodel XML version 3.2

on:
pull_request:
branches: [ main ]

jobs:
validate-xml:
runs-on: ubuntu-latest
env:
XSD_PATH: 3.2/itop_design.xsd
XML_PATH: test/datamodel.must-validate.xml

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Prepare Python environment
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install XML validation dependencies
run: pip install -r scripts/requirements.txt

- name: Validate XML datamodel against schema
run: python scripts/validate_xml.py $XSD_PATH $XML_PATH
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"cSpell.words": [
"addprevious",
"attcode",
"autoincrement",
"cmdb",
"CMDB",
"Combodo",
"dashlet",
"dashlets",
"datamodels",
"extkey",
"fileref",
"finalclass",
Expand All @@ -15,6 +17,7 @@
"ITSM",
"jointype",
"jqueryui",
"lxml",
"metavalue",
"metavalues",
"mgmt",
Expand All @@ -24,6 +27,7 @@
"networkflow",
"Nihilo",
"noout",
"NSMAP",
"stylesheet",
"teemip",
"timespent",
Expand Down
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lxml>=4.9.0
22 changes: 22 additions & 0 deletions scripts/validate_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import sys
import lxml.etree as ET

if len(sys.argv) != 3:
print("Usage: python validate_xml.py <XSD_PATH> <XML_PATH>")
sys.exit(1)

XSD_PATH = sys.argv[1]
XML_PATH = sys.argv[2]

for path in [XSD_PATH, XML_PATH]:
if not os.path.isfile(path):
raise FileNotFoundError(f"Missing required file: {path}")

schema = ET.XMLSchema(file=XSD_PATH)
parser = ET.XMLParser(schema=schema)

with open(XML_PATH, "rb") as f:
ET.parse(f, parser)

print("✅ XML is valid against schema.")