Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update testing structure for dbt Labs testing support - postgres #33

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci_dbt_test_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# **what?**
# Run tests for dbt-snowflake-query-tags against supported adapters

# **why?**
# To ensure that dbt-snowflake-query-tags works as expected with all supported adapters

# **when?**
# On every PR, and every push to main and when manually triggered

name: Package Integration Tests

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
run-tests:
uses: dbt-labs/dbt-package-testing/.github/workflows/run_tox.yml@v1
with:
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_TEST_USER }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_TEST_ROLE }}
SNOWFLAKE_DATABASE: ${{ secrets.SNOWFLAKE_TEST_DATABASE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_TEST_WAREHOUSE }}
SNOWFLAKE_SCHEMA: "integration_tests_snowflake_${{ github.run_number }}"
secrets:
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_TEST_ACCOUNT }}
DBT_ENV_SECRET_SNOWFLAKE_PASS: ${{ secrets.SNOWFLAKE_TEST_PASSWORD }}
15 changes: 8 additions & 7 deletions .github/workflows/ci_test_package.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NiallRees the CI is failing because I updated the testing folder to be located somewhere else. But the workflow itself is triggered off pull_request_target. That means the workflow code is running what exists on main - the version looking for profiles in integration_test_project even though the profiles file is now located in intgeration_tests.

We can do this iteratively where the testing folder is duplicated then another PR follows to remove the duplicated code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll merge this if you’re confident, then want to open another dummy change PR to validate? I think we might actually need to fix some tests ourselves too

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ on:

env:
# These are configured in GitHub secrets
DBT_PROFILES_DIR: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/integration_test_project
DBT_PROFILES_DIR: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/integration_tests
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_SNOWFLAKE_TEST_ACCOUNT: ${{ secrets.SNOWFLAKE_TEST_ACCOUNT }}
DBT_ENV_SECRET_SNOWFLAKE_TEST_USER: ${{ secrets.SNOWFLAKE_TEST_USER }}
DBT_ENV_SECRET_SNOWFLAKE_TEST_PASSWORD: ${{ secrets.SNOWFLAKE_TEST_PASSWORD }}
DBT_ENV_SECRET_SNOWFLAKE_TEST_ROLE: ${{ secrets.SNOWFLAKE_TEST_ROLE }}
DBT_ENV_SECRET_SNOWFLAKE_TEST_DATABASE: ${{ secrets.SNOWFLAKE_TEST_DATABASE }}
DBT_ENV_SECRET_SNOWFLAKE_TEST_WAREHOUSE: ${{ secrets.SNOWFLAKE_TEST_WAREHOUSE }}
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_TEST_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_TEST_USER }}
DBT_ENV_SECRET_SNOWFLAKE_PASS: ${{ secrets.SNOWFLAKE_TEST_PASSWORD }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_TEST_ROLE }}
SNOWFLAKE_DATABASE: ${{ secrets.SNOWFLAKE_TEST_DATABASE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_TEST_WAREHOUSE }}
SNOWFLAKE_SCHEMA: "integration_tests_snowflake_${{ github.run_number }}"


jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main_test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
# These are configured in GitHub secrets
DBT_PROFILES_DIR: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/integration_test_project
DBT_PROFILES_DIR: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/integration_tests
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_SNOWFLAKE_TEST_ACCOUNT: ${{ secrets.SNOWFLAKE_TEST_ACCOUNT }}
DBT_ENV_SECRET_SNOWFLAKE_TEST_USER: ${{ secrets.SNOWFLAKE_TEST_USER }}
Expand Down
20 changes: 0 additions & 20 deletions integration_test_project/profiles.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'dbt_snowflake_query_tags_tests'
version: '1.0.0'
config-version: 2

profile: dbt_snowflake_query_tags_tests
profile: integration_tests


dispatch:
Expand Down
File renamed without changes.
31 changes: 31 additions & 0 deletions integration_tests/profiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# HEY! This file is used in the dbt-snowflake-query-tags integrations tests with GitHub Actions.
# You should __NEVER__ check credentials into version control. Thanks for reading :)

config:
send_anonymous_usage_stats: False
use_colors: True

integration_tests:
target: snowflake
outputs:
snowflake:
# type: snowflake
# account: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_TEST_ACCOUNT') }}"
# user: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_TEST_USER') }}"
# password: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_TEST_PASSWORD') }}"
# role: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_TEST_ROLE') }}"
# database: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_TEST_DATABASE') }}"
# warehouse: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_TEST_WAREHOUSE') }}"
# schema: dbt_snowflake_query_tags_test_commit_{{ env_var('GITHUB_SHA_OVERRIDE', '') if env_var('GITHUB_SHA_OVERRIDE', '') else env_var('GITHUB_SHA') }}
# threads: 8

snowflake:
type: "snowflake"
account: "{{ env_var('SNOWFLAKE_ACCOUNT') }}"
user: "{{ env_var('SNOWFLAKE_USER') }}"
password: "{{ env_var('DBT_ENV_SECRET_SNOWFLAKE_PASS') }}"
role: "{{ env_var('SNOWFLAKE_ROLE') }}"
database: "{{ env_var('SNOWFLAKE_DATABASE') }}"
warehouse: "{{ env_var('SNOWFLAKE_WAREHOUSE') }}"
schema: "{{ env_var('SNOWFLAKE_SCHEMA') }}"
threads: 10
1 change: 1 addition & 0 deletions supported_adapters.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUPPORTED_ADAPTERS=snowflake
27 changes: 20 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@ passenv =
DBT_PROFILES_DIR
GITHUB_SHA
GITHUB_SHA_OVERRIDE
DBT_ENV_SECRET_SNOWFLAKE_TEST_ACCOUNT
DBT_ENV_SECRET_SNOWFLAKE_TEST_USER
DBT_ENV_SECRET_SNOWFLAKE_TEST_PASSWORD
DBT_ENV_SECRET_SNOWFLAKE_TEST_ROLE
DBT_ENV_SECRET_SNOWFLAKE_TEST_DATABASE
DBT_ENV_SECRET_SNOWFLAKE_TEST_WAREHOUSE
SNOWFLAKE_ACCOUNT
SNOWFLAKE_USER
DBT_ENV_SECRET_SNOWFLAKE_PASS
SNOWFLAKE_ROLE
SNOWFLAKE_DATABASE
SNOWFLAKE_WAREHOUSE
SNOWFLAKE_SCHEMA

[testenv:snowflake]
changedir = integration_test_project
changedir = integration_tests
deps = dbt-snowflake~=1.5.0
commands =
dbt deps
dbt build --full-refresh
dbt build

# Snowflake integration tests for centralized dbt testing
# run dbt commands directly, assumes dbt is already installed in environment
[testenv:dbt_integration_snowflake]
changedir = integration_tests
allowlist_externals =
dbt
skip_install = true
commands =
dbt deps
dbt build --full-refresh --no-version-check
dbt build --no-version-check