-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from supercontainers/add-ci
ci: add schema validation and drafts
- Loading branch information
Showing
8 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jsonschema |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import os | ||
import re | ||
import json | ||
import jsonschema | ||
|
||
here = os.path.abspath(__file__) | ||
root = os.path.dirname(os.path.dirname(here)) | ||
|
||
schema_file = os.path.join(root, "definition-schema.json") | ||
|
||
def recursive_find(base, pattern="compspec.json"): | ||
""" | ||
Find all compspec.json below a root | ||
""" | ||
for root, _, filenames in os.walk(base): | ||
for filename in filenames: | ||
fullpath = os.path.join(root, filename) | ||
if re.search(pattern, fullpath): | ||
yield fullpath | ||
|
||
|
||
def read_json(filename): | ||
with open(filename, "r") as fd: | ||
content = json.loads(fd.read()) | ||
return content | ||
|
||
|
||
def main(root): | ||
""" | ||
Validate the format of WIP prototype specs. | ||
""" | ||
root = os.path.abspath(root) | ||
if not os.path.exists(root): | ||
sys.exit(f"{root} does not exist.") | ||
specs = recursive_find(root) | ||
|
||
schema = read_json(schema_file) | ||
for spec_file in specs: | ||
print(f"⭐️ Validating spec {spec_file}") | ||
spec = read_json(spec_file) | ||
jsonschema.validate(spec, schema=schema) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
root = sys.argv[1] | ||
main(root) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: check compatibility specs | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: [] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
- name: Run Validation | ||
run: | | ||
sudo apt-get update && sudo apt-get install -y python3 python3-pip python3-setuptools wget | ||
sudo pip3 install -r .github/requirements.txt | ||
python3 .github/validate.py . | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compatibilities": { | ||
"version": "0.0.0", | ||
"io.archspec.cpu": { | ||
"annotations": [ | ||
"family", | ||
"model", | ||
"target", | ||
"vendor" | ||
] | ||
} | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Schema for the definitions of the known labels", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"compatibilities": { | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"$comment": "Version of the metadata namespace", | ||
"type": "string" | ||
}, | ||
"patternProperties": { | ||
"([\\w]*)": { | ||
"annotations": { | ||
"$comment": "Acceptable keys for a given namespace.", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Schema for the definitions of the known labels", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"compatibilities": { | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"$comment": "Version of the metadata namespace", | ||
"type": "string" | ||
}, | ||
"patternProperties": { | ||
"([\\w]*)": { | ||
"annotations": { | ||
"$comment": "Key value pairs for a given namespace.", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"patternProperties": { | ||
"\\w[\\w-]*": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"compatibilities": { | ||
"version": "0.0.0", | ||
"org.supercontainers.mpi": { | ||
"annotations": [ | ||
"implementation", | ||
"portability.optimization", | ||
"porability.mode" | ||
] | ||
}, | ||
"org.supercontainers.hardware.gpu": { | ||
"annotations": [ | ||
"driver.version", | ||
"cuda.version", | ||
"architecture" | ||
] | ||
}, | ||
"org.supercontainers.communication": { | ||
"annotations": [ | ||
"framework" | ||
] | ||
}, | ||
"org.supercontainers.openmpi": { | ||
"annotations": [ | ||
"version" | ||
] | ||
}, | ||
"org.supercontainers.libfabric": { | ||
"annotations": [ | ||
"abi.version" | ||
] | ||
} | ||
} | ||
} |