Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge nov 20th - include custom cmd advanced ci #6346

Merged
merged 37 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f6d9ce5
add optimization tip
mirnawong1 Oct 23, 2024
b47f065
Update ci-jobs.md
mirnawong1 Oct 23, 2024
3cd60d5
Update website/docs/docs/deploy/job-commands.md
mirnawong1 Oct 23, 2024
7c9ccb2
reuben's updates
mirnawong1 Oct 23, 2024
5eaa38b
update
mirnawong1 Oct 23, 2024
1d8f8b6
update header
mirnawong1 Oct 23, 2024
f104df6
Update website/docs/docs/deploy/job-commands.md
mirnawong1 Oct 23, 2024
be7c9d1
Update website/docs/docs/deploy/job-commands.md
mirnawong1 Oct 23, 2024
0c3b983
add url img
mirnawong1 Oct 23, 2024
ff8c1df
Merge branch 'current' into custom-commands
mirnawong1 Oct 24, 2024
ee552c5
Merge branch 'current' into custom-commands
mirnawong1 Oct 28, 2024
169fcd7
Update website/docs/docs/deploy/ci-jobs.md
mirnawong1 Oct 28, 2024
5a6ed0c
Update website/docs/docs/deploy/ci-jobs.md
mirnawong1 Oct 28, 2024
c7f6ac3
Merge branch 'current' into custom-commands
mirnawong1 Oct 29, 2024
58548ee
Merge branch 'current' into custom-commands
mirnawong1 Oct 29, 2024
d7a8fab
Merge branch 'current' into custom-commands
mirnawong1 Oct 30, 2024
44a9a40
Update website/docs/docs/deploy/ci-jobs.md
mirnawong1 Oct 30, 2024
a0e441e
add rn
mirnawong1 Oct 30, 2024
00ceba8
Update website/docs/docs/deploy/job-commands.md
mirnawong1 Nov 4, 2024
ccbef51
Update website/docs/docs/dbt-versions/release-notes.md
mirnawong1 Nov 4, 2024
bbb849c
Merge branch 'current' into custom-commands
mirnawong1 Nov 4, 2024
bb4dd65
add more context
mirnawong1 Nov 4, 2024
6c42ac6
Merge branch 'custom-commands' of github.com:dbt-labs/docs.getdbt.com…
mirnawong1 Nov 4, 2024
4acdd94
Merge branch 'current' into custom-commands
mirnawong1 Nov 4, 2024
e0677f5
Merge branch 'current' into custom-commands
mirnawong1 Nov 4, 2024
1b7347e
Merge branch 'current' into custom-commands
mirnawong1 Nov 4, 2024
17e974a
Update job-commands.md
mirnawong1 Nov 5, 2024
bb435ae
Merge branch 'current' into custom-commands
mirnawong1 Nov 5, 2024
87429f3
add img
mirnawong1 Nov 5, 2024
343cf10
add link
mirnawong1 Nov 5, 2024
b9bc16e
Merge branch 'current' into custom-commands
mirnawong1 Nov 18, 2024
047257b
Merge branch 'current' into custom-commands
mirnawong1 Nov 19, 2024
4a7775f
Update website/docs/docs/deploy/ci-jobs.md
mirnawong1 Nov 19, 2024
e785c3c
Merge branch 'current' into custom-commands
mirnawong1 Nov 19, 2024
c107a90
Merge branch 'current' into custom-commands
mirnawong1 Nov 20, 2024
7258c4e
Update website/docs/docs/dbt-versions/release-notes.md
mirnawong1 Nov 20, 2024
3cfc130
Merge branch 'current' into custom-commands
mirnawong1 Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions website/docs/docs/dbt-versions/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Release notes are grouped by month for both multi-tenant and virtual private clo

\* The official release date for this new format of release notes is May 15th, 2024. Historical release notes for prior dates may not reflect all available features released earlier this year or their tenancy availability.

## November 2024

- **Enhancement**: For users that have Advanced CI's [compare changes](/docs/deploy/advanced-ci#compare-changes) feature enabled, you can optimize performance when running comparisons by using custom dbt syntax to exclude specific large models (or groups of models with tags). Refer to [Compare changes custom commands](/docs/deploy/job-commands#compare-changes-custom-commands) for examples of how to customize the comparison command.
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

## October 2024
<Expandable alt_header="Coalesce 2024 announcements">

Expand Down
1 change: 1 addition & 0 deletions website/docs/docs/deploy/advanced-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Advanced CI"
id: "advanced-ci"
sidebar_label: "Advanced CI"
description: "Advanced CI enables developers to compare changes by demonstrating the changes the code produces."
image: /img/docs/dbt-cloud/example-ci-compare-changes-tab.png
---

# Advanced CI <Lifecycle status="enterprise"/>
Expand Down
14 changes: 9 additions & 5 deletions website/docs/docs/deploy/ci-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ description: "Learn how to create and set up CI checks to test code changes befo

You can set up [continuous integration](/docs/deploy/continuous-integration) (CI) jobs to run when someone opens a new pull request (PR) in your dbt Git repository. By running and testing only _modified_ models, dbt Cloud ensures these jobs are as efficient and resource conscientious as possible on your data platform.

## Set up CI jobs {#set-up-ci-jobs}

dbt Labs recommends that you create your CI job in a dedicated dbt Cloud [deployment environment](/docs/deploy/deploy-environments#create-a-deployment-environment) that's connected to a staging database. Having a separate environment dedicated for CI will provide better isolation between your temporary CI schema builds and your production data builds. Additionally, sometimes teams need their CI jobs to be triggered when a PR is made to a branch other than main. If your team maintains a staging branch as part of your release process, having a separate environment will allow you to set a [custom branch](/faqs/Environments/custom-branch-settings) and, accordingly, the CI job in that dedicated environment will be triggered only when PRs are made to the specified custom branch. To learn more, refer to [Get started with CI tests](/guides/set-up-ci).

### Prerequisites
## Prerequisites
- You have a dbt Cloud account.
- CI features:
- For both the [concurrent CI checks](/docs/deploy/continuous-integration#concurrent-ci-checks) and [smart cancellation of stale builds](/docs/deploy/continuous-integration#smart-cancellation) features, your dbt Cloud account must be on the [Team or Enterprise plan](https://www.getdbt.com/pricing/).
Expand All @@ -20,6 +16,9 @@ dbt Labs recommends that you create your CI job in a dedicated dbt Cloud [deploy
- Set up a [connection with your Git provider](/docs/cloud/git/git-configuration-in-dbt-cloud). This integration lets dbt Cloud run jobs on your behalf for job triggering.
- If you're using a native [GitLab](/docs/cloud/git/connect-gitlab) integration, you need a paid or self-hosted account that includes support for GitLab webhooks and [project access tokens](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html). If you're using GitLab Free, merge requests will trigger CI jobs but CI job status updates (success or failure of the job) will not be reported back to GitLab.

## Set up CI jobs {#set-up-ci-jobs}

dbt Labs recommends that you create your CI job in a dedicated dbt Cloud [deployment environment](/docs/deploy/deploy-environments#create-a-deployment-environment) that's connected to a staging database. Having a separate environment dedicated for CI will provide better isolation between your temporary CI schema builds and your production data builds. Additionally, sometimes teams need their CI jobs to be triggered when a PR is made to a branch other than main. If your team maintains a staging branch as part of your release process, having a separate environment will allow you to set a [custom branch](/faqs/Environments/custom-branch-settings) and, accordingly, the CI job in that dedicated environment will be triggered only when PRs are made to the specified custom branch. To learn more, refer to [Get started with CI tests](/guides/set-up-ci).

To make CI job creation easier, many options on the **CI job** page are set to default values that dbt Labs recommends that you use. If you don't want to use the defaults, you can change them.

Expand All @@ -40,6 +39,11 @@ To make CI job creation easier, many options on the **CI job** page are set to d
- **dbt compare**<Lifecycle status="enterprise" /> &mdash; Enable this option to compare the last applied state of the production environment (if one exists) with the latest changes from the pull request, and identify what those differences are. To enable record-level comparison and primary key analysis, you must add a [primary key constraint](/reference/resource-properties/constraints) or [uniqueness test](/reference/resource-properties/data-tests#unique). Otherwise, you'll receive a "Primary key missing" error message in dbt Cloud.

To review the comparison report, navigate to the [Compare tab](/docs/deploy/run-visibility#compare-tab) in the job run's details. A summary of the report is also available from the pull request in your Git provider (see the [CI report example](#example-ci-report)).

:::info Optimization tip
When you enable the **dbt compare** checkbox, you can customize the comparison command to optimize your CI job. For example, if you have large models that take a long time to compare, you can exclude them to speed up the process using the [`--exclude` flag](/reference/node-selection/exclude). Use [custom commands](/docs/deploy/job-commands#compare-changes-custom-commands) to modify the selection criteria.
:::
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

- **Compare changes against an environment (Deferral)** &mdash; By default, it’s set to the **Production** environment if you created one. This option allows dbt Cloud to check the state of the code in the PR against the code running in the deferred environment, so as to only check the modified code, instead of building the full table or the entire DAG.

:::info
Expand Down
26 changes: 23 additions & 3 deletions website/docs/docs/deploy/job-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,34 @@ For every job, you have the option to select the [Generate docs on run](/docs/co

You can add or remove as many dbt commands as necessary for every job. However, you need to have at least one dbt command. There are few commands listed as "dbt Cloud CLI" or "dbt Core" in the [dbt Command reference page](/reference/dbt-commands) page. This means they are meant for use in dbt Core or dbt Cloud CLI, and not in dbt Cloud IDE.


:::tip Using selectors

Use [selectors](/reference/node-selection/syntax) as a powerful way to select and execute portions of your project in a job run. For example, to run tests for one_specific_model, use the selector: `dbt test --select one_specific_model`. The job will still run if a selector doesn't match any models.
Use [selectors](/reference/node-selection/syntax) as a powerful way to select and execute portions of your project in a job run. For example, to run tests for one _specific_ model, use the selector: `dbt test --select one_specific_model`. The job will still run if a selector doesn't match any models.
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

:::

**Job outcome** &mdash; During a job run, the commands are "chained" together and executed as run steps. If one of the run steps in the chain fails, then the subsequent steps aren't executed, and the job will fail.
#### Compare changes custom commands

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this would be a good place to add a screenshot. We should have one available from the product next week once eng has it built.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will ask @mikaylacrawford for screenshot nxt week

For users that have Advanced CI's [compare changes](/docs/deploy/advanced-ci#compare-changes) feature enabled, you can use a custom dbt syntax to exclude specific large models (or groups of models with tags) to optimize running the comparison. Running comparisons on large models can significantly increase the time it takes for CI jobs to complete.

The following examples highlight how you can customize the comparison command:

- Exclude the large `fct_orders` model from the comparison to run a CI job on fewer or smaller models and reduce job time/resource consumption. Use the following command:

```sql
--select state:modified --exclude fct_orders
```
- Exclude models based on tags for scenarios like when models share a common feature or function. Use the following command:

```sql
--select state modified --exclude tag:tagname_a tag:tagname_b
```
- Include models that were directly modified and also those one step downstream using the `modified+1` selector. Use the following command:
```sql
--select state:modified+1
```

#### Job outcome
During a job run, the commands are "chained" together and executed as run steps. If one of the run steps in the chain fails, then the subsequent steps aren't executed, and the job will fail.

In the following example image, the first four run steps are successful. However, if the fifth run step (`dbt run --select state:modified+ --full-refresh --fail-fast`) fails, then the next run steps aren't executed, and the entire job fails. The failed job returns a non-zero [exit code](/reference/exit-codes) and "Error" job status:

Expand Down
Loading