You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/10/20 16:44:52 UTC
(tooling-trusted-releases) branch sbp updated: Check the RAT XML schema against ATR requirements
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/sbp by this push:
new 633c7d54 Check the RAT XML schema against ATR requirements
633c7d54 is described below
commit 633c7d54d881a938934754b7f87c21c80b6aa345
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Tue Oct 20 17:43:52 2026 +0100
Check the RAT XML schema against ATR requirements
---
.github/workflows/build.yml | 3 ++-
scripts/ci/check_rat_schema.py | 50 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b32915e9..e59567cc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -107,10 +107,11 @@ jobs:
-H "Accept: application/vnd.github+json" \
"${api}/issues" -d "$data" >/dev/null
- - name: Build image and check SBOM spec parity
+ - name: Build image and check tool compatibility
run: |
docker build -f Dockerfile.alpine -t atr:ci .
docker run --rm atr:ci .venv/bin/python scripts/ci/check_sbom_spec_parity.py --require-tools
+ docker run --rm atr:ci sh -c '.venv/bin/python scripts/ci/check_rat_schema.py /opt/tools/apache-rat-*.jar'
- name: Check that the server runs as a non-root user
env:
diff --git a/scripts/ci/check_rat_schema.py b/scripts/ci/check_rat_schema.py
new file mode 100755
index 00000000..8ffd46aa
--- /dev/null
+++ b/scripts/ci/check_rat_schema.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+import zipfile
+from typing import Final
+
+import defusedxml.ElementTree as ElementTree
+
+_NAMESPACES: Final = {"xs": "http://www.w3.org/2001/XMLSchema"}
+_REQUIRED: Final = (
+ ("xs:element[@name='rat-report']/xs:complexType/*/xs:element[@name='version']", set()),
+ (".//xs:element[@name='resource']", {"name", "type"}),
+ (".//xs:element[@name='resource']/xs:complexType/*/xs:element[@name='license']", {"approval", "name"}),
+)
+
+
+def main() -> None:
+ with zipfile.ZipFile(sys.argv[1]) as jar:
+ schema = ElementTree.fromstring(jar.read("org/apache/rat/rat-report.xsd"))
+ if schema.get("targetNamespace") is not None:
+ sys.exit("ERROR: the RAT report schema has a target namespace")
+ for path, required in _REQUIRED:
+ child = schema.find(path, _NAMESPACES)
+ if child is None:
+ sys.exit(f"ERROR: the RAT report schema does not declare {path}")
+ attributes = child.findall("xs:complexType/xs:attribute", _NAMESPACES)
+ missing = required - {attribute.get("name") for attribute in attributes}
+ if missing:
+ sys.exit(f"ERROR: the RAT report schema does not declare {sorted(missing)} on {path}")
+
+
+if __name__ == "__main__":
+ main()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org