CI/CD Integration
rocky ci compiles and tests your project in one step. It runs on your CI machine, on DuckDB, with no warehouse credentials, so it is a cheap required check on a pull request.
1. The rocky ci Command
Section titled “1. The rocky ci Command”rocky ci --contracts contractsWith no --models, the command covers the models of every transformation pipeline. It runs two phases in order:
- Compile: type-check every model, resolve the DAG, validate contracts. When the project has
data/seed.sql, the types come from the tables it makes. - Test: execute each model’s SQL against DuckDB in dependency order, on the seed’s tables
Exit 0 means every check passed. Exit 1 means a compilation or test failure. Compile catches type mismatches, missing dependencies and contract violations. Test catches faults that show only when the SQL runs: syntax errors, division by zero, invalid casts.
Structural diff against a base ref
Section titled “Structural diff against a base ref”rocky ci-diff answers a different question for a reviewer: what did this branch change? It compares model files between a base git ref and HEAD, compiles both sides, and reports the added, modified, and removed columns per model. It writes JSON for your pipeline and Markdown for a PR comment:
rocky ci-diff # defaults to mainrocky ci-diff release/2026-04 --models src/modelsci-diff reads HEAD and the merge base from git, so uncommitted edits never reach the report. Pass --working-tree to preview uncommitted work. The JSON output says which ran in mode.
In GitHub Actions, post that Markdown block straight to the PR:
- name: Post diff to PR run: | rocky ci-diff --output json | jq -r .markdown | \ gh pr comment "$PR_NUMBER" --body-file - env: PR_NUMBER: ${{ github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Semantic breaking-change findings and the promote gate
Section titled “Semantic breaking-change findings and the promote gate”Three commands run the same breaking-change classifier over the typed IR (the compiler’s typed graph of your models, see the glossary). Two of them only report. One of them blocks:
reporting only the gate ───────────────────────────── ──────────────────────────────────── rocky plan --semantic rocky plan promote <branch> (your working tree) │ rocky ci-diff --semantic ├─ a `breaking` finding (a branch, at PR time) │ └─► no plan_id: the promote │ │ stops here ├─► findings in the JSON │ │ the exit code never └─ no `breaking` finding │ changes └─► plan_id ─► rocky apply │ replays the └─► a reviewer reads them recorded verdictrocky ci-diff --semantic runs the classifier on top of the structural diff and puts the findings under breaking_findings in the JSON output:
rocky ci-diff --semantic --output json | jq '.breaking_findings'Each finding carries a tagged change.kind (such as column_dropped, column_type_changed, target_renamed) and a severity (breaking, warning, or info). ci-diff --semantic is informational: a breaking finding does not change its exit code.
rocky plan --semantic gives the author the same verdict at plan time. It diffs your working tree, uncommitted edits included, against --base (default main), and attaches the verdict under breaking_verdict in the JSON output:
rocky plan --semantic --base main --output json | jq '.breaking_verdict'This reports only. When no baseline exists (no models/ directory, or the --base ref’s models do not compile), Rocky omits breaking_verdict. The hard gate is rocky plan promote, below.
The hard gate lives on rocky plan promote and rocky apply. When you promote a branch to production, Rocky runs the same classifier against --base (default main). Any finding with severity == "breaking" blocks the promote at plan time.
The gate fires once. A blocked promote produces no plan_id, so rocky apply has nothing to run. Rocky records the gate result in the plan and does not re-evaluate it at apply time. To ship a breaking change on purpose, pass --allow-breaking at plan time. The override emits a breaking_changes_allowed audit event.
# Promote-time gate (blocks on `breaking` findings); add --allow-breaking to override (audited)plan_id=$(rocky plan promote fix_price --base main --output json | jq -r .plan_id)rocky apply "$plan_id"The bare rocky branch promote <name> form still works as an alias for the two-step flow above. See rocky branch promote for the flag list, and the branch_promote schema for the audit-event reference.
2. GitHub Actions
Section titled “2. GitHub Actions”Basic setup
Section titled “Basic setup”name: Rocky CIon: pull_request: paths: - "models/**" - "contracts/**" - "rocky.toml" - "tests/**"
jobs: rocky: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Install Rocky run: | curl -fsSL https://raw.githubusercontent.com/rocky-data/rocky/main/engine/install.sh | bash echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Compile and Test run: rocky ci --models models --contracts contractsJSON output and artifacts
Section titled “JSON output and artifacts”Add -o json > ci-report.json to any command, then upload the file with actions/upload-artifact@v4 (if: always()) to keep the detail after the job ends. To comment on the PR, use the rocky ci-diff step above.
3. GitLab CI
Section titled “3. GitLab CI”Basic setup
Section titled “Basic setup”rocky-ci: image: python:3.13-slim before_script: - apt-get update && apt-get install -y --no-install-recommends curl ca-certificates - curl -fsSL https://raw.githubusercontent.com/rocky-data/rocky/main/engine/install.sh | bash - export PATH="$HOME/.local/bin:$PATH" script: - rocky ci --models models --contracts contracts rules: - changes: - models/** - contracts/** - rocky.tomlTo report a compile failure early, split rocky compile and rocky test into two jobs (stages compile and test, needs: [rocky-compile] on the second).
4. Using rocky compile for PR Checks
Section titled “4. Using rocky compile for PR Checks”rocky compile skips tests, so it is faster than rocky ci:
rocky compile --models models --contracts contractsThe compiler catches type mismatches (a column Int64 in one model and String in another), a depends_on that names a missing model, contract violations, DAG cycles, and SQL that names a table or column Rocky cannot find.
To check one model while you work on it:
rocky compile --models models --model revenue_summary5. AI-Powered Test Coverage
Section titled “5. AI-Powered Test Coverage”rocky ai-test writes test assertions from your models. It needs ANTHROPIC_API_KEY set.
Generate tests locally
Section titled “Generate tests locally”export ANTHROPIC_API_KEY="sk-ant-..."
# Add intent descriptions to all models (one-time setup)rocky ai-explain --all --save --models models
# Generate test assertions from intentrocky ai-test --all --save --models modelsThis writes one standalone .sql assertion per file into tests/, a sibling of models/. rocky ci and rocky test do not pick them up: they execute your models and any [[test]] sidecar blocks, never loose tests/*.sql files. Commit them and run them in your own CI step against DuckDB. For gating that Rocky runs itself, declare [[tests]] in the model sidecars and run rocky test --declarative.
rocky ai-test revenue_summary --save --models models generates tests for one model.
CI workflow with AI test generation
Section titled “CI workflow with AI test generation”Generate the tests on a schedule and open a PR. Use the same install step as in Basic setup:
name: Update AI Testson: schedule: - cron: "0 6 * * 1" # Every Monday at 6am
jobs: update-tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # ...install Rocky as in Basic setup... - name: Generate Tests env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | rocky ai-explain --all --save --models models rocky ai-test --all --save --models models - name: Create PR uses: peter-evans/create-pull-request@v6 with: title: "test: update AI-generated test assertions" body: "Auto-generated test updates from `rocky ai-test`" branch: update-ai-tests6. Integration with Dagster CI
Section titled “6. Integration with Dagster CI”If Dagster orchestrates Rocky, add a second job that runs after rocky ci (needs: [rocky]): install dagster dagster-rocky with uv add and run uv run dg check defs. rocky ci validates the models on their own. dg check defs confirms that the orchestration layer can load them into assets.
7. JSON Output
Section titled “7. JSON Output”Every CI command emits structured JSON. The JSON output reference has the full shapes. rocky ci returns:
{ "version": "1.80.0", "command": "ci", "compile_ok": true, "tests_ok": true, "models_compiled": 12, "tests_passed": 12, "tests_failed": 0, "exit_code": 0, "diagnostics": [], "failures": []}Parse the payload with jq:
rocky ci -o json | jq -e '.tests_failed == 0'rocky compile -o json | jq '.diagnostics[] | select(.severity == "Error") | .message'