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

Fix installed DBT versions, move duckdb files to tmp #3

Merged
merged 3 commits into from
Jun 21, 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
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ jobs:
# - run: hatch fmt --check
- run: git fetch origin main
- run: pre-commit run --from-ref origin/main --to-ref HEAD
- run: |
hatch run dbt clean
hatch run dbt seed
hatch run dbt build
- run: hatch test --all
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ pip install hatch
# Configure Hatch to create venvs in project
hatch config set dirs.env.virtual .hatch

# Before testing we need to build DBT project
hatch run dbt clean
hatch run dbt seed
hatch run dbt build

# test in one venv
hatch test
# test accross different python & dbt versions
Expand Down
Binary file removed dev.duckdb
Binary file not shown.
39 changes: 23 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ dependencies = [
[tool.hatch.envs.default]
dependencies = [
"pytest",
"dbt-core~=1.8",
"dbt-duckdb~=1.8"
"dbt-core~=1.8.0",
"dbt-duckdb~=1.8.0"
]

[tool.hatch.envs.default.env-vars]
EXPECTED_PYTHON_VERSION = "3.12"
EXPECTED_DBT_VERSION = "1.8"
DBT_PROJECT_DIR = "tests/my_pumpkin"
DBT_PROFILES_DIR = "tests/my_pumpkin"
# There is an issue with dbt clean when running ouutside project
DBT_CLEAN_PROJECT_FILES_ONLY = "False"

[tool.hatch.envs.hatch-test]
# don't inherit from default
template = "hatch-test"
dependencies = [
"pytest"
"pytest",
"dbt-core~={matrix:dbt}.0",
"dbt-duckdb~={matrix:dbt}.0"
]

[tool.hatch.envs.hatch-test.overrides]
matrix.dbt.dependencies = [
{value = "dbt-core~=1.5", if = ["1.5"]},
{value = "dbt-duckdb~=1.5", if = ["1.5"]},
{value = "dbt-core~=1.6", if = ["1.6"]},
{value = "dbt-duckdb~=1.6", if = ["1.6"]},
{value = "dbt-core~=1.7", if = ["1.7"]},
{value = "dbt-duckdb~=1.7", if = ["1.7"]},
{value = "dbt-core~=1.8", if = ["1.8"]},
{value = "dbt-duckdb~=1.8", if = ["1.8"]}
]
[tool.hatch.envs.hatch-test.env-vars]
EXPECTED_PYTHON_VERSION = "{matrix:python}"
EXPECTED_DBT_VERSION = "{matrix:dbt}"

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.9", "3.10", "3.11"]
Expand All @@ -56,6 +56,13 @@ explicit_start = false
whitelines = 1
sequence_style = "keep_style"

[tool.pytest.ini_options]
filterwarnings = [
"ignore:.*PyType_Spec with a metaclass that has custom tp_new.*:DeprecationWarning",
"ignore:.*datetime.datetime.utcnow\\(\\) is deprecated.*:DeprecationWarning",
"ignore:.*method is deprecated, use 'warning' instead.*:DeprecationWarning"
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
5 changes: 0 additions & 5 deletions pytest.ini

This file was deleted.

15 changes: 0 additions & 15 deletions tests/my_pumpkin/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/my_pumpkin/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ profile: my_pumpkin
clean-targets:
- target
- dbt_packages
- dev.duckdb
- "{{ env_var('TEMP', '/tmp') }}/dev.duckdb"

seeds:
my_pumpkin:
Expand Down
Binary file removed tests/my_pumpkin/dev.duckdb
Binary file not shown.
8 changes: 2 additions & 6 deletions tests/my_pumpkin/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ my_pumpkin:
outputs:
dev:
type: duckdb
path: dev.duckdb
# TEMP env var is defined only on Windows
path: "{{ env_var('TEMP', '/tmp') }}/dev.duckdb"
threads: 1

prod:
type: duckdb
path: prod.duckdb
threads: 4

target: dev
14 changes: 14 additions & 0 deletions tests/test_hatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import sys
import dbt
import dbt.version

def test_expected_python_version():
sys_version = str(sys.version_info.major) + "." + str(sys.version_info.minor)
expected_version = os.environ.get('EXPECTED_PYTHON_VERSION')
assert sys_version == expected_version

def test_expected_dbt_version():
sys_version = dbt.version.get_installed_version().major + "." + dbt.version.get_installed_version().minor
expected_version = os.environ.get('EXPECTED_DBT_VERSION')
assert sys_version == expected_version