]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/commitdiff
Add json schema validation github action
authorb3nj4m1n <b3nj4m1n@gmx.net>
Wed, 14 Dec 2022 21:06:45 +0000 (22:06 +0100)
committerb3nj4m1n <b3nj4m1n@gmx.net>
Wed, 14 Dec 2022 21:06:45 +0000 (22:06 +0100)
.github/workflows/json_schema.yml [new file with mode: 0644]
json-schema/file.json [deleted file]
json-schema/program.json

diff --git a/.github/workflows/json_schema.yml b/.github/workflows/json_schema.yml
new file mode 100644 (file)
index 0000000..d8bca9e
--- /dev/null
@@ -0,0 +1,23 @@
+name: Validate JSON
+
+on:
+  push:
+    branches:
+      - main
+  pull_request:
+    branches:
+      - main
+
+jobs:
+  validate:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Validate JSON
+        uses: walbo/validate-json@v1.1.0
+        with:
+          files: programs/*.json
+          schema: json-schema/program.json
+          schema-version: draft-07
+          fail-on-missing-schema: true
+          strict: true
diff --git a/json-schema/file.json b/json-schema/file.json
deleted file mode 100644 (file)
index 1a3e217..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-    "$schema": "http://json-schema.org/draft-07/schema#",
-    "title": "File schema",
-    "properties": {
-        "path": {
-            "type": "string",
-            "description": "Path to file (or folder).",
-            "minLength": 1
-        },
-        "movable": {
-            "type": "boolean",
-            "description": "Is file (or folder) movable to a place other than $HOME."
-        },
-        "help": {
-            "type": "string",
-            "description": "Help text for user. Supports markdown."
-        }
-    },
-    "required": [
-        "path",
-        "movable",
-        "help"
-    ]
-}
\ No newline at end of file
index d5692739a4e1c401c7019caa8f364001e16b1248..1fcf2d798510dfbacb52a4040b70f6c2d966c659 100644 (file)
@@ -1,7 +1,7 @@
 {
 {
-    "$schema": "http://json-schema.org/draft-07/schema#",
     "title": "Program",
     "description": "Specification of files or folders in the $HOME folder for a program",
     "title": "Program",
     "description": "Specification of files or folders in the $HOME folder for a program",
+    "type": "object",
     "properties": {
         "name": {
             "type": "string",
     "properties": {
         "name": {
             "type": "string",
             "description": "List of files (or folders) associated with the program",
             "type": "array",
             "items": {
             "description": "List of files (or folders) associated with the program",
             "type": "array",
             "items": {
-                "$ref": "file.json"
+                    "type": "object",
+                    "properties": {
+                        "path": {
+                            "type": "string",
+                            "description": "Path to file (or folder).",
+                            "minLength": 1
+                        },
+                        "movable": {
+                            "type": "boolean",
+                            "description": "Is file (or folder) movable to a place other than $HOME."
+                        },
+                        "help": {
+                            "type": "string",
+                            "description": "Help text for user. Supports markdown."
+                        }
+                    },
+                    "required": [
+                        "path",
+                        "movable",
+                        "help"
+                    ]
             },
             "minItems": 1
         }
             },
             "minItems": 1
         }
@@ -21,4 +41,4 @@
         "name",
         "files"
     ]
         "name",
         "files"
     ]
-}
\ No newline at end of file
+}