What Turbo CI builds
Why does Turbo CI build a model my pull request didn't change?
Why does Turbo CI build a model my pull request didn't change?
Turbo CI runs on your pull request’s latest commit, exactly as you pushed it. Commands that select with To fix it, merge your default branch into your branch, or rebase onto it, and push. The next Turbo CI run compares matching files and skips the model.
state:modified (or a sub-selector such as state:modified.body) compare each file in that commit with the manifest.json of the schedule you defer to, which usually runs on your default branch. A model counts as modified whenever its file differs from that manifest, not only when your pull request changed it.So if your default branch changes a model after your branch last merged it, your branch still has the older copy of that model. The file differs from the manifest, and Turbo CI builds the model even though your pull request’s list of changed files doesn’t include it.To confirm, compare the file on your branch with the default branch, then with your pull request’s own changes:Deferred-to runs older than 60 days
What happens when the schedule I defer to hasn't run for more than 60 days?
What happens when the schedule I defer to hasn't run for more than 60 days?
Bolt archives run artifacts 60 days after a run starts. If the newest
manifest.json of the schedule or environment your Turbo CI schedule defers to is older than that, Bolt can’t read it:- Bolt doesn’t stop the run. It runs without defer, and the first dbt™ command in the run log starts with
⚠ Defer skipped: .... Commands that select withstate:modifiedhave no manifest to compare against, so dbt™ can fail them. - The Lineage Diff check has no base manifest to compare against. Its text starts with
Base manifest unavailable:and names the run date.
target/manifest.json (any dbt run, build, compile, or parse does), or change the Turbo CI schedule’s Defer to to a schedule that runs regularly.One project, several warehouse accounts
dbt clone fails for a model that exists in one Snowflake account but not in another
dbt clone fails for a model that exists in one Snowflake account but not in another
Some teams run one dbt™ project against several warehouse accounts, for example one Snowflake account per region, with a Turbo CI schedule per account and a tag on each model that says where it runs. See Run several Turbo CI checks on a pull request for the setup. The first time a pull request adds a model that already runs in one account to a second account, the Register it in 2. Create the incremental models before the buildBetween the clone and the build, add a The build then runs a skipped model incrementally against its empty table. If the model’s incremental filter reads from You still need the
dbt clone step fails in the second account with Snowflake’s Object '<database>.<schema>.<model>' does not exist or not authorized error.Each Turbo CI schedule defers to a schedule or environment on its own account, and state:modified compares your pull request with that account’s manifest.json. A manifest lists every model in the project, whatever its tags, so a model that was only ever built in the first account is still state:old in the second account’s manifest. dbt clone trusts the manifest, looks for the production table in the second account, and finds nothing.Dropping the clone step moves the error, because the model then has no table in the CI schema at all. The next failure is a unit test on an incremental model: dbt™ runs unit tests before it builds the model, and incremental models need to exist before dbt™ can unit test them.Before you change anything, check the schedule: Defer to on each Turbo CI schedule must point at a schedule or environment on the same warehouse account as the schedule’s CI environment. The steps below assume it does.1. Skip the clone when there is nothing to cloneAdd this macro to your dbt™ project. It keeps the regular zero-copy clone when the production table exists and logs a skip when it does not, so the model is built from scratch in the next command. It is the same override as Turbo CI with Snowflake shared databases; if you already use that one, merge the two conditions into one macro.create_or_replace_clone.sql
dbt_project.yml, replacing my_project with your project’s name:dbt_project.yml
dbt run --empty on the incremental models in your selection. It creates an empty table for each model that the clone skipped, which is what the unit tests need, and does nothing to the models that were cloned. This is the step dbt™ recommends for unit tests on incremental models. For a schedule whose models carry the eu tag and run on the ci_eu target:{{ this }}, the CI copy can end up with no rows; the unit tests and the schema tests still run.The longer-term fix: keep the manifest honestThe clone fails because the manifest says the model exists in an account where it never ran. If a model is enabled only under the targets of the accounts it is tagged for, it is state:new in every other account, the clone leaves it alone, and the build does a full first build:dbt run --empty step for unit tests on incremental models.