Skip to content

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

Description

@jaqx0r

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions