Metadata-Version: 2.4
Name: dbt-ci
Version: 1.26.3
Summary: CI/CD tool for dbt projects with intelligent change detection and selective execution
Author-email: Patrick Tannoury <patrick.tannoury@datablock.dev>
License: MIT License
        
        Copyright (c) 2026 DataBlock
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://datablock.dev/dbt-ci
Project-URL: Documentation, https://datablock.dev/dbt-ci/docs
Project-URL: Repository, https://github.com/datablock-dev/dbt-ci
Project-URL: Issues, https://github.com/datablock-dev/dbt-ci/issues
Project-URL: Changelog, https://github.com/datablock-dev/dbt-ci/releases
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click<9,>=8.1
Requires-Dist: pyyaml<7,>=6.0
Requires-Dist: dbt-core<2.0.0,>=1.10.13
Requires-Dist: slack-sdk<4,>=3.27
Provides-Extra: gcp
Requires-Dist: google-cloud-bigquery<4,>=3.20; extra == "gcp"
Requires-Dist: google-cloud-storage<4,>=2.14; extra == "gcp"
Provides-Extra: aws
Requires-Dist: boto3<2,>=1.34; extra == "aws"
Provides-Extra: docker
Requires-Dist: docker<8,>=7.0; extra == "docker"
Provides-Extra: all
Requires-Dist: dbt-ci[gcp]; extra == "all"
Requires-Dist: dbt-ci[aws]; extra == "all"
Requires-Dist: dbt-ci[docker]; extra == "all"
Provides-Extra: dev
Requires-Dist: dbt-ci[all]; extra == "dev"
Requires-Dist: pytest==9.2.0; extra == "dev"
Requires-Dist: black==26.10.1; extra == "dev"
Requires-Dist: mypy==2.4.1; extra == "dev"
Requires-Dist: flake8==7.5.0; extra == "dev"
Requires-Dist: duckdb==2.0.1; extra == "dev"
Requires-Dist: pytest-cov==7.1.0; extra == "dev"
Requires-Dist: pytest-mock==3.17.0; extra == "dev"
Dynamic: license-file

# dbt-ci

[![Tests](https://github.com/datablock-dev/dbt-ci/actions/workflows/tests.yml/badge.svg)](https://github.com/datablock-dev/dbt-ci/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/dbt-ci)](https://pypi.org/project/dbt-ci/)
[![Python](https://img.shields.io/pypi/pyversions/dbt-ci)](https://pypi.org/project/dbt-ci/)
[![dbt-core](https://img.shields.io/badge/dbt--core-1.10%20%7C%201.11%20%7C%201.12-orange?logo=dbt&logoColor=white)](https://github.com/datablock-dev/dbt-ci/actions/workflows/tests.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/datablock-dev/dbt-ci/blob/main/LICENSE)

**Slim CI for dbt Core, in your own pipeline.** dbt-ci builds and tests only what a pull
request changes, tells reviewers which dashboards it affects, and cleans up after itself.
It runs in GitHub Actions, GitLab CI or anywhere else Python runs, and it's free and open source.

Every pull request gets a comment like this one, updated on each push:

> ## dbt-ci run report
>
> `feature/orders-daily` → `main` · commit `1a2b3c4` · PR #42 · GitHub Actions pull-request ([run](#))
>
> | Change | Count |
> |---|---:|
> | Modified | 1 |
> | New | 1 |
> | Deleted | 1 |
>
> **Modified (1)**
>
> - `stg_customers` (model): `models/staging/stg_customers.sql` changed
>
> **New (1)**
>
> - `orders_daily` (model): `models/marts/orders_daily.sql` added
>
> **Deleted (1)**
>
> - `legacy_orders` (model): `models/marts/legacy_orders.sql` deleted
>
> ### ⚠️ Affects 1 exposure(s)
>
> - `revenue_dashboard`
>
> ### Run time
>
> Built **2** node(s) in **41s** of dbt run time.
> The **186** other node(s) with a recorded run time took about **23m 10s** when they last ran, so this run skipped about **97%** of the run time of a full build.
>
> ### Commands
>
> | Command | Status | Duration |
> |---|---|---:|
> | `init` | ✅ completed | 8.4s |
> | `run` | ✅ completed | 8.9s |

## Quick start

### GitHub Actions

```yaml
name: dbt CI

on:
  pull_request:

permissions:
  contents: read
  pull-requests: write   # for the PR comment

jobs:
  dbt-ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0

      # Authenticate to your warehouse and state bucket here

      - uses: datablock-dev/dbt-ci@v1
        with:
          project-dir: dbt
          profiles-dir: dbt
          target: ci
          state-uri: gs://my-bucket/dbt-state/manifest.json   # or s3://
          reference-target: production
          extras: gcp
          adapter: dbt-bigquery
```

That's the whole setup. See the [GitHub Action docs](https://github.com/datablock-dev/dbt-ci/blob/main/docs/github-action.md) for every
input, output and command.

### Any other CI

```bash
pip install 'dbt-ci[gcp]' dbt-bigquery

dbt-ci init --dbt-project-dir dbt --state-uri gs://my-bucket/dbt-state/manifest.json \
  --reference-target production --target ci
dbt-ci run       # build and test the changed nodes and their dependents
dbt-ci report    # summarise the change set (and post it with --pr-comment)
```

There are ready-made [CI/CD examples](https://github.com/datablock-dev/dbt-ci/blob/main/docs/ci-examples.md), including GitLab CI.

## Why dbt-ci?

dbt Core can already select changed models with `--select state:modified+`. dbt-ci builds
on that and handles the parts you would otherwise script yourself:

| | dbt Core alone | dbt-ci |
|---|---|---|
| Build only changed nodes and their dependents | ✅ `state:modified+` | ✅ |
| Fetch the production manifest from GCS or S3 | You script it | ✅ `--state-uri` |
| Ignore changes that only come from environment-specific config | ❌ | ✅ `hybrid` keeps only nodes the git diff also touches |
| Ignore changes merged into `main` after the branch was created | ❌ | ✅ compares against the branch's merge base by default (`init --compare-to`) |
| Comment the change set and affected exposures on the PR | ❌ | ✅ `report --pr-comment` |
| Show how much build time a PR skipped | ❌ | ✅ the report's run time section |
| Post a summary to Slack | ❌ | ✅ |
| Zero-copy PR environment that is torn down afterwards | `dbt clone`, teardown by hand | ✅ `ephemeral create` / `destroy` |
| Drop tables of models deleted in the PR | ❌ | ✅ `delete` |
| Move tables onto a changed partitioning, clustering or sort key, keeping their rows | ❌ | ✅ `migration` (BigQuery, Snowflake, Redshift, Databricks) |
| Run a changed test without rebuilding its model | ❌ | ✅ `run --skip-test-only-changes` (opt-in) |
| Retry a failed step from the point of failure within the CI run | `dbt retry`, run by hand | ✅ `run --retries` (opt-in) |
| Warn when the production state was built by another dbt version | ❌ | ✅ `init` and the report flag it, since it can mark unchanged nodes as modified |

On dbt Cloud, its CI jobs already run `state:modified+` with deferral. dbt-ci is for
teams that run dbt Core in their own CI. It decides *what* to build; data-diff tools such
as Datafold or Recce compare the data that was built, and work alongside it.

## How it works

```mermaid
flowchart LR
    prod["Production deploy<br/>uploads manifest.json"] --> bucket[("GCS / S3")]
    bucket --> init
    subgraph pr["Pull request CI"]
        init["init<br/>compare against production<br/>(dbt state + git diff)"] --> run["run<br/>build & test changed nodes<br/>and their dependents"]
        run --> report["report<br/>job summary + PR comment"]
    end
```

1. **`init`** downloads the production manifest, compares it with the pull request, and
   caches the change set: modified, new and deleted nodes, each with the reason it is
   there.
2. **`run`**, **`ephemeral`**, **`delete`** and **`migration`** read that cache, so the
   state is resolved once per CI run.
3. **`report`** renders the change set, the exposures it affects and the status of each
   command, then **`finalize`** uploads the artifacts and clears the cache.

## Commands

| Command | What it does |
|---------|--------------|
| [`init`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#init---initialize-state) | Compare the PR against the production state and cache the change set |
| [`run`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#run---run-modified-models) | Build and test the changed nodes, optionally capped with `--downstream-depth`, narrowed with dbt selectors (`--select`, `--exclude`) or with test-only changes skipped (`--skip-test-only-changes`). Failed steps can be retried with `dbt retry` (`--retries`) |
| [`ephemeral`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#ephemeral---ephemeral-environment) | Clone what the PR needs into an isolated schema, and tear it down afterwards |
| [`delete`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#delete---delete-removed-models) | Drop the tables of models the PR removed |
| [`migration`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#migration---migrate-table-layout-changes) | Move incremental tables onto a changed partitioning, clustering, sort or distribution key, keeping their rows |
| [`report`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#report---summarise-the-run) | Write the run report to the job summary, a file or a PR comment |
| [`finalize`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#finalize---finalize-state) | Upload artifacts to GCS or S3 and clear the cache, without letting an older deploy overwrite a newer one's manifest. `{pr}` and `{branch}` in `--artifacts-uri` give every pull request its own folder |
| [`config`](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md#config---generate-a-config-file) | Generate a commented `dbt-ci.config.yaml`, or `config show` the settings a command would run with and where each came from |

## Compatibility

| | Supported |
|---|---|
| dbt | dbt-core 1.10, 1.11 and 1.12, and [dbt v2](https://github.com/datablock-dev/dbt-ci/blob/main/docs/configuration.md#dbt-v2). Upcoming dbt releases are tested twice a week, before they ship |
| Python | 3.12, 3.13, 3.14 |
| Warehouses | Any dbt adapter. `migration` changes table layouts on BigQuery, Snowflake, Redshift and Databricks; other warehouses have no layout config to migrate |
| State storage | GCS, S3 or a local path |
| How dbt runs | In-process, a local binary, Docker or a shell script ([runners](https://github.com/datablock-dev/dbt-ci/blob/main/docs/runners.md)) |

## Documentation

- [GitHub Action](https://github.com/datablock-dev/dbt-ci/blob/main/docs/github-action.md): inputs, outputs and command lists
- [Installation](https://github.com/datablock-dev/dbt-ci/blob/main/docs/installation.md): extras, supported versions, development install
- [Commands](https://github.com/datablock-dev/dbt-ci/blob/main/docs/commands.md): every command and its flags
- [Configuration](https://github.com/datablock-dev/dbt-ci/blob/main/docs/configuration.md): `dbt-ci.config.yaml`, its sections, profiles and per-event (pull request / push / schedule) settings with a local preview (`config show --event push`), dry runs per command, common flags, environment variables, cache
- [Runners](https://github.com/datablock-dev/dbt-ci/blob/main/docs/runners.md): in-process, local, Docker and bash
- [State storage](https://github.com/datablock-dev/dbt-ci/blob/main/docs/state-storage.md): keeping the production manifest in GCS or S3
- [CI/CD examples](https://github.com/datablock-dev/dbt-ci/blob/main/docs/ci-examples.md): GitHub Actions without the action, a reusable workflow built on profiles, Slack notifications only on deploys, GitLab CI, common workflows

## Contributing

Contributions are welcome. See [CONTRIBUTING.md](https://github.com/datablock-dev/dbt-ci/blob/main/CONTRIBUTING.md) for the development
setup, and [RELEASING.md](https://github.com/datablock-dev/dbt-ci/blob/main/RELEASING.md) for how releases are published.
Questions and ideas go to [GitHub Issues](https://github.com/datablock-dev/dbt-ci/issues).

## License

[MIT](https://github.com/datablock-dev/dbt-ci/blob/main/LICENSE)
