Skip to content

Add environment variables to CI workflow #273

Add environment variables to CI workflow

Add environment variables to CI workflow #273

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
GA4_CONVERSION_EVENTS: ${{ vars.GA4_CONVERSION_EVENTS }}
GA4_DERIVED_SESSION_PROPERTIES: ${{ vars.GA4_DERIVED_SESSION_PROPERTIES }}
GA4_DERIVED_USER_PROPERTIES: ${{ vars.GA4_DERIVED_USER_PROPERTIES }}
GA4_INCREMENTAL_DAYS: ${{ vars.GA4_INCREMENTAL_DAYS }}
GA4_START_DATE: ${{ vars.GA4_START_DATE }}
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: Materialize necessary dbt resources
run: |
dbt seed -f
dbt run -s +test_type:unit -f --empty
- name: Run dbt unit tests
run: dbt test -s test_type:unit