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

Add tox-based Integration Testing Support #111

Merged
merged 9 commits into from
Oct 15, 2024
Merged
Changes from 8 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
20 changes: 11 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -10,8 +10,12 @@ jobs:
username: dbt-labs
password: ''
environment:
POSTGRES_HOST: localhost
POSTGRES_USER: root
POSTGRES_DB: circle_test
POSTGRES_PORT: 5432
POSTGRES_DATABASE: circle_test
POSTGRES_SCHEMA: dbt_utils_integration_tests_postgres
DBT_ENV_SECRET_POSTGRES_PASS: ''

steps:
- checkout
@@ -35,17 +39,15 @@ jobs:
python -m pip install --upgrade pip setuptools
python -m pip install --pre dbt-core dbt-postgres dbt-redshift dbt-snowflake dbt-bigquery dbt-databricks

mkdir -p ~/.dbt
cp integration_tests/ci/sample.profiles.yml ~/.dbt/profiles.yml

- run:
name: "Run Tests - Postgres"
environment:
POSTGRES_TEST_HOST: localhost
POSTGRES_TEST_USER: root
POSTGRES_TEST_PASS: ''
POSTGRES_TEST_PORT: 5432
POSTGRES_TEST_DBNAME: circle_test
POSTGRES_HOST: localhost
POSTGRES_USER: root
POSTGRES_PORT: 5432
POSTGRES_DATABASE: circle_test
POSTGRES_SCHEMA: dbt_utils_integration_tests_postgres
DBT_ENV_SECRET_POSTGRES_PASS: ''
command: |
. dbt_venv/bin/activate
cd integration_tests
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# **what?**
# Run tests for dbt-codegen against supported adapters

# **why?**
# To ensure that dbt-codegen 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
# this just tests with postgres so no variables need to be passed through.
# When it's time to add more adapters you will need to pass through inputs for
# the other adapters as shown in the below example for redshift
# with:
# # redshift
# REDSHIFT_HOST: ${{ vars.REDSHIFT_HOST }}
# REDSHIFT_USER: ${{ vars.REDSHIFT_USER }}
# REDSHIFT_DATABASE: ${{ vars.REDSHIFT_DATABASE }}
# REDSHIFT_SCHEMA: "integration_tests_redshift_${{ github.run_number }}"
# REDSHIFT_PORT: ${{ vars.REDSHIFT_PORT }}
# secrets:
# DBT_ENV_SECRET_REDSHIFT_PASS: ${{ secrets.DBT_ENV_SECRET_REDSHIFT_PASS }}
emmyoop marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions integration_tests/.env/postgres.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POSTGRES_HOST=localhost
POSTGRES_USER=root
DBT_ENV_SECRET_POSTGRES_PASS=password
POSTGRES_PORT=5432
POSTGRES_DATABASE=audit_helper_test
POSTGRES_SCHEMA=audit_helper_integration_tests_postgres
emmyoop marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@

# HEY! This file is used in the dbt-audit-helper integrations tests with CircleCI.
# You should __NEVER__ check credentials into version control. Thanks for reading :)

integration_tests:
target: postgres
outputs:
postgres:
type: postgres
host: "{{ env_var('POSTGRES_TEST_HOST') }}"
user: "{{ env_var('POSTGRES_TEST_USER') }}"
pass: "{{ env_var('POSTGRES_TEST_PASS') }}"
port: "{{ env_var('POSTGRES_TEST_PORT') | as_number }}"
dbname: "{{ env_var('POSTGRES_TEST_DBNAME') }}"
schema: audit_helper_integration_tests_postgres
threads: 1
type: "postgres"
host: "{{ env_var('POSTGRES_HOST') }}"
user: "{{ env_var('POSTGRES_USER') }}"
pass: "{{ env_var('DBT_ENV_SECRET_POSTGRES_PASS') }}"
port: "{{ env_var('POSTGRES_PORT') | as_number }}"
dbname: "{{ env_var('POSTGRES_DATABASE') }}"
schema: "{{ env_var('POSTGRES_SCHEMA') }}"
threads: 5

redshift:
type: redshift
@@ -51,3 +47,4 @@ integration_tests:
http_path: "{{ env_var('DATABRICKS_TEST_HTTP_PATH') }}"
token: "{{ env_var('DATABRICKS_TEST_ACCESS_TOKEN') }}"
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=postgres
emmyoop marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tox]
skipsdist = True
envlist = lint_all, testenv

[testenv]
passenv =
# postgres env vars
POSTGRES_HOST
POSTGRES_USER
DBT_ENV_SECRET_POSTGRES_PASS
POSTGRES_PORT
POSTGRES_DATABASE
POSTGRES_SCHEMA

# Postgres integration tests for centralized dbt testing
# run dbt commands directly, assumes dbt is already installed in environment
[testenv:dbt_integration_postgres]
changedir = integration_tests
allowlist_externals =
dbt
skip_install = true
commands =
dbt --version
dbt debug --target postgres
emmyoop marked this conversation as resolved.
Show resolved Hide resolved