Skip to content

Commit

Permalink
updated for new dbt based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhopper-dataengineers committed Jul 22, 2024
1 parent 7c43623 commit 9a54f3f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
22 changes: 15 additions & 7 deletions tasks/dbt-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,23 @@ inputs:
description: Whether to archive test results
required: false
default: 'false'
data-tests:
description: Whether to run data tests
required: false
default: 'true'
unit-tests:
description: Whether to run unit tests
required: false
default: 'true'

runs:
using: "composite"
steps:
- name: Run DBT Schema Only Tests
if: inputs.target != 'unit-test'
- name: Run DBT Data Tests
if: ${{ inputs.data-tests == 'true' }}
shell: bash
run: |
dbt test --profiles-dir=${{ inputs.profiles-directory }} --target=${{ inputs.target }} --exclude tag:unit_test
dbt test --select test_type:data --profiles-dir=${{ inputs.profiles-directory }} --target=${{ inputs.target }}
working-directory: ${{ inputs.working-directory }}
env:
snowflake-account: ${{ inputs.snowflake-account }}
Expand All @@ -54,11 +62,11 @@ runs:
snowflake-authenticator-value: ${{ inputs.snowflake-authenticator-value }}
snowflake-private-key-passphrase: ${{ inputs.snowflake-privatekey-passphrase }}

- name: Run DBT Schema Tests and unit-tests
if: inputs.target == 'unit-test'
- name: Run DBT Unit Tests
if: ${{ inputs.unit-tests == 'true' }}
shell: bash
run: |
dbt test --profiles-dir=${{ inputs.profiles-directory }} --target=${{ inputs.target }}
dbt test --select test_type:unit --profiles-dir=${{ inputs.profiles-directory }} --target=${{ inputs.target }}
working-directory: ${{ inputs.working-directory }}
env:
snowflake-account: ${{ inputs.snowflake-account }}
Expand All @@ -74,5 +82,5 @@ runs:
if: ${{ inputs.archive-outputs == 'true' }}
with:
name: dbt-test-results
path:
path:
${{ inputs.working-directory }}/target/run_results.json
26 changes: 16 additions & 10 deletions tasks/dbt-test/devops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ parameters:
- name: archive_outputs
type: boolean
default: false
- name: data_tests
type: boolean
default: true
- name: unit_tests
type: boolean
default: true

steps:

- bash: |
source $DBT_ENV_NAME/bin/activate
dbt test --profiles-dir=${{ parameters.profiles_directory }} --target=${{ parameters.target }} --exclude tag:unit_test
displayName: Run dbt Schema Only Tests
condition: and(succeeded(), ne('${{ parameters.target }}', 'unit-test'))
source $DBT_ENV_NAME/bin/activate
dbt test --select test_type:data --profiles-dir=${{ parameters.profiles_directory }} --target=${{ parameters.target }}
displayName: Run dbt Data Tests
condition: and(succeeded(), ${{ parameters.data_tests }})
workingDirectory: ${{ parameters.working_directory }}
env:
DBT_ENV_NAME: ${{ parameters.env_name }}
Expand All @@ -32,13 +38,13 @@ steps:
snowflake-password: ${{ parameters.snowflake_authenticator_value }}
snowflake-warehouse: $(snowflake-warehouse)
snowflake-role: $(snowflake-role)
snowflake-privatekey-passphrase: $(snowflake-privatekey-password)
snowflake-private-key-password: $(snowflake-private-key-password)
- bash: |
source $DBT_ENV_NAME/bin/activate
dbt test --profiles-dir=${{ parameters.profiles_directory }} --target=${{ parameters.target }}
displayName: Run dbt Schema Tests and unit-tests
condition: and(succeeded(), eq('${{ parameters.target }}', 'unit-test'))
source $DBT_ENV_NAME/bin/activate
dbt test --select test_type:unit --profiles-dir=${{ parameters.profiles_directory }} --target=${{ parameters.target }}
displayName: Run dbt Unit Tests
condition: and(succeeded(), ${{ parameters.unit_tests }})
workingDirectory: ${{ parameters.working_directory }}
env:
DBT_ENV_NAME: ${{ parameters.env_name }}
Expand All @@ -48,7 +54,7 @@ steps:
snowflake-password: ${{ parameters.snowflake_authenticator_value }}
snowflake-warehouse: $(snowflake-warehouse)
snowflake-role: $(snowflake-role)
snowflake-privatekey-passphrase: $(snowflake-privatekey-password)
snowflake-private-key-password: $(snowflake-private-key-password)
- task: PublishPipelineArtifact@1
displayName: Archive dbt test results
Expand Down

0 comments on commit 9a54f3f

Please sign in to comment.