-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (71 loc) · 3.11 KB
/
pr_run_models.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
name: Pull Request testing - Run dbt models on BigQuery
on:
pull_request:
paths:
- 'macros/**'
- 'models/**'
- 'integration_tests/**'
- 'dbt_project.yml'
- 'packages.yml'
- 'config.py'
workflow_dispatch:
# GitHub secrets
env:
DBT_PROFILES_DIR: .
GITHUB_SHA_OVERRIDE: ${{ github.event.pull_request.head.sha }} # We need the commit hash of the pull request branch's head, the GITHUB_SHA env var is always the base branch in a pull_request_target trigger
DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT }}
DBT_ENV_SECRET_BIGQUERY_TEST_STORAGE_PROJECT: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_STORAGE_PROJECT }}
DBT_ENV_SECRET_BIGQUERY_TEST_EXECUTION_PROJECT: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_EXECUTION_PROJECT }}
DBT_ENV_SECRET_BIGQUERY_TEST_LOCATION: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_LOCATION }}
DBT_BQ_MONITORING_GCP_PROJECTS: ${{ secrets.DBT_BQ_MONITORING_GCP_PROJECTS }}
concurrency:
cancel-in-progress: true
group: pr-run-models-${{ github.workflow }}-${{ github.ref }}
jobs:
integration-bigquery:
name: Run dbt models on BigQuery to test model validity
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python packages
run: python -m pip install dbt-bigquery~=1.9.1 sqlfluff-templater-dbt
- name: Write keyfile if secret is defined
run: |
if [ -z "${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT }}" ]; then
echo "Error: DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT is not defined."
else
echo ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT }} | base64 -d > ./integration_tests/keyfile.json
fi
- name: Setup dbt dependencies
run: |
cd integration_tests
dbt deps
- name: Setup dbt fixtures
run: |
cd integration_tests
dbt run -s tag:fixtures
- name: Run all models once
run: |
cd integration_tests
dbt build -s dbt_bigquery_monitoring --full-refresh --empty
- name: Run all models again to test incremental
run: |
cd integration_tests
dbt build -s dbt_bigquery_monitoring --empty
- name: Run all models again with cloud audit logs
run: |
cd integration_tests
DBT_BQ_MONITORING_SHOULD_COMBINE_AUDIT_LOGS_AND_INFORMATION_SCHEMA=true DBT_BQ_MONITORING_GCP_BIGQUERY_AUDIT_LOGS=true \
dbt run -s jobs_from_audit_logs+ --full-refresh --empty
- name: Run all models again to test incremental with cloud audit logs
run: |
cd integration_tests
DBT_BQ_MONITORING_SHOULD_COMBINE_AUDIT_LOGS_AND_INFORMATION_SCHEMA=true DBT_BQ_MONITORING_GCP_BIGQUERY_AUDIT_LOGS=true \
dbt run -s jobs_from_audit_logs+ --empty