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 + GHA #319

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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@main
Copy link

Choose a reason for hiding this comment

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

dbt-labs has tagged a commit for this workflow to ensure we don't accidentally break anyone during development.

Suggested change
uses: dbt-labs/dbt-package-testing/.github/workflows/run_tox.yml@main
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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
target/
dbt_packages/
logs/
env/
.python-version
integration_tests/.spark-warehouse
integration_tests/.hive-metastore
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# for convenience - test locally against latest changes in dbt-core + adapters
dbt-core@git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core
dbt-postgres@git+https://github.com/dbt-labs/dbt-postgres.git
tox>=3.13
1 change: 1 addition & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dispatch:
flags:
partial_parse: True
send_anonymous_usage_stats: False
use_colors: True
warn_error_options:
silence: # To silence or ignore dbt 1.8.x upgrade warnings
- TestsConfigDeprecation
Expand Down
5 changes: 5 additions & 0 deletions integration_tests/package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages:
- local: ../
- package: calogica/dbt_date
version: 0.10.1
sha1_hash: de2deba3d66ce03d8c02949013650cc9b94f6030
12 changes: 12 additions & 0 deletions integration_tests/profiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
integration_tests:
outputs:
postgres:
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
target: postgres
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
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 deps --target postgres
dbt build --target postgres