Skip to content

feat: add cue_vet_test rule for validating data files against CUE schemas#28

Open
jaqx0r wants to merge 2 commits into
seh:mainfrom
jaqx0r:feat/cue-vet-test
Open

feat: add cue_vet_test rule for validating data files against CUE schemas#28
jaqx0r wants to merge 2 commits into
seh:mainfrom
jaqx0r:feat/cue-vet-test

Conversation

@jaqx0r

@jaqx0r jaqx0r commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Adds a cue_vet_test Bazel test rule that runs cue vet to validate YAML/JSON data files against a cue_instance schema.

API

load("@rules_cue//cue:cue.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)

Implementation Notes

  • New Bazel test rule (rule(test = True, ...)) — pass = exit 0, fail = non-zero + error in test log
  • Generates a dedicated shell test runner via ctx.actions.write (does not reuse cue-run-from-runfiles, which assumes --outfile output production)
  • Uses existing CUE toolchain (//tools/cue:toolchain_type)
  • Instance path computed module-relative via paths.relativize (same as _make_instance_consuming_action)
  • Runfiles resolved via rlocation using _runfile_path (existing helper, not duplicated)

Testing

  • test/testdata/vet/ — new testdata directory with #Config schema, valid.yaml, passing cue_vet_test target

Closes #27

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.

feat: add cue_vet_test rule for validating data files against CUE schemas

1 participant