Skip to content

Commit 4cb4132

Browse files
authored
Feature/add titan (#251) (#252)
* Feature/add titan (#251) * Titan role updates * Add role grants. * update roles for covid and snowflake dbs * grant transformer access to additional warehouses and dbs * update roles and grant permissions macro * make quoting consistent * fix role name in dbt macro * fix macro and script to get artifacts to not fail on first run and add stage permissions * change workflow 20 to only run on PR to main * include seeds when running dynamic models for the first time * account for not having catalog.json on the first run * update model for country geo due to source schema change * fix linting issue --------- Co-authored-by: Noel Gomez Co-authored-by: Sebastian Sassi
1 parent c352b48 commit 4cb4132

33 files changed

+544
-33
lines changed

.github/workflows/10_feature_dbt_checks.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ jobs:
9999
run: "../automate/dbt/get_artifacts.sh"
100100

101101
- name: Clone incremental models that are directly or indirectly affected by the change
102+
if: ${{ steps.prod_manifest.outputs.manifest_found == 'true' }}
102103
run: |
103104
dbt clone -s state:modified+,config.materialized:incremental,state:old --state logs
104105
dbt clone -s state:modified+,config.materialized:snapshot,state:old --state logs
@@ -110,9 +111,15 @@ jobs:
110111
- name: Run Observe Model
111112
run: "dbt build --fail-fast -s L1_inlets.observe"
112113

113-
# There is an issue with --empty and dynamic tables so need to exclude them
114+
# There is an issue with --empty and dynamic tables so need to run them by themselves
114115
- name: Governance run of dynamic tables
115-
run: "dbt build --fail-fast -s config.materialized:dynamic_table -s test_failures --defer --state logs"
116+
if: ${{ steps.prod_manifest.outputs.manifest_found == 'false' }}
117+
run: "dbt build --fail-fast -s config.materialized:dynamic_table stg_test_failures resource_type:seed"
118+
119+
# There is an issue with --empty and dynamic tables so need to run them by themselves
120+
- name: Governance run of dynamic tables
121+
if: ${{ steps.prod_manifest.outputs.manifest_found == 'true' }}
122+
run: "dbt build --fail-fast -s config.materialized:dynamic_table stg_test_failures --defer --state logs"
116123

117124
# There is an issue with --empty and dynamic tables so need to exclude them
118125
- name: Governance run of dbt with EMPTY models using slim mode
@@ -125,8 +132,13 @@ jobs:
125132
run: "dbt build --fail-fast --empty --exclude config.materialized:dynamic_table ${{ env.FULL_REFRESH_FLAG }}"
126133

127134
- name: Generate Docs Combining Prod and branch catalog.json
135+
if: ${{ steps.prod_manifest.outputs.catalog_found == 'true' }}
128136
run: "dbt-coves generate docs --merge-deferred --state logs"
129137

138+
- name: Generate dbt Docs
139+
if: ${{ steps.prod_manifest.outputs.catalog_found == 'false' }}
140+
run: "dbt docs generate"
141+
130142
- name: Run governance checks
131143
run: "pre-commit run --from-ref origin/${{ github.event.pull_request.base.ref }} --to-ref HEAD"
132144

.github/workflows/20_release_dbt_checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: "20: 🏎️ dbt Release Branch Validations"
33
on: # yamllint disable-line rule:truthy
44
pull_request:
55
types: [opened, synchronize, labeled, unlabeled]
6-
# No branch restrictions for validate-branch job to run on all PRs
7-
# dbt job will be conditionally run based on target branch
6+
branches:
7+
- main
88
paths:
99
- transform/**/*
1010

@@ -112,7 +112,7 @@ jobs:
112112
run: automate/git/branch_validator.py
113113

114114
dbt:
115-
if: github.base_ref == 'main' && github.event.action != 'unlabeled' && (github.event.action != 'labeled' || github.event.label.name == 'full-refresh')
115+
if: github.event.action != 'unlabeled' && (github.event.action != 'labeled' || github.event.label.name == 'full-refresh')
116116
name: Pull Request dbt Tests
117117
runs-on: ubuntu-latest
118118
needs: [validate-branch]

automate/dbt/get_artifacts.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,57 @@ cd $DATACOVES__DBT_HOME
88
mkdir -p logs
99

1010
dbt run-operation get_last_artifacts
11-
LINES_IN_MANIFEST="$(grep -c '^' logs/manifest.json)"
11+
12+
# Check if manifest.json exists before trying to grep it
13+
if [ -f "logs/manifest.json" ]; then
14+
LINES_IN_MANIFEST="$(grep -c '^' logs/manifest.json)"
15+
else
16+
LINES_IN_MANIFEST=0
17+
fi
1218

1319
if [ $LINES_IN_MANIFEST -eq 0 ]
1420
then
15-
echo "Manifest not found in Snowflake stage, contact the Snowflake administrator to load a updated manifest to snowflake."
21+
echo "Manifest not found in Snowflake stage, contact the Snowflake administrator to load a updated manifest.json to snowflake."
1622
# This is used by github actions
17-
echo "manifest_found=false" >> $GITHUB_OUTPUT
23+
if [ -n "$GITHUB_OUTPUT" ]; then
24+
echo "manifest_found=false" >> $GITHUB_OUTPUT
25+
fi
1826

1927
# This is used by Jenkins
2028
# echo "false" > temp_MANIFEST_FOUND.txt
2129
else
2230
echo "Updated manifest from production"
2331

2432
# This is used by github actions
25-
echo "manifest_found=true" >> $GITHUB_OUTPUT
33+
if [ -n "$GITHUB_OUTPUT" ]; then
34+
echo "manifest_found=true" >> $GITHUB_OUTPUT
35+
fi
2636

2737
# This is used by Jenkins
2838
# echo "true" > temp_MANIFEST_FOUND.txt
2939
fi
40+
41+
42+
# Check if catalog.json exists before trying to grep it
43+
if [ -f "logs/catalog.json" ]; then
44+
LINES_IN_CATALOG="$(grep -c '^' logs/catalog.json)"
45+
else
46+
LINES_IN_CATALOG=0
47+
fi
48+
49+
50+
if [ $LINES_IN_CATALOG -eq 0 ]
51+
then
52+
echo "Catalog not found in Snowflake stage, contact the Snowflake administrator to load a updated catalog.json to snowflake."
53+
# This is used by github actions
54+
if [ -n "$GITHUB_OUTPUT" ]; then
55+
echo "catalog_found=false" >> $GITHUB_OUTPUT
56+
fi
57+
else
58+
echo "Updated catalog from production"
59+
60+
# This is used by github actions
61+
if [ -n "$GITHUB_OUTPUT" ]; then
62+
echo "catalog_found=true" >> $GITHUB_OUTPUT
63+
fi
64+
fi
File renamed without changes.

0 commit comments

Comments
 (0)