0
0
dbtdata~20 mins

PR review workflows for dbt changes - Mini Project: Build & Apply

Choose your learning style9 modes available
PR Review Workflows for dbt Changes
📖 Scenario: You work on a data team that uses dbt to manage data transformations. Your team wants to ensure that every change to the dbt project is reviewed carefully before merging. This helps keep the data models accurate and reliable.
🎯 Goal: You will create a simple PR review workflow for dbt changes. This workflow will run dbt commands to check the changes and show the results in the pull request. This helps your team catch errors early and keep the data pipeline healthy.
📋 What You'll Learn
Create a GitHub Actions workflow file named dbt-pr-review.yml
Set the workflow to run on pull requests to the main branch
Add a job that sets up Python and installs dbt
Run dbt compile to check for syntax errors
Run dbt test to run tests on the changed models
Output the results so reviewers can see if the changes pass
💡 Why This Matters
🌍 Real World
Teams use PR review workflows to catch errors in dbt projects before merging changes. This keeps data models accurate and prevents broken pipelines.
💼 Career
Data engineers and analytics engineers often create and maintain CI/CD workflows for dbt to ensure data quality and reliability.
Progress0 / 4 steps
1
Create the workflow file and trigger
Create a file named .github/workflows/dbt-pr-review.yml. Inside it, start a workflow with the name dbt PR Review that triggers on pull requests to the main branch. Write the YAML lines to set this up.
dbt
Need a hint?

Use name: to name the workflow. Use on: pull_request: branches: - main to trigger on PRs to main.

2
Add a job to set up Python and install dbt
Add a job named dbt-check that runs on ubuntu-latest. Inside the job, add steps to check out the code, set up Python 3.12, and install dbt using pip install dbt-core.
dbt
Need a hint?

Use actions/checkout@v3 to get the code. Use actions/setup-python@v4 with python-version: '3.12'. Then run pip install dbt-core.

3
Add steps to run dbt compile and dbt test
Inside the dbt-check job's steps, add two run commands: one to run dbt compile and one to run dbt test. These commands check the syntax and run tests on the dbt models.
dbt
Need a hint?

Add two steps with run: dbt compile and run: dbt test to check your dbt models.

4
Print the workflow summary output
Add a final step in the dbt-check job to print a message dbt PR review completed. Use a run command with echo to display this message in the workflow logs.
dbt
Need a hint?

Use echo "dbt PR review completed" in a run step to print the message.