Skip to content

Commit 8dbfbff

Browse files
committed
chore: create make command install dbt version
1 parent 4c94ee1 commit 8dbfbff

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

.github/workflows/pr.yaml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,7 @@ jobs:
7373
strategy:
7474
fail-fast: false
7575
matrix:
76-
dbt-version:
77-
[
78-
'1.3.0',
79-
'1.4.0',
80-
'1.5.0',
81-
'1.6.0',
82-
'1.7.0',
83-
'1.8.0',
84-
'1.9.0',
85-
'1.10.0',
86-
]
76+
dbt-version: ['1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10']
8777
steps:
8878
- uses: actions/checkout@v5
8979
- name: Set up Python
@@ -96,18 +86,7 @@ jobs:
9686
run: |
9787
uv venv .venv
9888
source .venv/bin/activate
99-
sed -i 's/"pydantic>=2.0.0"/"pydantic"/g' pyproject.toml
100-
if [[ "${{ matrix.dbt-version }}" == "1.10.0" ]]; then
101-
# For 1.10.0: only add version to dbt-core, remove versions from all adapter packages
102-
sed -i -E 's/"(dbt-core)[^"]*"/"\1~=${{ matrix.dbt-version }}"/g' pyproject.toml
103-
# Remove version constraints from all dbt adapter packages
104-
sed -i -E 's/"(dbt-(bigquery|duckdb|snowflake|athena-community|clickhouse|databricks|redshift|trino))[^"]*"/"\1"/g' pyproject.toml
105-
else
106-
# For other versions: apply version to all dbt packages
107-
sed -i -E 's/"(dbt-[^">=<~!]+)[^"]*"/"\1~=${{ matrix.dbt-version }}"/g' pyproject.toml
108-
fi
109-
UV=1 make install-dev
110-
uv pip install pydantic>=2.0.0 --reinstall
89+
UV=1 make install-dev-dbt-${{ matrix.dbt-version }}
11190
- name: Run dbt tests
11291
# We can't run slow tests across all engines due to tests requiring DuckDB and old versions
11392
# of DuckDB require a version of DuckDB we no longer support

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ else
66
PIP := pip3
77
endif
88

9+
UNAME_S := $(shell uname -s)
10+
ifeq ($(UNAME_S),Darwin)
11+
SED_INPLACE = sed -i ''
12+
else
13+
SED_INPLACE = sed -i
14+
endif
15+
916
install-dev:
1017
$(PIP) install -e ".[dev,web,slack,dlt,lsp]" ./examples/custom_materializations
1118

@@ -15,6 +22,33 @@ install-doc:
1522
install-pre-commit:
1623
pre-commit install
1724

25+
install-dev-dbt-%:
26+
@version="$*"; \
27+
period_count=$$(echo "$$version" | tr -cd '.' | wc -c); \
28+
if [ "$$period_count" -eq 0 ]; then \
29+
version="$${version:0:1}.$${version:1}"; \
30+
elif [ "$$period_count" -eq 1 ]; then \
31+
version="$$version.0"; \
32+
fi; \
33+
echo "Installing dbt version: $$version"; \
34+
cp pyproject.toml pyproject.toml.backup; \
35+
$(SED_INPLACE) 's/"pydantic>=2.0.0"/"pydantic"/g' pyproject.toml; \
36+
if [ "$$version" = "1.10.0" ]; then \
37+
echo "Applying special handling for dbt 1.10.0"; \
38+
$(SED_INPLACE) -E 's/"(dbt-core)[^"]*"/"\1~='"$$version"'"/g' pyproject.toml; \
39+
$(SED_INPLACE) -E 's/"(dbt-(bigquery|duckdb|snowflake|athena-community|clickhouse|databricks|redshift|trino))[^"]*"/"\1"/g' pyproject.toml; \
40+
else \
41+
echo "Applying version $$version to all dbt packages"; \
42+
$(SED_INPLACE) -E 's/"(dbt-[^"><=~!]+)[^"]*"/"\1~='"$$version"'"/g' pyproject.toml; \
43+
fi; \
44+
$(MAKE) install-dev; \
45+
if [ "$$version" = "1.6.0" ]; then \
46+
echo "Applying pydantic override for dbt 1.6.0"; \
47+
$(PIP) install 'pydantic>=2.0.0' --reinstall; \
48+
fi; \
49+
mv pyproject.toml.backup pyproject.toml; \
50+
echo "Restored original pyproject.toml"
51+
1852
style:
1953
pre-commit run --all-files
2054

0 commit comments

Comments
 (0)