-
Notifications
You must be signed in to change notification settings - Fork 135
72 lines (61 loc) · 1.83 KB
/
run_unit_tests_on_pr.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
name: Run Unit Tests on Pull Request
# on: [pull_request_target,workflow_dispatch]
on:
push:
branches:
- 'feature/add_dbt_unit_tests'
env:
BIGQUERY_PROJECT: ${{ secrets.BIGQUERY_PROJECT }}
BIGQUERY_PROPERTY_ID: ${{ secrets.BIGQUERY_PROPERTY_ID }}
BIGQUERY_DATASET: ${{ secrets.BIGQUERY_DATASET }}
BIGQUERY_KEYFILE: ./unit_tests/dbt-service-account.json
jobs:
pytest_run_all:
name: Pytest Run All
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./unit_tests
steps:
- name: Check out
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v1
with:
python-version: "3.11.x"
- name: Authenticate using service account
run: 'echo "$KEYFILE" > ./dbt-service-account.json'
shell: bash
env:
KEYFILE: ${{secrets.GCP_BIGQUERY_USER_KEYFILE}}
- name: Install dependencies
run: |
pip install dbt-core
pip install dbt-bigquery
pip install pytest
- name: Run tests
run: python -m pytest .
run_dbt_unit_tests:
name: Run dbt Unit Tests
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v1
with:
python-version: "3.11.x"
- name: Authenticate using service account
run: 'echo "$KEYFILE" > ./unit_tests/dbt-service-account.json'
shell: bash
env:
KEYFILE: ${{ secrets.GCP_BIGQUERY_USER_KEYFILE }}
- name: Install dbt
run: |
pip install dbt-core
pip install dbt-bigquery
dbt deps
- name: Run dbt unit tests
run: dbt test -s test_type:unit