Skip to contentSkip to conversation

bitbake-setup JSON Schema: Fix linting errors

PATCH Superseded Rob Woolley 2 participants 19 messages Apr 7 – May 28

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover bitbake-setup JSON Schema: Fix linting errors

UPDATES v2:
The following updates were made to v2 of this series:
* Include an additional patch fixing an existing typo
* Update the examples property to wrap it in an array and add a required configuration element

This series fixes some linting errors in the JSON Schema. Problems were found using the https://github.com/sourcemeta/jsonschema tool.

Here are the steps used to install and use the tool to lint the schemas:

# Setup the jsonschema CLI tool

```
  python3 -m venv venv
  source venv/bin/activate
  pip install sourcemeta-jsonschema
```

# Validate the schemas

```
jsonschema lint setup-schema/bitbake-setup.schema.json
jsonschema lint setup-schema/layers.schema.json
```

# Check the examples

NOTE: The examples are annotations and are meant for humans reading the schema. They do not typically get checked automatically by the JSON Schema validation tools. Use jq to extract the JSON object into its own file to check it separately.

```
cd setup-schema

jq .examples[] bitbake-setup.schema.json  > bitbake-setup.schema-examples.json
jsonschema validate bitbake-setup.schema.json bitbake-setup.schema-examples.json


jq .examples[] layers.schema.json  > layers.schema-examples.json
jsonschema validate layers.schema.json layers.schema-examples.json
cd ..
```

# Check the default-registry/configurations

```
jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/oe-nodistro-master.conf.json
jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/oe-nodistro-whinlatter.conf.json
jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/poky-master.conf.json
jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/poky-whinlatter.conf.json
```

There are 2 outstanding types of linting errors related to the use of hyphen in the property names and the enum currently having only one value:

Set properties to identifier names that can be easily mapped to programming languages (matching [A-Za-z_][A-Za-z0-9_]*) (simple_properties_identifiers).

An enum of a single value can be expressed as const (enum_to_const)

The former would require a larger discussion and potentially increasing the version number. Updating the enum to include a new version would also resolve the latter error.

I do not believe that the changes in this series merit increasing the version of the schema.

Resolving these outstanding errors is not necessary for validating the Bitbake Configuration files.

UPDATE v2: Additional testing was performed with oe-selftest. This uses
python3-jsonschema which is a different implementation and caught additional linting errors.

```
    git clone https://git.openembedded.org/bitbake
    
    ./bitbake/bin/bitbake-setup init --non-interactive poky-master poky machine/qemux86-64 distro/poky
    
    . /ala-lpggp31/rwoolley/oe-selftest-testing/bitbake-builds/poky-master/build/init-build-env
    
    echo 'SANITY_TESTED_DISTROS = ""' >> conf/local.conf
    
    oe-selftest -r bblayers.BitbakeLayers.test_bitbakelayers_setup \
                   bblayers.BitbakeLayers.test_bitbakelayers_updatelayer \
                   bblayers.BitbakeLayers.test_validate_examplelayersjson \
                   bblayers.BitbakeLayers.test_validate_bitbake_setup_default_registry
```
#1 lore raw

PATCH v2 1/9 bitbake-setup.schema.json: Add title for schema

Resolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)

---
 setup-schema/bitbake-setup.schema.json | 1 +
 1 file changed, 1 insertion(+)
setup-schema/bitbake-setup.schema.json +1 -0
index be8772db1..d340c9785 100644
@@ -1,6 +1,7 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "Schema for bitbake-setup configuration files",
+    "title": "bitbake-setup configuration file",
     "type": "object",
     "required": [
         "description",
Signature · 1 line
2.49.0
Reviewed-by on v2 1/9
#2 lore raw

Re: [bitbake-devel] [PATCH v2 1/9] bitbake-setup.schema.json: Add title for schema

Quoted 5 lines · Rob Woolley via lists.openembedded.org

Resolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)

Quoted 16 lines
---
 setup-schema/bitbake-setup.schema.json | 1 +
 1 file changed, 1 insertion(+)
setup-schema/bitbake-setup.schema.json +1 -0
index be8772db1..d340c9785 100644
@@ -1,6 +1,7 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "Schema for bitbake-setup configuration files",
+    "title": "bitbake-setup configuration file",
     "type": "object",
     "required": [
         "description",
Signature · 2 lines
Yoann Congal
Smile ECS
#3 lore raw

PATCH v2 2/9 bitbake-setup.schema.json: Add examples property

In reply to Rob Woolley

This resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)

This example intentionally only references bitbake as a minimal example that focuses on the tool itself.

---
 setup-schema/bitbake-setup.schema.json | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
setup-schema/bitbake-setup.schema.json +27 -0
index d340c9785..3324546de 100644
@@ -1,6 +1,33 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "Schema for bitbake-setup configuration files",
+    "examples" : [
+        {
+            "description": "Example bitbake-setup configuration file",
+            "sources": {
+                "bitbake": {
+                    "git-remote": {
+                        "remotes": {
+                            "origin": {
+                                "uri": "https://git.openembedded.org/bitbake"
+                            }
+                        },
+                        "branch": "master",
+                        "rev": "master"
+                    },
+                    "path": "bitbake"
+                }
+            },
+            "bitbake-setup": {
+                "configurations": [
+                    {
+                        "bb-layers": ["openembedded-core/meta","meta-yocto/meta-yocto-bsp","meta-yocto/meta-poky"]
+                    }
+                ]
+            },
+            "version": "1.0"
+        }
+    ],
     "title": "bitbake-setup configuration file",
     "type": "object",
     "required": [
Signature · 1 line
2.49.0
#4 lore raw

Re: [bitbake-devel] [PATCH v2 2/9] bitbake-setup.schema.json: Add examples property

Quoted 25 lines · Rob Woolley via lists.openembedded.org

This resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)

This example intentionally only references bitbake as a minimal example that focuses on the tool itself.

---
 setup-schema/bitbake-setup.schema.json | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
setup-schema/bitbake-setup.schema.json +5 -0
index d340c9785..3324546de 100644
@@ -1,6 +1,33 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "Schema for bitbake-setup configuration files",
+    "examples" : [
+        {
+            "description": "Example bitbake-setup configuration file",
+            "sources": {
+                "bitbake": {

setup-schema/bitbake-setup.schema.json line 18

Quoted 10 lines
setup-schema/bitbake-setup.schema.json +10 -0
+                    "git-remote": {
+                        "remotes": {
+                            "origin": {
+                                "uri": "https://git.openembedded.org/bitbake"
+                            }
+                        },
+                        "branch": "master",
+                        "rev": "master"
+                    },
+                    "path": "bitbake"

For this example, I think we can use the shortest form:

  "sources": {
      "bitbake": {
          "git-remote": {
              "uri": "https://git.openembedded.org/bitbake",
              "rev": "master"

}
}

setup-schema/bitbake-setup.schema.json line 24

Quoted 6 lines
setup-schema/bitbake-setup.schema.json +6 -0
+                }
+            },
+            "bitbake-setup": {
+                "configurations": [
+                    {
+                        "bb-layers": ["openembedded-core/meta","meta-yocto/meta-yocto-bsp","meta-yocto/meta-poky"]

The fact that this example references layer that it does not source makes me uneasy.

How about a minimal example with bitbake+openembedded-core and a qemux86-64+nodistro build?

Quoted 9 lines
setup-schema/bitbake-setup.schema.json +6 -0
+                    }
+                ]
+            },
+            "version": "1.0"
+        }
+    ],
     "title": "bitbake-setup configuration file",
     "type": "object",
     "required": [
Signature · 2 lines
Yoann Congal
Smile ECS
#5 lore raw

PATCH v2 3/9 bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas

In reply to Rob Woolley

The oneOf keyword is for matching exactly one subschema.

However, the 2 possible BitBake configuration fragments are not disjoint. Since a simple example with type and description would match both. For this reason, we should use anyOf instead.

This resolves the following jsonschema linting error:
A oneOf where all branches have disjoint types can be safely converted to anyOf (oneof_to_anyof_disjoint_types)

---
 setup-schema/bitbake-setup.schema.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
index 3324546de..f2e466c9b 100644
@@ -92,7 +92,7 @@
                                 "type": "array",
                                 "description": "List of BitBake configuration fragments to enable",
                                 "items": {
-                                    "oneOf": [
+                                    "anyOf": [
                                         {
                                             "type": "string",
                                             "description": "Configuration fragment name"
Signature · 1 line
2.49.0
Reviewed-by on v2 3/9
#6 lore raw

Re: [bitbake-devel] [PATCH v2 3/9] bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas

Quoted 7 lines · Rob Woolley via lists.openembedded.org

The oneOf keyword is for matching exactly one subschema.

However, the 2 possible BitBake configuration fragments are not disjoint. Since a simple example with type and description would match both. For this reason, we should use anyOf instead.

Quoted 5 lines

This resolves the following jsonschema linting error:
A oneOf where all branches have disjoint types can be safely converted to anyOf (oneof_to_anyof_disjoint_types)

Quoted 17 lines
---
 setup-schema/bitbake-setup.schema.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
index 3324546de..f2e466c9b 100644
@@ -92,7 +92,7 @@
                                 "type": "array",
                                 "description": "List of BitBake configuration fragments to enable",
                                 "items": {
-                                    "oneOf": [
+                                    "anyOf": [
                                         {
                                             "type": "string",
                                             "description": "Configuration fragment name"
Signature · 2 lines
Yoann Congal
Smile ECS
#7 lore raw

PATCH v2 4/9 bitbake-setup.schema.json: Remove trailing period

In reply to Rob Woolley

This resolves the jsonschema linting error:
Descriptions should not end with a period to give user interfaces flexibility in presenting the text (description_trailing_period)

---
 setup-schema/bitbake-setup.schema.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
index f2e466c9b..896b0ba4a 100644
@@ -150,7 +150,7 @@
                             },
                             "setup-dir-name": {
                                 "type": "string",
-                                "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections."
+                                "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections"
                             }
                         },
                         "additionalProperties": false
Signature · 1 line
2.49.0
Reviewed-by on v2 4/9
#8 lore raw

Re: [bitbake-devel] [PATCH v2 4/9] bitbake-setup.schema.json: Remove trailing period

Quoted 5 lines · Rob Woolley via lists.openembedded.org

This resolves the jsonschema linting error:
Descriptions should not end with a period to give user interfaces flexibility in presenting the text (description_trailing_period)

Quoted 17 lines
---
 setup-schema/bitbake-setup.schema.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
index f2e466c9b..896b0ba4a 100644
@@ -150,7 +150,7 @@
                             },
                             "setup-dir-name": {
                                 "type": "string",
-                                "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections."
+                                "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections"
                             }
                         },
                         "additionalProperties": false
Signature · 2 lines
Yoann Congal
Smile ECS
#9 lore raw

PATCH v2 5/9 layers.schema.json: Add missing schema

In reply to Rob Woolley

This resolves the jsonschema error:
error: The JSON document is not a valid JSON Schema

---
 setup-schema/layers.schema.json | 1 +
 1 file changed, 1 insertion(+)
setup-schema/layers.schema.json +1 -0
index f42606941..2c192c8b0 100644
@@ -1,4 +1,5 @@
 {
+    "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "OpenEmbedder Layer Setup Manifest",
     "type": "object",
     "additionalProperties": false,
Signature · 1 line
2.49.0
Reviewed-by on v2 5/9
#10 lore raw

Re: [bitbake-devel] [PATCH v2 5/9] layers.schema.json: Add missing schema

Quoted 5 lines · Rob Woolley via lists.openembedded.org

This resolves the jsonschema error:
error: The JSON document is not a valid JSON Schema

---

Quoted 13 lines
 setup-schema/layers.schema.json | 1 +
 1 file changed, 1 insertion(+)
setup-schema/layers.schema.json +1 -0
index f42606941..2c192c8b0 100644
@@ -1,4 +1,5 @@
 {
+    "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "OpenEmbedder Layer Setup Manifest",
     "type": "object",
     "additionalProperties": false,
Signature · 2 lines
Yoann Congal
Smile ECS
#11 lore raw

PATCH v2 6/9 layers.schema.json: Add title for subschema

In reply to Rob Woolley

Resolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)

---
 setup-schema/layers.schema.json | 1 +
 1 file changed, 1 insertion(+)
setup-schema/layers.schema.json +1 -0
index 2c192c8b0..8bc74a533 100644
@@ -1,6 +1,7 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "OpenEmbedder Layer Setup Manifest",
+    "title": "bitbake-setup layer subschema",
     "type": "object",
     "additionalProperties": false,
     "required": [
Signature · 1 line
2.49.0
#12 lore raw

Re: [bitbake-devel] [PATCH v2 6/9] layers.schema.json: Add title for subschema

Quoted 14 lines · Rob Woolley via lists.openembedded.org

Resolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)

---
 setup-schema/layers.schema.json | 1 +
 1 file changed, 1 insertion(+)
setup-schema/layers.schema.json +0 -0
index 2c192c8b0..8bc74a533 100644

setup-schema/layers.schema.json line 3

Quoted 3 lines
setup-schema/layers.schema.json +0 -0
@@ -1,6 +1,7 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "OpenEmbedder Layer Setup Manifest",

Just noticed a OpenEmbedde*r* typo here. Could you also fix it in this series?

setup-schema/layers.schema.json line 4

Quoted 1 line
setup-schema/layers.schema.json +1 -0
+    "title": "bitbake-setup layer subschema",

This is not only a bb-setup subschema, this schema is valid in itself for files used in:
* openembedded-core/scripts/oe-setup-layers
* bitbake-layers create-layers-setup

For the title, something like "OpenEmbedded layer setup schema"? But then, it's a little too similar to the description. So maybe the description should be extended?

Quoted 3 lines
setup-schema/layers.schema.json +0 -0
     "type": "object",
     "additionalProperties": false,
     "required": [
Signature · 2 lines
Yoann Congal
Smile ECS
#13 lore raw

PATCH v2 7/9 layers.schema.json: Add examples property

In reply to Rob Woolley

This resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)

This example intentionally only references bitbake as a minimal example that focuses on the tool itself.

---
 setup-schema/layers.schema.json | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
setup-schema/layers.schema.json +19 -0
index 8bc74a533..5c715f08e 100644
@@ -1,6 +1,25 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "OpenEmbedder Layer Setup Manifest",
+    "examples" : [
+        {
+            "version": "1.0",
+            "sources": {
+                "bitbake": {
+                    "git-remote": {
+                        "remotes": {
+                            "origin": {
+                                "uri": "https://git.openembedded.org/bitbake"
+                            }
+                        },
+                        "branch": "master",
+                        "rev": "master"
+                    },
+                    "path": "bitbake"
+                }
+            }
+        }
+    ],
     "title": "bitbake-setup layer subschema",
     "type": "object",
     "additionalProperties": false,
Signature · 1 line
2.49.0
#14 lore raw

Re: [bitbake-devel] [PATCH v2 7/9] layers.schema.json: Add examples property

Quoted 17 lines · Rob Woolley via lists.openembedded.org

This resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)

This example intentionally only references bitbake as a minimal example that focuses on the tool itself.

---
 setup-schema/layers.schema.json | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
setup-schema/layers.schema.json +0 -0
index 8bc74a533..5c715f08e 100644

setup-schema/layers.schema.json line 6

Quoted 6 lines
setup-schema/layers.schema.json +3 -0
@@ -1,6 +1,25 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "description": "OpenEmbedder Layer Setup Manifest",
+    "examples" : [
+        {
+            "version": "1.0",

Can you put the "version" key at the end? (Like we do in
https://git.openembedded.org/bitbake/tree/default-registry/)

setup-schema/layers.schema.json line 19

Quoted 13 lines
setup-schema/layers.schema.json +13 -0
+            "sources": {
+                "bitbake": {
+                    "git-remote": {
+                        "remotes": {
+                            "origin": {
+                                "uri": "https://git.openembedded.org/bitbake"
+                            }
+                        },
+                        "branch": "master",
+                        "rev": "master"
+                    },
+                    "path": "bitbake"
+                }

Maybe use the short form here?

  "sources": {
      "bitbake": {
          "git-remote": {
              "uri": "https://git.openembedded.org/bitbake"
              "rev": "master"
          }
      }

}

Quoted 6 lines
setup-schema/layers.schema.json +3 -0
+            }
+        }
+    ],
     "title": "bitbake-setup layer subschema",
     "type": "object",
     "additionalProperties": false,
Signature · 2 lines
Yoann Congal
Smile ECS
#15 lore raw

PATCH v2 8/9 layers.schema.json: Remove trailing period

In reply to Rob Woolley

This resolves the jsonschema linting error:
Descriptions should not end with a period to give user interfaces flexibility in presenting the text (description_trailing_period)

---
 setup-schema/layers.schema.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
setup-schema/layers.schema.json +2 -2
index 5c715f08e..0ab679a6f 100644
@@ -44,7 +44,7 @@
                         "type": "string"
                     },
                     "contains_this_file": {
-                        "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then.",
+                        "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then",
                         "type": "boolean"
                     },
                     "git-remote": {
@@ -64,7 +64,7 @@
                                 "type": "string"
                             },
                             "describe": {
-                                "description": "The output of 'git describe' (human readable description of the revision using tags in revision history).",
+                                "description": "The output of 'git describe' (human readable description of the revision using tags in revision history)",
                                 "type": "string"
                             },
                             "uri": {
Signature · 1 line
2.49.0
Reviewed-by on v2 8/9
#16 lore raw

Re: [bitbake-devel] [PATCH v2 8/9] layers.schema.json: Remove trailing period

Quoted 5 lines · Rob Woolley via lists.openembedded.org

This resolves the jsonschema linting error:
Descriptions should not end with a period to give user interfaces flexibility in presenting the text (description_trailing_period)

Quoted 26 lines
---
 setup-schema/layers.schema.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
setup-schema/layers.schema.json +2 -2
index 5c715f08e..0ab679a6f 100644
@@ -44,7 +44,7 @@
                         "type": "string"
                     },
                     "contains_this_file": {
-                        "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then.",
+                        "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then",
                         "type": "boolean"
                     },
                     "git-remote": {
@@ -64,7 +64,7 @@
                                 "type": "string"
                             },
                             "describe": {
-                                "description": "The output of 'git describe' (human readable description of the revision using tags in revision history).",
+                                "description": "The output of 'git describe' (human readable description of the revision using tags in revision history)",
                                 "type": "string"
                             },
                             "uri": {
Signature · 2 lines
Yoann Congal
Smile ECS
#17 lore raw

PATCH v2 9/9 layers.schema.json: Fix typo in property name

In reply to Rob Woolley
---
 setup-schema/layers.schema.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/layers.schema.json +1 -1
index 0ab679a6f..8b46ca08c 100644
@@ -77,7 +77,7 @@
                                 "patternProperties": { ".*" : {
                                     "description": "A git remote",
                                     "type": "object",
-                                    "addtionalProperties": false,
+                                    "additionalProperties": false,
                                     "required": [
                                         "uri"
                                     ],
Signature · 1 line
2.49.0
Reviewed-by on v2 9/9
#18 lore raw

Re: [bitbake-devel] [PATCH v2 9/9] layers.schema.json: Fix typo in property name

Quoted 2 lines · Rob Woolley via lists.openembedded.org

---

Nice catch!

Quoted 16 lines
 setup-schema/layers.schema.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/layers.schema.json +1 -1
index 0ab679a6f..8b46ca08c 100644
@@ -77,7 +77,7 @@
                                 "patternProperties": { ".*" : {
                                     "description": "A git remote",
                                     "type": "object",
-                                    "addtionalProperties": false,
+                                    "additionalProperties": false,
                                     "required": [
                                         "uri"
                                     ],
Signature · 2 lines
Yoann Congal
Smile ECS