Skip to content

Add unit json schema (infra)#2354

Merged
fernando79513 merged 3 commits intomainfrom
json_schema
Mar 10, 2026
Merged

Add unit json schema (infra)#2354
fernando79513 merged 3 commits intomainfrom
json_schema

Conversation

@Hook25
Copy link
Collaborator

@Hook25 Hook25 commented Feb 27, 2026

Description

This adds a json schema for yaml Checkbox units. This also adds pre-configuration for VS Code to simplify the life of those using it, which I think is why we committed it to the repo.

Minor: this fixes a missing exporter in the docs I found.

Resolved issues

Fixes: CHECKBOX-1396

Documentation

N/A

Tests

Tested locally with the vs code plugin + the neovim lsp plugin

Copy link
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very very cool.
I've run it in all the yaml files in the base provider, and mostly the linting issues were related to the estimated duration issues:
https://docs.google.com/spreadsheets/d/1G-8OoozIgTTThQCZA-tSOnv5Nyj1aDVDkQH5_vigtQY/edit?gid=0#gid=0

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a JSON Schema set intended to validate Checkbox “unit” definitions (job/test plan/category/template/exporter/manifest entry/packaging meta-data), plus editor configuration to wire the schema into VS Code, and a small documentation correction for exporter units.

Changes:

  • Added a top-level unit schema (unit.schema.json) and per-unit schemas under unit_json_schema/.
  • Updated exporter documentation to include tar and tp-export as supported values/options.
  • Added a VS Code YAML schema mapping to apply the unit schema to selected YAML file globs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
unit_json_schema/unit.schema.json Entry-point schema that references the per-unit schemas via $ref.
unit_json_schema/job.schema.json Schema for job units (shared fields + siblings).
unit_json_schema/test-plan.schema.json Schema for test plan units including include/mandatory/bootstrapping fields.
unit_json_schema/category.schema.json Schema for category units.
unit_json_schema/template.schema.json Schema for template units (extends job fields).
unit_json_schema/exporter.schema.json Schema for exporter units.
unit_json_schema/manifest-entry.schema.json Schema for manifest entry units.
unit_json_schema/packaging-meta-data.schema.json Schema for packaging meta-data units.
docs/reference/units/exporter.rst Documentation update to reflect tar and tp-export.
.vscode/settings.json VS Code YAML schema association configuration.

Key issues to address before this is practically usable in-repo (all verified against existing provider .pxu unit files and the docs in docs/reference/units/):

  • All schemas use $id values pointing at a non-existent schema_checkbox/ path and also use GitHub blob/ URLs (HTML), which will break remote resolution and can break relative $ref resolution in some tooling.
  • Several schemas require non-underscored fields (e.g. name, summary, template-summary) but existing units and docs consistently use translatable underscore forms (e.g. _name, _summary, _template-summary)—causing widespread validation failures.
  • Multiple fields are typed as arrays in the schemas (e.g. depends, requires, imports, flags, environ), but are commonly expressed as scalar strings in existing .pxu units (and documented as space/comma-separated lists), which will also fail validation.
  • template.schema.json restricts template-unit to const: "job", but the template unit documentation explicitly states other values may be used.
  • .vscode/settings.json maps the schema to units/*.yaml globs, but this repository’s actual unit files are primarily providers/**/units/**/*.pxu (so the mapping won’t apply unless .pxu is associated and included).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Minor: more permissive expected duration
@fernando79513
Copy link
Collaborator

fernando79513 commented Mar 10, 2026

I run the "lint report" again. Most of the issues seem to be with the jobs, not the linter

  • Description field present
  • Summary field missing
  • jinja templates
  • providers/genio/units/peripheral/jobs.yaml: plugin missing 'shell76'
  • providers/base/units/disk/jobs.yaml: flag missing 'deprecated'

yaml-lint-report.csv

There are still some issues that we may want to address

  • providers/genio/units/thermal/jobs.yaml: 'autorestart' flag missing link
  • Some categories are using the "summary" field (providers/base/units/stress/s3s4.yaml). Is this intended, or just a misuse? link
  • Template units don't accept siblings, but we are using them in some jobs (providers/base/units/wwan/jobs.yaml: wwan/gsm-connection-{manufacturer}-{model}-{hw_id}-auto) link

@Hook25
Copy link
Collaborator Author

Hook25 commented Mar 10, 2026

  • autorestart: fixed, even though we should deprecate it as well
  • shell76, I can't find it, are you sure its there?
  • sibling of templates, I'm not sure they would/wouldnt work, what should I do? Support them or..? I don't think we can realistically make the repo clean in one pr

@fernando79513
Copy link
Collaborator

  • Nice
  • This was my bad, I typed on the translated yaml by mistake
  • They are supported (but they require a specific syntax with two brackets). I think the complexity they involve is not worth the simplifications that they achieve. We can keep them out of the linter and not encourage using them

Copy link
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM+1!

@fernando79513 fernando79513 merged commit 66408e7 into main Mar 10, 2026
78 checks passed
@fernando79513 fernando79513 deleted the json_schema branch March 10, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants