Run checks against DBT Models
ActionsTags
(2)Description:
This github action is intended for comparing models
that have changed in an open PR.
Overview of process:
- Fetches modified files by CURLing
github.api.com/repos/{organization}/{repository}/pulls/{pull_request_id}/files
- Filters on files matching
models/*.sql
(call theserelevant_files
) - Runs
dbt deps; dbt compile
to buildmanifest.json
- Parses
manifest.json
and fetchesrelevant_models
with manifest-attributeoriginal_file_path
inrelevant_files
- Loops over
models
- Runs all SQL files in
helpers/sql_checks
for each of therelevant_models
(comparingdev vs prod
via (dev_prefixand
prod_prefix`) - Saves output to file, in pretty format for github comment
- Leverages
py-github-helper
to post comment on open PR
- Runs all SQL files in
Github Actions Input Arguments:
Look at this working example, if you are unfamiliar with Github Actions Inputs
. Inputs
are used to configure Github Actions, and can be thought of as parameters/config, so the action knows what to do.
How inputs are used:
GCP_TOKEN
-> for connecting to BQ- runs
dbt compile
andhelpers/sql_checks
to compare tables
- runs
GH_TOKEN
-> for connecting to Github- fetches modified
models/*.sql
in your PR - adds comment on your PR
- fetches modified
PR_NUMBER
-> for fetching open PR from github (the PR your running this action against)GH_REPO
-> for fetching open PR from github (the PR your running this action against)GH_ORG
-> for fetching open PR from github (the PR your running this action against)dev_prefix
-> the prefix used when running dbt locally (aka your dev environment)prod_prefix
-> the prefix used when running dbt remotely (aka your prod environment)fallback_prefix
-> if you have a customgenerate_schema_name
, where you have a different prefix for some models in prod, you can set this field to that prefixproject_id
-> for connecting to BQ (the BQ project id)DBT_PROFILE_FILE
-> the local path in your repo to yourprofile.yml
for dbt- this is necessary for compiling
manifest.json
during setup process
- this is necessary for compiling
ignored_schemas
-> comma separated string of schemas to ignore (skip checking during github action)irregular_schemas
-> comma separated string of schemas which usefallback_prefix
(described above)
Quick Start: A bare-bones example can be found here.
Run checks against DBT Models is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.