Overview
Thecerbos compile command compiles your Cerbos policies and optionally runs tests to verify they work as expected. This is useful for validating policies during development and in CI/CD pipelines.
Usage
Arguments
Path to the directory containing your Cerbos policies.
Flags
Testing
Skip running tests. Only compile the policies without executing test cases.
Filter tests by dimensions. Can be specified multiple times to combine filters.Format:
dimension=glob1,glob2;...Dimensions: suite, test, principal, resource, actionExample: --test-filter='suite=MySuite;test=album*;principal=alice'Skip batching tests. Run tests individually instead of in batches.
Enable verbose output on test failure. Shows detailed information about failed tests.
Output
Output format for compilation results.Options:
tree, list, jsonTest output format. If not specified, matches the value of
--output.Options: tree, list, json, junitOutput color level.Options:
auto, never, always, 256, 16mDisable colored output. Alternative to
--color=never.Schema Validation
Ignore schema validation during compilation. Useful when schemas are not available or validation should be skipped.
Legacy Options
Deprecated. Path to the directory containing tests. Defaults to the policy directory.
Deprecated. Run only tests that match this regex pattern.
Examples
Compile and run all tests
Compile without running tests
Run tests matching a specific filter
Combine multiple test filters
Output results as JSON
Generate JUnit test report
Verbose test output
Compile without color output
Ignore schema validation
Exit Codes
0- Success: All policies compiled and all tests passed3- Compilation failed: Policies have syntax or validation errors4- Tests failed: Policies compiled but some tests failed
Test Filters
Test filters allow you to run a subset of your tests based on various dimensions:- suite - Filter by test suite name
- test - Filter by test case name
- principal - Filter by principal in test
- resource - Filter by resource in test
- action - Filter by action in test
*, ?, etc.) and can be combined. Multiple values for the same dimension are OR’d together, while different dimensions are AND’d together.