Update dbt CI matrix (#7196)

This commit is contained in:
Danny Jones
2025-10-20 03:02:42 +05:30
committed by GitHub
parent 9b467aff82
commit e2e9202bf2
9 changed files with 16 additions and 80 deletions

View File

@@ -93,24 +93,15 @@ jobs:
fail-fast: false
matrix:
dbt-version:
- dbt140
- dbt150
- dbt160
- dbt170
- dbt180
- dbt190
- dbt1100
include:
# Default to python 3.12 for dbt tests.
# * Python 3.13 not supported yet.
# * Looks like it's due to psycopg2 support as of 2024-10-10
- python-version: "3.12"
# For dbt 1.4 - 1.6 override to python 3.11
- dbt-version: dbt140
python-version: "3.11"
- dbt-version: dbt150
python-version: "3.11"
- dbt-version: dbt160
python-version: "3.11"
permissions:
contents: read
pull-requests: write

View File

@@ -113,7 +113,7 @@ source .venv/bin/activate
```
(The `dbt180` environment is a good default choice.
However any version can be installed by replacing `dbt180` with
`py`, `py39` through `py313`, `dbt140` through `dbt190`, etc.
`py`, `py39` through `py313`, `dbt170` through `dbt1100`, etc.
`py` defaults to the python version that was used to install tox.
To be able to run all tests including the dbt templater,
choose one of the dbt environments.)

2
constraints/dbt1100.txt Normal file
View File

@@ -0,0 +1,2 @@
dbt-core~=1.10.0b1
dbt-postgres~=1.10.0b1

View File

@@ -1,2 +0,0 @@
dbt-core~=1.4.1
dbt-postgres~=1.4.1

View File

@@ -1,2 +0,0 @@
dbt-core~=1.5.0
dbt-postgres~=1.5.0

View File

@@ -1,2 +0,0 @@
dbt-core~=1.5.0
dbt-postgres~=1.5.0

View File

@@ -1,2 +0,0 @@
dbt-core~=1.6.0
dbt-postgres~=1.6.0

View File

@@ -258,22 +258,9 @@ class DbtTemplater(JinjaTemplater):
# https://github.com/sqlfluff/sqlfluff/issues/5054
self.try_silence_dbt_logs()
if self.dbt_version_tuple >= (1, 5):
user_config = None
# 1.5.x+ this is a dict.
cli_vars = self._get_cli_vars()
else:
# Here, we read flags.PROFILE_DIR directly, prior to calling
# set_from_args(). Apparently, set_from_args() sets PROFILES_DIR
# to a lowercase version of the value, and the profile wouldn't be
# found if the directory name contained uppercase letters. This fix
# was suggested and described here:
# https://github.com/sqlfluff/sqlfluff/issues/2253#issuecomment-1018722979
from dbt.config import read_user_config
user_config = read_user_config(flags.PROFILES_DIR)
# Pre 1.5.x this is a string.
cli_vars = str(self._get_cli_vars())
user_config = None
# 1.5.x+ this is a dict.
cli_vars = self._get_cli_vars()
flags.set_from_args(
DbtConfigArgs(
@@ -348,41 +335,9 @@ class DbtTemplater(JinjaTemplater):
selector_methods_manager = DbtSelectorMethodManager(
self.dbt_manifest, previous_state=None
)
if self.dbt_version_tuple >= (1, 5):
_dbt_selector_method = selector_methods_manager.get_method(
DbtMethodName.Path, method_arguments=[]
)
else:
# This replicates the newer PathSelectorMethod of dbt 1.5+
# TODO: Remove once dbt 1.4 support is dropped
from dbt.graph.selector_methods import SelectorMethod
class ProjectPathSelectorMethod(SelectorMethod):
"""A path selector with `project_root` to work in dbt 1.4."""
def search(selector_self, included_nodes: set, selector: str):
"""Yields nodes from included that match the given path."""
root = Path(self.project_dir) if self.project_dir else Path.cwd()
paths = set(p.relative_to(root) for p in root.glob(selector))
for unique_id, node in selector_self.all_nodes(included_nodes):
ofp = Path(node.original_file_path)
if ofp in paths:
yield unique_id
if (
hasattr(node, "patch_path") and node.patch_path
): # pragma: no cover
pfp = node.patch_path.split("://")[1]
ymlfp = Path(pfp)
if ymlfp in paths:
yield unique_id
if any(
parent in paths for parent in ofp.parents
): # pragma: no cover
yield unique_id
_dbt_selector_method = ProjectPathSelectorMethod(
selector_methods_manager.manifest, None, []
)
_dbt_selector_method = selector_methods_manager.get_method(
DbtMethodName.Path, method_arguments=[]
)
if self.formatter: # pragma: no cover TODO?
self.formatter.dispatch_compilation_header(
@@ -662,12 +617,8 @@ class DbtTemplater(JinjaTemplater):
# overwritten.
render_func: Optional[Callable[[str], str]] = None
if self.dbt_version_tuple >= (1, 3):
compiled_sql_attribute = "compiled_code"
raw_sql_attribute = "raw_code"
else: # pragma: no cover
compiled_sql_attribute = "compiled_sql"
raw_sql_attribute = "raw_sql"
compiled_sql_attribute = "compiled_code"
raw_sql_attribute = "raw_code"
def from_string(*args, **kwargs):
"""Replaces (via monkeypatch) the jinja2.Environment function."""
@@ -701,7 +652,7 @@ class DbtTemplater(JinjaTemplater):
from dbt_common.events.contextvars import set_task_contextvars
set_task_contextvars(project_root=self.project_dir)
except ImportError:
except ImportError: # pragma: no cover
try:
from dbt.events.contextvars import set_task_contextvars

View File

@@ -1,5 +1,5 @@
[tox]
envlist = generate-fixture-yml, linting, doclinting, ruleslinting, docbuild, cov-init, doctests, py{39,310,311,312,313}, dbt{140,150,160,170,180,190}, cov-report, mypy, mypyc, winpy, dbt{150,180,190}-winpy, yamllint
envlist = generate-fixture-yml, linting, doclinting, ruleslinting, docbuild, cov-init, doctests, py{39,310,311,312,313}, dbt{170,180,190,1100}, cov-report, mypy, mypyc, winpy, dbt{180,190}-winpy, yamllint
min_version = 4.0 # Require 4.0+ for proper pyproject.toml support
[testenv]
@@ -20,7 +20,7 @@ deps =
# we force the right installation version up front in each environment.
# NOTE: This is a bit of a hack around tox, but it does achieve reasonably
# consistent results.
dbt{140,150,160,170,180,190}: -r constraints/{envname}.txt
dbt{170,180,190,1100}: -r constraints/{envname}.txt
# Include any other steps necessary for testing below.
# {posargs} is there to allow us to specify specific tests, which
# can then be invoked from tox by calling e.g.
@@ -32,7 +32,7 @@ commands =
# number pinned to the same version number of the main sqlfluff library
# so it _must_ be installed second in the context of a version which isn't
# yet released (and so not available on pypi).
dbt{140,150,160,170,180,190}: python -m pip install "{toxinidir}/plugins/sqlfluff-templater-dbt"
dbt{170,180,190,1100}: python -m pip install "{toxinidir}/plugins/sqlfluff-templater-dbt"
# Add the example plugin.
# NOTE: The trailing comma is important because in the github test suite
# the python version is not specified and instead the "py" or "winpy"