diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e971488 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 + # 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 }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 404fb93..2b68528 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ target/ dbt_packages/ logs/ +env/ .python-version integration_tests/.spark-warehouse integration_tests/.hive-metastore diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..c47a7ad --- /dev/null +++ b/dev-requirements.txt @@ -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 \ No newline at end of file diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index 6d970a4..202663b 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -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 diff --git a/integration_tests/package-lock.yml b/integration_tests/package-lock.yml new file mode 100644 index 0000000..5600369 --- /dev/null +++ b/integration_tests/package-lock.yml @@ -0,0 +1,5 @@ +packages: + - local: ../ + - package: calogica/dbt_date + version: 0.10.1 +sha1_hash: de2deba3d66ce03d8c02949013650cc9b94f6030 diff --git a/integration_tests/profiles.yml b/integration_tests/profiles.yml new file mode 100644 index 0000000..fa1ac8c --- /dev/null +++ b/integration_tests/profiles.yml @@ -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 diff --git a/supported_adapters.env b/supported_adapters.env new file mode 100644 index 0000000..14c965c --- /dev/null +++ b/supported_adapters.env @@ -0,0 +1 @@ +SUPPORTED_ADAPTERS=postgres \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..72f732c --- /dev/null +++ b/tox.ini @@ -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