-
Notifications
You must be signed in to change notification settings - Fork 42
144 lines (123 loc) · 5.14 KB
/
run-db-tests.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Run package tests for all dbs
on: [push, delete]
env:
DBT_PROFILES_DIR: ${{ github.workspace }}/
SNOWFLAKE_RE_DATA_TESTING_ACCOUNT: ${{ secrets.SNOWFLAKE_RE_DATA_TESTING_ACCOUNT }}
RE_DATA_TESTING_USER: ${{ secrets.RE_DATA_TESTING_USER }}
RE_DATA_TESTING_PASSWORD: ${{ secrets.RE_DATA_TESTING_PASSWORD }}
REDSHIFT_RE_DATA_TESTING_HOST: ${{ secrets.REDSHIFT_RE_DATA_TESTING_HOST }}
BIGQUERY_TESTING_TYPE: ${{ secrets.BIGQUERY_TESTING_TYPE }}
BIGQUERY_TESTING_PROJECT_ID: ${{ secrets.BIGQUERY_TESTING_PROJECT_ID }}
BIGQUERY_TESTING_PRIVATE_KEY_ID: ${{ secrets.BIGQUERY_TESTING_PRIVATE_KEY_ID }}
BIGQUERY_TESTING_PRIVATE_KEY: ${{ secrets.BIGQUERY_TESTING_PRIVATE_KEY }}
BIGQUERY_TESTING_CLIENT_EMAIL: ${{ secrets.BIGQUERY_TESTING_CLIENT_EMAIL }}
BIGQUERY_TESTING_CLIENT_ID: ${{ secrets.BIGQUERY_TESTING_CLIENT_ID }}
BIGQUERY_TESTING_AUTH_URI: ${{ secrets.BIGQUERY_TESTING_AUTH_URI }}
BIGQUERY_TESTING_TOKEN_URI: ${{ secrets.BIGQUERY_TESTING_TOKEN_URI }}
BIGQUERY_TESTING_AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.BIGQUERY_TESTING_AUTH_PROVIDER_X509_CERT_URL }}
BIGQUERY_TESTING_CLIENT_X509_CERT_URL: ${{ secrets.BIGQUERY_TESTING_CLIENT_X509_CERT_URL }}
DBT_VERSION: 1.7
PYTHON_VERSION: "3.8.x"
jobs:
test-postgres:
runs-on: ubuntu-latest
if: github.event_name == 'push'
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- name: Check out
uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
working-directory: ./integration_tests
run: |
pip install -r requirements.txt
pip install dbt-postgres==$DBT_VERSION
dbt deps
- name: Test DB
working-directory: ./integration_tests/python_tests
run: pytest --db postgres --source_schema dq
test-other-dbs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 're-data/dbt-re-data' && github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
database: [snowflake, bigquery, redshift]
steps:
- name: Check out
uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Set the DQ_SCHEMA environment variable
shell: bash
run: |
echo "DQ_SCHEMA=dq_${GITHUB_REF_SLUG//[^[:alnum:]]/_}" >> $GITHUB_ENV
- name: Print DQ_SCHEMA
run: |
echo $DQ_SCHEMA
- name: Install dependencies
working-directory: ./integration_tests
run: |
pip install -r requirements.txt
pip install dbt-${{ matrix.database }}==$DBT_VERSION
dbt deps
- name: Drop schemas
working-directory: ./integration_tests
run: |
dbt run-operation drop_all_schemas --args "{ schema_name: ${{ env.DQ_SCHEMA }} }" --profile re_data_${{ matrix.database }} --vars "{ source_schema: ${{ env.DQ_SCHEMA }} }"
- name: Create Schemas if needed
if: matrix.database == 'redshift'
working-directory: ./integration_tests
run: |
dbt run-operation create_required_schemas --args "{ schema_name: ${{ env.DQ_SCHEMA }} }" --profile re_data_${{ matrix.database }} --vars "{ source_schema: ${{ env.DQ_SCHEMA }} }"
- name: Test DB
working-directory: ./integration_tests/python_tests
run: |
pytest --db ${{ matrix.database }} --source_schema ${{ env.DQ_SCHEMA }}
clean-up-schemas:
runs-on: ubuntu-latest
if: github.event_name == 'delete' && github.repository == 're-data/dbt-re-data' && github.ref == 'refs/heads/main'
strategy:
fail-fast: false
matrix:
database: [snowflake, bigquery, redshift]
steps:
- name: Check out
uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Set the DQ_SCHEMA environment variable
shell: bash
run: |
echo "DQ_SCHEMA=dq_${GITHUB_EVENT_REF_SLUG//[^[:alnum:]]/_}" >> $GITHUB_ENV
- name: Print DQ_SCHEMA
run: |
echo $DQ_SCHEMA
- name: Install dependencies and drop branch schema
working-directory: ./integration_tests
run: |
pip install -r requirements.txt
pip install dbt-${{ matrix.database }}==$DBT_VERSION
dbt deps
dbt run-operation drop_all_schemas --args "{ schema_name: ${{ env.DQ_SCHEMA }} }" --profile re_data_${{ matrix.database }} --vars "{ source_schema: ${{ env.DQ_SCHEMA }} }"