Skip to content

validate

The validate command checks your cigen configuration for errors without generating any output files.

Terminal window
cigen validate [OPTIONS]

Path to the cigen configuration directory or file.

  • Default: Current directory (.)
  • Example: --config .cigen/ or --config .cigen/config.yml

Enable verbose output showing detailed validation steps.

Enable strict validation mode with additional checks.

Terminal window
cigen validate
Terminal window
cigen validate --config .cigen/
Terminal window
cigen validate --config .cigen/ --verbose

The validate command performs comprehensive checks:

  • YAML syntax validation
  • JSON schema compliance
  • Required field presence
  • Image specifications
  • Step references and syntax
  • Dependency graphs (circular dependency detection)
  • Required vs optional fields
  • Job references exist
  • Dependency chains are valid
  • No orphaned jobs
  • All referenced variables are defined
  • Template syntax is correct
  • No undefined template expressions
  • CircleCI: Resource class compatibility, orb usage
  • Platform-specific constraints and limits
  • Referenced files exist (e.g., Dockerfiles, scripts)
  • Source file groups are valid
  • Cache key dependencies are resolvable
  • Schema compliance
  • Basic syntax checks
  • Job/workflow reference validation
  • All basic validations
  • Warning-level issues become errors
  • Additional best practice checks
  • Performance impact analysis
Error: Invalid job configuration at 'jobs.test'
- Missing required property 'image'
- Property 'invalid_field' is not allowed

Solution: Fix the job definition to match the schema requirements.

Error: Circular dependency detected
- job_a -> job_b -> job_c -> job_a

Solution: Remove circular references in job requires fields.

Error: Undefined variable 'app_name' in template
- File: workflows/main/jobs/deploy.yml
- Line: 12

Solution: Define the variable in your vars section:

vars:
app_name: my-application
Error: Referenced file not found
- File: Dockerfile.production
- Referenced in: jobs.build_production.dockerfile

Solution: Create the missing file or correct the reference.

  • 0: Validation passed
  • 1: Validation errors found
  • 2: Configuration file not found
  • 3: Internal validation error
repos:
- repo: local
hooks:
- id: cigen-validate
name: Validate cigen config
entry: cigen validate
language: system
files: '^\.cigen/'
pass_filenames: false
# GitHub Actions
- name: Validate CI config
run: cigen validate --config .cigen/ --strict
# CircleCI
- run:
name: Validate CI config
command: cigen validate --config .cigen/ --strict

For VS Code, add to .vscode/settings.json:

{
"yaml.schemas": {
"https://cigen.dev/schemas/v1/config-schema.json": ".cigen/config.yml"
}
}

Validation is typically fast:

  • Small configs (< 10 jobs): < 100ms
  • Medium configs (10-50 jobs): < 500ms
  • Large configs (50+ jobs): < 2 seconds

Strict mode adds ~50% overhead for additional checks.

Run validation frequently during development:

Terminal window
# Watch for changes and validate
watch -n 1 cigen validate
  • Add validation to pull request checks
  • Include validation in development workflows
  • Use --strict mode in CI pipelines

Structure your config for easier validation:

.cigen/
├── config.yml # Main config
├── jobs/ # Job definitions
├── workflows/ # Workflow definitions
└── templates/ # Custom templates
  1. YAML Indentation: Use consistent 2-space indentation
  2. Missing References: Ensure all referenced jobs/commands exist
  3. Schema Mismatches: Check field names against documentation
  4. Template Syntax: Verify Jinja2 template expressions

Enable debug output for complex validation issues:

Terminal window
RUST_LOG=debug cigen validate --verbose