-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
94 lines (91 loc) · 3.54 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: 'Run checks against DBT Models'
description: 'Compares columns and rows in BigQuery.'
inputs:
GCP_TOKEN:
description: 'The GCP Key used to connect to BQ'
required: true
default: 'abcd'
GH_TOKEN:
description: 'The PAT to Comment on PRs'
required: true
default: '1234'
PR_NUMBER:
description: 'The PR to Comment on'
required: true
default: '${{ github.event.number }}'
GH_REPO:
description: 'The Github Repository'
required: true
default: '${{ github.repository }}'
GH_ORG:
description: 'The Github Repository Owner'
required: true
default: '${{ github.repository_owner }}'
WORK_DIR:
description: "The fullpath to dbt workspace"
required: true
default: '${{ github.workspace }}'
DBT_PROFILE_FILE:
description: 'The fullpath to dbt profile (needs to exist in repo)'
required: true
default: "helpers/profiles.yml"
project_id:
description: 'The BigQuery Project ID'
required: true
default: "my-bq-project"
dev_prefix:
description: 'The schema prefix used by dbt on dev datasets'
required: true
default: "dev_"
prod_prefix:
description: 'The schema prefix used by dbt on prod datasets'
required: true
default: "prod_"
fallback_prefix:
description: 'An alternative schema prefix used by a select few prod datasets'
required: true
default: ""
ignored_schemas:
description: 'Schemas which do not have a prod counterpart (ignored)'
required: true
default: "legacy,ignored"
irregular_schemas:
description: 'The schemas which leverage fallback prefix'
required: true
default: "scratch,test"
custom_checks_path:
description: 'A local folder containing any custom SQL to run.'
required: false
default: ""
runs:
using: "composite"
steps:
- name: Checkout Repo
uses: actions/[email protected]
- name: Run Table Checks
shell: bash
run: |
# Setup & run DBT compile
echo "Initializing environment..."
mkdir -p ~/.dbt
mkdir -p secrets
cp ${{ inputs.DBT_PROFILE_FILE }} ~/.dbt/profiles.yml
bq_keyfile="secrets/bq_keyfile.json"
echo ${{ inputs.GCP_TOKEN }} > $bq_keyfile
export GOOGLE_APPLICATION_CREDENTIALS=$bq_keyfile
custom_checks_path="$(pwd)/${{ inputs.custom_checks_path }}"
# Compiling DBT environment
echo "Running dbt deps and dbt compile..."
source setup.sh ${{ inputs.WORK_DIR }}
manifest_file="$(pwd)/target/manifest.json"
# CD to the Github Action's workspace
cd /home/runner/work/_actions/org-not-included/dbt_table_diff/v2.2.3
mkdir -p secrets
gh_keyfile="secrets/gh_keyfile.json"
echo -n "${{ inputs.GH_TOKEN }}" > $gh_keyfile
bq_keyfile="secrets/bq_keyfile.json"
echo ${{ inputs.GCP_TOKEN }} > $bq_keyfile
pip3 install -Ir local-requirements.txt
# Run Checks on Modified Files and Add Github Comment
echo "Github Details: ${{ inputs.GH_ORG }}/${{ inputs.GH_REPO }} (PR# ${{ inputs.PR_NUMBER }})..."
python3 dbt_table_diff/run_sql_checks.py -t ${{ inputs.GH_TOKEN }} -o ${{ inputs.GH_ORG }} -r ${{ inputs.GH_REPO }} -l ${{ inputs.PR_NUMBER }} --manifest_file $manifest_file --project_id ${{ inputs.project_id }} --keyfile_path $bq_keyfile --ignored_schemas ${{ inputs.ignored_schemas }} --irregular_schemas ${{ inputs.irregular_schemas }} --dev_prefix ${{ inputs.dev_prefix }} --prod_prefix ${{ inputs.prod_prefix }} --fallback_prefix ${{ inputs.fallback_prefix }} --custom_checks_path $custom_checks_path