added
This commit is contained in:
1 parent
614d235bbe
commit
1e52a733d1
29 files changed
+728
-66
No files matched your search
@@ -14,6 +14,7 @@ PROFILES = {
|
||||
"documentation-guide": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
@@ -25,6 +26,7 @@ PROFILES = {
|
||||
"skill-workflow": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
@@ -39,6 +41,7 @@ PROFILES = {
|
||||
"software-automation": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
@@ -54,6 +57,7 @@ PROFILES = {
|
||||
"dataset": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
@@ -133,6 +137,104 @@ def audit(root: Path, profile: str) -> dict:
|
||||
else:
|
||||
findings.append({"level": "error", "message": "entrypoints must be an object"})
|
||||
|
||||
variables_path = root / "repository-variables.json"
|
||||
variables = None
|
||||
if variables_path.is_file():
|
||||
try:
|
||||
variables = json.loads(variables_path.read_text(encoding="utf-8-sig"))
|
||||
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
||||
findings.append(
|
||||
{"level": "error", "message": f"repository-variables.json is invalid: {exc}"}
|
||||
)
|
||||
else:
|
||||
for key in (
|
||||
"schema_version",
|
||||
"repository_profile",
|
||||
"identity",
|
||||
"repository",
|
||||
"rights",
|
||||
"skill_defaults",
|
||||
"verified_by",
|
||||
"verified_at",
|
||||
):
|
||||
if key not in variables:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"repository-variables.json lacks key: {key}",
|
||||
}
|
||||
)
|
||||
|
||||
if manifest and variables:
|
||||
identity = variables.get("identity", {})
|
||||
variable_authors = [
|
||||
item.get("name")
|
||||
for item in identity.get("authors", [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
manifest_authors = [
|
||||
item.get("name")
|
||||
for item in manifest.get("authors", [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
comparisons = (
|
||||
("authors", variable_authors, manifest_authors),
|
||||
(
|
||||
"publisher",
|
||||
identity.get("publisher", {}).get("name"),
|
||||
manifest.get("publisher", {}).get("name"),
|
||||
),
|
||||
(
|
||||
"maintainer",
|
||||
identity.get("maintainer", {}).get("name"),
|
||||
manifest.get("maintenance", {}).get("maintainer"),
|
||||
),
|
||||
(
|
||||
"repository",
|
||||
variables.get("repository"),
|
||||
{
|
||||
key: manifest.get(key)
|
||||
for key in (
|
||||
"repository_id",
|
||||
"name",
|
||||
"title",
|
||||
"canonical_url",
|
||||
"organization",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"rights",
|
||||
variables.get("rights"),
|
||||
{
|
||||
key: manifest.get("rights", {}).get(key)
|
||||
for key in ("license", "license_file")
|
||||
},
|
||||
),
|
||||
)
|
||||
for label, variable_value, manifest_value in comparisons:
|
||||
if variable_value != manifest_value:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": (
|
||||
f"{label} differs between repository-variables.json "
|
||||
"and repository.json"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
if variables and variables.get("repository_profile") != profile:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": (
|
||||
"repository_profile differs between repository-variables.json "
|
||||
f"({variables.get('repository_profile')}) and requested audit ({profile})"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
version_path = root / "VERSION"
|
||||
version = version_path.read_text(encoding="utf-8-sig").strip() if version_path.is_file() else None
|
||||
if version and manifest and manifest.get("version") != version:
|
||||
|
||||
Reference in new issue
Block a user