Summary
Add a cue_vet_test Bazel test rule that runs cue vet to validate YAML/JSON data files against a cue_instance schema.
Motivation
cue vet is the standard way to validate data files (YAML, JSON) against CUE schemas (docs). There's currently no rules_cue support for this — users can only export or def, but cannot express "this YAML must conform to this CUE schema" as a Bazel test.
Proposed API
load("@rules_cue//cue:defs.bzl", "cue_vet_test")
cue_vet_test(
name = "validate_config",
instance = ":my_schema_instance",
data = ["config.yaml", "overrides.yaml"],
schema_expression = ["#Config"],
concrete = True, # default
)
Attributes
| Attribute |
Type |
Default |
Description |
instance |
label |
required |
cue_instance target providing the schema |
data |
label_list |
required |
YAML/JSON files to validate |
schema_expression |
string_list |
[] |
-d expressions selecting schema definitions |
concrete |
bool |
True |
Pass -c flag (require concrete values) |
Behavior
- Pass:
cue vet exits 0 (silent)
- Fail:
cue vet exits non-zero, error output in test log
Implementation Notes
- New Bazel test rule (
rule(test = True, ...))
- Consumes
CUEInstanceInfo provider from instance attr
- Generates a shell test runner via
ctx.actions.write (does not reuse cue-run-from-runfiles — that wrapper assumes output file production)
- Uses existing CUE toolchain (
//tools/cue:toolchain_type)
Out of Scope
- Standalone file validation (no
cue_instance) — could be added later
cue vet on CUE-only packages (-c=false ./... pattern)
Summary
Add a
cue_vet_testBazel test rule that runscue vetto validate YAML/JSON data files against acue_instanceschema.Motivation
cue vetis the standard way to validate data files (YAML, JSON) against CUE schemas (docs). There's currently no rules_cue support for this — users can onlyexportordef, but cannot express "this YAML must conform to this CUE schema" as a Bazel test.Proposed API
Attributes
instancelabelcue_instancetarget providing the schemadatalabel_listschema_expressionstring_list[]-dexpressions selecting schema definitionsconcreteboolTrue-cflag (require concrete values)Behavior
cue vetexits 0 (silent)cue vetexits non-zero, error output in test logImplementation Notes
rule(test = True, ...))CUEInstanceInfoprovider frominstanceattrctx.actions.write(does not reusecue-run-from-runfiles— that wrapper assumes output file production)//tools/cue:toolchain_type)Out of Scope
cue_instance) — could be added latercue veton CUE-only packages (-c=false ./...pattern)