From ed29087e2f74b84a6d5012c9650b175b045d9cfd Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Wed, 8 Feb 2023 11:22:07 +0100 Subject: [PATCH 01/20] chore: added json schema for configuration file --- .github/PULL_REQUEST_TEMPLATE.md | 1 + .github/workflows/publish-go-tester-task.yml | 4 +- .github/workflows/release-go-task.yml | 5 + Taskfile.yml | 5 + configuration/configuration.schema.json | 143 +++++++++++++++++++ 5 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 configuration/configuration.schema.json diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 64204542882..3fa03de617e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,6 +9,7 @@ See [how to contribute](https://arduino.github.io/arduino-cli/latest/CONTRIBUTIN - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) - [ ] `UPGRADING.md` has been updated with a migration guide (for breaking changes) +- [ ] `configuration.schema.json` updated if new parameters are added. ## What kind of change does this PR introduce? diff --git a/.github/workflows/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml index 73a6c57491a..37c3be01a6f 100644 --- a/.github/workflows/publish-go-tester-task.yml +++ b/.github/workflows/publish-go-tester-task.yml @@ -111,6 +111,9 @@ jobs: - task: protoc:collect path: "*_proto.zip" name: rpc-protocol-files + - task: dist:jsonschema + path: "*configuration.schema.json" + name: configuration-schema steps: - name: Checkout repository @@ -146,7 +149,6 @@ jobs: steps: - name: Download build artifacts uses: actions/download-artifact@v3 - - name: Output checksum run: | TAG="${{ needs.package-name-prefix.outputs.prefix }}git-snapshot" diff --git a/.github/workflows/release-go-task.yml b/.github/workflows/release-go-task.yml index b059d60925d..609ab50faa8 100644 --- a/.github/workflows/release-go-task.yml +++ b/.github/workflows/release-go-task.yml @@ -253,6 +253,11 @@ jobs: - name: Collect proto files run: task protoc:collect + - name: Add configuration jsonschema + run: | + TAG=${{ needs.create-release-artifacts.outputs.version }} + cp ./configuration/configuration.schema.json ${{ env.DIST_DIR}}/${TAG}-configuration.schema.json + - name: Create checksum file working-directory: ${{ env.DIST_DIR}} run: | diff --git a/Taskfile.yml b/Taskfile.yml index 0a37a4a8a76..b3d8572d27e 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -329,6 +329,11 @@ tasks: desc: Returns the version used in the project cmds: - echo {{.VERSION}} + dist:jsonschema: + desc: Copy the jsonschema to dist folder + cmds: + - mkdir --parents {{.DIST_DIR}} + - cp ./configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json vars: PROJECT_NAME: "arduino-cli" diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json new file mode 100644 index 00000000000..5760ea2ed44 --- /dev/null +++ b/configuration/configuration.schema.json @@ -0,0 +1,143 @@ +{ + "title": "Arduino CLI configuration schema", + "description": "Describe the parameters available for the Arduino CLI configuration file. This schema should be considered unstable at this moment, it is not used by the CLI to validate input configuration", + "properties": { + "board_manager": { + "description": "", + "properties": { + "additional_urls": { + "description": "the URLs to any additional Boards Manager package index files needed for your boards platforms.", + "type": "string" + } + }, + "type": "object" + }, + "build_cache": { + "description": "configuration options related to the compilation cache", + "properties": { + "compilations_before_purge": { + "description": "interval, in number of compilations, at which the cache is purged, defaults to `10`. When `0` the cache is never purged.", + "type": "number", + "format": "integer", + "minimum": 0 + }, + "ttl": { + "description": "cache expiration time of build folders. If the cache is hit by a compilation the corresponding build files lifetime is renewed. The value format must be a valid input for time.ParseDuration(), defaults to `720h` (30 days)", + "type": "number", + "format": "integer", + "minimum": 0 + } + }, + "type": "object" + }, + "daemon": { + "description": "options related to running Arduino CLI as a [gRPC] server.", + "properties": { + "port": { + "description": "TCP port used for gRPC client connections.", + "type": "number", + "format": "integer", + "minimum": 0 + } + }, + "type": "object" + }, + "directories": { + "description": "directories used by Arduino CLI.", + "properties": { + "builtin.libraries": { + "description": "the libraries in this directory will be available to all platforms without the need for the user to install them, but with the lowest priority over other installed libraries with the same name, it's the equivalent of the Arduino IDE's bundled libraries directory.", + "type": "string" + }, + "builtin.tools": { + "description": "it's a list of directories of tools that will be available to all platforms without the need for the user to install them, it's the equivalent of the Arduino IDE 1.x bundled tools directory.", + "type": "string" + }, + "data": { + "description": "directory used to store Boards/Library Manager index files and Boards Manager platform installations.", + "type": "string" + }, + "downloads": { + "description": "directory used to stage downloaded archives during Boards/Library Manager installations.", + "type": "string" + }, + "user": { + "description": "the equivalent of the Arduino IDE's [\"sketchbook\" directory][sketchbook directory]. Library Manager installations are made to the `libraries` subdirectory of the user directory.", + "type": "string" + } + }, + "type": "object" + }, + "library": { + "description": "configuration options relating to Arduino libraries.", + "properties": { + "enable_unsafe_install": { + "description": "set to `true` to enable the use of the `--git-url` and `--zip-file` flags with [`arduino-cli lib install`][arduino cli lib install]. These are considered \"unsafe\" installation methods because they allow installing files that have not passed through the Library Manager submission process.", + "type": "boolean" + } + }, + "type": "object" + }, + "locale": { + "description": "the language used by Arduino CLI to communicate to the user, the parameter is the language identifier in the standard POSIX format `[_[.]]` (for example `it` or `it_IT`, or `it_IT.UTF-8`).", + "type": "string" + }, + "logging": { + "description": "configuration options for Arduino CLI's logs.", + "properties": { + "file": { + "description": "path to the file where logs will be written.", + "type": "string" + }, + "format": { + "description": "output format for the logs. Allowed values are `text` or `json`.", + "type": "string", + "enum": ["text", "json"] + }, + "level": { + "description": "messages with this level and above will be logged. Valid levels are: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic`.", + "type": "string", + "enum": ["trace", "debug", "info", "warn", "error", "fatal"] + } + }, + "type": "object" + }, + "metrics": { + "description": "settings related to the collection of data used for continued improvement of Arduino CLI.", + "properties": { + "addr": { + "description": "TCP port used for metrics communication.", + "type": "number", + "format": "integer", + "minimum": 0 + }, + "enabled": { + "description": "controls the use of metrics.", + "type": "boolean" + } + }, + "type": "object" + }, + "sketch": { + "description": "configuration options relating to [Arduino sketches][sketch specification].", + "properties": { + "always_export_binaries": { + "description": "set to `true` to make [`arduino-cli compile`][arduino-cli compile] always save binaries to the sketch folder. This is the equivalent of using the [`--export-binaries`][arduino-cli compile options] flag.", + "type": "boolean" + } + }, + "type": "object" + }, + "updater": { + "description": "configuration options related to Arduino CLI updates", + "properties": { + "enable_notification": { + "description": "set to `false` to disable notifications of new Arduino CLI releases, defaults to `true`", + "type": "boolean" + } + }, + "type": "object" + } + }, + "type": "object" +} From fb6e552b32ca79bc6fa811bc2d5fedaf1c75e73d Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Fri, 10 Feb 2023 09:25:38 +0100 Subject: [PATCH 02/20] fix: additional_urls type --- configuration/configuration.schema.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 5760ea2ed44..97b74ea2ed5 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -7,7 +7,10 @@ "properties": { "additional_urls": { "description": "the URLs to any additional Boards Manager package index files needed for your boards platforms.", - "type": "string" + "type": "array", + "items": { + "type": "string" + } } }, "type": "object" @@ -35,9 +38,8 @@ "properties": { "port": { "description": "TCP port used for gRPC client connections.", - "type": "number", - "format": "integer", - "minimum": 0 + "type": "string", + "pattern": "^[0-9]+$" } }, "type": "object" @@ -107,9 +109,7 @@ "properties": { "addr": { "description": "TCP port used for metrics communication.", - "type": "number", - "format": "integer", - "minimum": 0 + "type": "string" }, "enabled": { "description": "controls the use of metrics.", From 8aa6453bc1ac0ec8c3681e12a1a0d263e78f54eb Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Fri, 10 Feb 2023 09:26:16 +0100 Subject: [PATCH 03/20] fix(ci): tasks conditions --- .github/workflows/publish-go-nightly-task.yml | 1 + DistTasks.yml | 6 ++++++ Taskfile.yml | 5 ----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-go-nightly-task.yml b/.github/workflows/publish-go-nightly-task.yml index 12c4f33c609..c5070dc83b7 100644 --- a/.github/workflows/publish-go-nightly-task.yml +++ b/.github/workflows/publish-go-nightly-task.yml @@ -36,6 +36,7 @@ jobs: - Linux_ARM64 - macOS_64bit - macOS_ARM64 + - jsonschema steps: - name: Checkout repository diff --git a/DistTasks.yml b/DistTasks.yml index eb9dcd4f9e1..459e3b7a42f 100644 --- a/DistTasks.yml +++ b/DistTasks.yml @@ -251,3 +251,9 @@ tasks: CONTAINER_TAG: "{{.GO_VERSION}}-darwin-arm64-debian10" PACKAGE_PLATFORM: "macOS_ARM64" PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz" + + jsonschema: + desc: Copy the jsonschema to dist folder + cmds: + - mkdir --parents {{.DIST_DIR}} + - cp ./configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json diff --git a/Taskfile.yml b/Taskfile.yml index b3d8572d27e..0a37a4a8a76 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -329,11 +329,6 @@ tasks: desc: Returns the version used in the project cmds: - echo {{.VERSION}} - dist:jsonschema: - desc: Copy the jsonschema to dist folder - cmds: - - mkdir --parents {{.DIST_DIR}} - - cp ./configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json vars: PROJECT_NAME: "arduino-cli" From 3d24c9b32e1dc5c64a8257c142187718a1240c82 Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:55:22 +0100 Subject: [PATCH 04/20] Update .github/workflows/release-go-task.yml Co-authored-by: per1234 --- .github/workflows/release-go-task.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-go-task.yml b/.github/workflows/release-go-task.yml index 609ab50faa8..02e14c49bdc 100644 --- a/.github/workflows/release-go-task.yml +++ b/.github/workflows/release-go-task.yml @@ -253,7 +253,7 @@ jobs: - name: Collect proto files run: task protoc:collect - - name: Add configuration jsonschema + - name: Add configuration JSON schema run: | TAG=${{ needs.create-release-artifacts.outputs.version }} cp ./configuration/configuration.schema.json ${{ env.DIST_DIR}}/${TAG}-configuration.schema.json From 6f7a4c757b5828e1e82a5f94bd3876ece73c38e1 Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:55:52 +0100 Subject: [PATCH 05/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 97b74ea2ed5..7be29a7491c 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -1,6 +1,6 @@ { "title": "Arduino CLI configuration schema", - "description": "Describe the parameters available for the Arduino CLI configuration file. This schema should be considered unstable at this moment, it is not used by the CLI to validate input configuration", + "description": "Describe the parameters available for the Arduino CLI configuration file. This schema should be considered unstable at this moment.", "properties": { "board_manager": { "description": "", From 19b12de7ca11357254f4477ae42a5cf748615246 Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:56:22 +0100 Subject: [PATCH 06/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 7be29a7491c..d0e135458b0 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -99,7 +99,7 @@ "level": { "description": "messages with this level and above will be logged. Valid levels are: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic`.", "type": "string", - "enum": ["trace", "debug", "info", "warn", "error", "fatal"] + "enum": ["trace", "debug", "info", "warn", "error", "fatal", "panic"] } }, "type": "object" From d096c6df1cc822b404368de014685d90cb9d76e3 Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:56:38 +0100 Subject: [PATCH 07/20] Update DistTasks.yml Co-authored-by: per1234 --- DistTasks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DistTasks.yml b/DistTasks.yml index 459e3b7a42f..ebc0db6424a 100644 --- a/DistTasks.yml +++ b/DistTasks.yml @@ -253,7 +253,7 @@ tasks: PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz" jsonschema: - desc: Copy the jsonschema to dist folder + desc: Copy the JSON schema to dist folder cmds: - mkdir --parents {{.DIST_DIR}} - cp ./configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json From f7e5f86fdd8a3f78be3fb00682573b8436e3e12c Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Thu, 16 Feb 2023 12:47:40 +0100 Subject: [PATCH 08/20] chore: refine schema --- configuration/configuration.schema.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 97b74ea2ed5..a65e3f81789 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -1,6 +1,7 @@ { "title": "Arduino CLI configuration schema", "description": "Describe the parameters available for the Arduino CLI configuration file. This schema should be considered unstable at this moment, it is not used by the CLI to validate input configuration", + "$schema": "http://json-schema.org/draft-06/schema#", "properties": { "board_manager": { "description": "", @@ -26,9 +27,16 @@ }, "ttl": { "description": "cache expiration time of build folders. If the cache is hit by a compilation the corresponding build files lifetime is renewed. The value format must be a valid input for time.ParseDuration(), defaults to `720h` (30 days)", - "type": "number", - "format": "integer", - "minimum": 0 + "oneOf": [ + { + "type": "number", + "format": "integer", + "minimum": 0 + }, + { + "type": "string" + } + ] } }, "type": "object" From 99eb639d119fa42aa398a11f601cea018162cb8c Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Thu, 16 Feb 2023 13:34:47 +0100 Subject: [PATCH 09/20] test: validate json schema --- configuration/configuration_schema_test.go | 19 +++++++++++++++++++ docsgen/go.sum | 3 +++ go.mod | 3 +++ go.sum | 6 ++++++ 4 files changed, 31 insertions(+) create mode 100644 configuration/configuration_schema_test.go diff --git a/configuration/configuration_schema_test.go b/configuration/configuration_schema_test.go new file mode 100644 index 00000000000..afc961ee52f --- /dev/null +++ b/configuration/configuration_schema_test.go @@ -0,0 +1,19 @@ +package configuration + +import ( + "io/ioutil" + "testing" + + "github.com/stretchr/testify/require" + "github.com/xeipuuv/gojsonschema" +) + +func TestConfigurationSchemaValidity(t *testing.T) { + schemaBytes, err := ioutil.ReadFile("configuration.schema.json") + require.NoError(t, err) + + jl := gojsonschema.NewBytesLoader(schemaBytes) + sl := gojsonschema.NewSchemaLoader() + _, err = sl.Compile(jl) + require.NoError(t, err) +} diff --git a/docsgen/go.sum b/docsgen/go.sum index b458f5af5f2..bf4fea78449 100644 --- a/docsgen/go.sum +++ b/docsgen/go.sum @@ -331,6 +331,9 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/go.mod b/go.mod index d7c40152503..912d04ab767 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,7 @@ require ( require ( github.com/rogpeppe/go-internal v1.3.0 + github.com/xeipuuv/gojsonschema v1.2.0 go.bug.st/testifyjson v1.1.1 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 gopkg.in/yaml.v3 v3.0.1 @@ -88,6 +89,8 @@ require ( github.com/subosito/gotenv v1.2.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/xanzy/ssh-agent v0.2.1 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect gopkg.in/ini.v1 v1.62.0 // indirect diff --git a/go.sum b/go.sum index fefe1ab48bd..f80f605bd59 100644 --- a/go.sum +++ b/go.sum @@ -342,6 +342,12 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= From f12b648ffdf7b1db374d46608ad761a391f9af3e Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Thu, 16 Feb 2023 14:59:44 +0100 Subject: [PATCH 10/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index daa10e2c9fd..f3b07c1a49f 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -55,13 +55,22 @@ "directories": { "description": "directories used by Arduino CLI.", "properties": { - "builtin.libraries": { - "description": "the libraries in this directory will be available to all platforms without the need for the user to install them, but with the lowest priority over other installed libraries with the same name, it's the equivalent of the Arduino IDE's bundled libraries directory.", - "type": "string" - }, - "builtin.tools": { - "description": "it's a list of directories of tools that will be available to all platforms without the need for the user to install them, it's the equivalent of the Arduino IDE 1.x bundled tools directory.", - "type": "string" + "builtin": { + "description": "", + "properties": { + "libraries": { + "description": "the libraries in this directory will be available to all platforms without the need for the user to install them, but with the lowest priority over other installed libraries with the same name, it's the equivalent of the Arduino IDE's bundled libraries directory.", + "type": "string" + }, + "tools": { + "description": "it's a list of directories of tools that will be available to all platforms without the need for the user to install them, it's the equivalent of the Arduino IDE 1.x bundled tools directory.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "type": "object" }, "data": { "description": "directory used to store Boards/Library Manager index files and Boards Manager platform installations.", From f89612d3930a91410adabf93c31aa7c3382757f5 Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Thu, 16 Feb 2023 15:07:30 +0100 Subject: [PATCH 11/20] chore: schema updates --- configuration/configuration.schema.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index f3b07c1a49f..5d4778f6881 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -34,7 +34,8 @@ "minimum": 0 }, { - "type": "string" + "type": "string", + "pattern": "^[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" } ] } @@ -150,7 +151,8 @@ "properties": { "enable_notification": { "description": "set to `false` to disable notifications of new Arduino CLI releases, defaults to `true`", - "type": "boolean" + "type": "boolean", + "default": true } }, "type": "object" From 15a26dd4307858f1e22c434e98fe1fab514ad725 Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Thu, 16 Feb 2023 15:23:29 +0100 Subject: [PATCH 12/20] chore: update schema --- configuration/configuration.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 5d4778f6881..c1378b02235 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -10,7 +10,8 @@ "description": "the URLs to any additional Boards Manager package index files needed for your boards platforms.", "type": "array", "items": { - "type": "string" + "type": "string", + "format": "uri" } } }, From 9e4d7d7db0b8109175f057f6d875e4cf1284167d Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:34:27 +0100 Subject: [PATCH 13/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index f3b07c1a49f..97299ea2ecf 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -150,7 +150,8 @@ "properties": { "enable_notification": { "description": "set to `false` to disable notifications of new Arduino CLI releases, defaults to `true`", - "type": "boolean" + "type": "boolean", + "default": true } }, "type": "object" From 8ad388e4a71d579f4ca1e0a76579b40007162190 Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Thu, 16 Feb 2023 20:03:28 +0100 Subject: [PATCH 14/20] chore: refined workflows --- .github/workflows/release-go-task.yml | 6 ++---- .gitignore | 1 + Taskfile.yml | 6 ++++++ docs/configuration.md | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-go-task.yml b/.github/workflows/release-go-task.yml index 02e14c49bdc..af177d0d429 100644 --- a/.github/workflows/release-go-task.yml +++ b/.github/workflows/release-go-task.yml @@ -254,12 +254,10 @@ jobs: run: task protoc:collect - name: Add configuration JSON schema - run: | - TAG=${{ needs.create-release-artifacts.outputs.version }} - cp ./configuration/configuration.schema.json ${{ env.DIST_DIR}}/${TAG}-configuration.schema.json + run: task dist:jsonschema - name: Create checksum file - working-directory: ${{ env.DIST_DIR}} + working-directory: ${{ env.DIST_DIR }} run: | TAG=${{ needs.create-release-artifacts.outputs.version }} sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt diff --git a/.gitignore b/.gitignore index bca7f6fdbfe..8633c219477 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ venv /docsgen/arduino-cli.exe /docs/rpc/*.md /docs/commands/*.md +/docs/configuration.schema.json diff --git a/Taskfile.yml b/Taskfile.yml index 0a37a4a8a76..380b0898867 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,6 +9,7 @@ tasks: deps: - task: go:cli-docs - task: protoc:docs + - task: docs:include-configuration-json-schema cmds: - task: general:format-prettier @@ -218,6 +219,11 @@ tasks: - '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,settings.md --proto_path=rpc ./rpc/cc/arduino/cli/settings/v1/*.proto' - '{{ default "protoc" .PROTOC_BINARY }} --doc_out=./docs/rpc --doc_opt=markdown,debug.md --proto_path=rpc ./rpc/cc/arduino/cli/debug/v1/*.proto' + docs:include-configuration-json-schema: + desc: Copy configuration JSON schema to make it available in documentation + cmds: + - cp ./configuration/configuration.schema.json ./docs/configuration.schema.json + protoc:check: desc: Perform linting of the protobuf definitions cmds: diff --git a/docs/configuration.md b/docs/configuration.md index 16cacfcc5a6..7cfad9271c3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -105,6 +105,9 @@ The configuration file must be named `arduino-cli`, with the appropriate file ex - envfile - [INI] +The configuration file [JSON schema][configuration-schema] can be used to independently validate the file content. This +schema should be considered unstable in this version. + #### Locations Configuration files in the following locations are recognized by Arduino CLI: @@ -158,3 +161,4 @@ additional_urls = [ "https://downloads.arduino.cc/packages/package_staging_index [java properties file]: https://en.wikipedia.org/wiki/.properties [hcl]: https://github.com/hashicorp/hcl [ini]: https://en.wikipedia.org/wiki/INI_file +[configuration-schema]: ./configuration.schema.json From 34d95f87a307bab67d9fce666dbdde44a394341b Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:33:26 +0100 Subject: [PATCH 15/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index c1378b02235..b3133b2ecdc 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -22,8 +22,7 @@ "properties": { "compilations_before_purge": { "description": "interval, in number of compilations, at which the cache is purged, defaults to `10`. When `0` the cache is never purged.", - "type": "number", - "format": "integer", + "type": "integer" "minimum": 0 }, "ttl": { From 1d51c364ba1a9a6a1a5210c5b8c940ac3d1e067a Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:33:34 +0100 Subject: [PATCH 16/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index b3133b2ecdc..90bdf22d9e5 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -29,8 +29,7 @@ "description": "cache expiration time of build folders. If the cache is hit by a compilation the corresponding build files lifetime is renewed. The value format must be a valid input for time.ParseDuration(), defaults to `720h` (30 days)", "oneOf": [ { - "type": "number", - "format": "integer", + "type": "integer" "minimum": 0 }, { From 20a990e47f9e3fa758f87aa59373d10f9435124e Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Fri, 17 Feb 2023 11:41:27 +0100 Subject: [PATCH 17/20] fix: json --- configuration/configuration.schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 90bdf22d9e5..2736e5f1b8f 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -22,14 +22,14 @@ "properties": { "compilations_before_purge": { "description": "interval, in number of compilations, at which the cache is purged, defaults to `10`. When `0` the cache is never purged.", - "type": "integer" + "type": "integer", "minimum": 0 }, "ttl": { "description": "cache expiration time of build folders. If the cache is hit by a compilation the corresponding build files lifetime is renewed. The value format must be a valid input for time.ParseDuration(), defaults to `720h` (30 days)", "oneOf": [ { - "type": "integer" + "type": "integer", "minimum": 0 }, { From a46c294b58c55b8d37924d203792c8893976437c Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Mon, 20 Feb 2023 15:39:07 +0100 Subject: [PATCH 18/20] Update docs/configuration.md Co-authored-by: per1234 --- docs/configuration.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 540ad974e1a..6517c921d3a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -111,6 +111,8 @@ The configuration file must be named `arduino-cli`, with the appropriate file ex - envfile - [INI] +#### JSON schema + The configuration file [JSON schema][configuration-schema] can be used to independently validate the file content. This schema should be considered unstable in this version. From 23aeee2f2d0381e0ef7219582339a6aa42c5c350 Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Mon, 20 Feb 2023 15:43:12 +0100 Subject: [PATCH 19/20] chore: reorder paragraph --- docs/configuration.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 6517c921d3a..b03cbaa3e25 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -111,11 +111,6 @@ The configuration file must be named `arduino-cli`, with the appropriate file ex - envfile - [INI] -#### JSON schema - -The configuration file [JSON schema][configuration-schema] can be used to independently validate the file content. This -schema should be considered unstable in this version. - #### Locations Configuration files in the following locations are recognized by Arduino CLI: @@ -151,6 +146,11 @@ Doing the same using a TOML format file: additional_urls = [ "https://downloads.arduino.cc/packages/package_staging_index.json" ] ``` +#### JSON schema + +The configuration file [JSON schema][configuration-schema] can be used to independently validate the file content. This +schema should be considered unstable in this version. + [grpc]: https://grpc.io [sketchbook directory]: sketch-specification.md#sketchbook [arduino cli lib install]: commands/arduino-cli_lib_install.md From 46cf49ba8521608fc45dedd8cf2be142100484b4 Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Tue, 21 Feb 2023 16:42:21 +0100 Subject: [PATCH 20/20] Update configuration/configuration.schema.json Co-authored-by: per1234 --- configuration/configuration.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/configuration.schema.json b/configuration/configuration.schema.json index 2736e5f1b8f..dae8cf66a6d 100644 --- a/configuration/configuration.schema.json +++ b/configuration/configuration.schema.json @@ -34,7 +34,7 @@ }, { "type": "string", - "pattern": "^[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$" + "pattern": "^\\+?([0-9]?\\.?[0-9]+(([nuµm]?s)|m|h))+$" } ] }