Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit e1b6e74

Browse files
ADAP-1116: Move to hatch and pyproject.toml (#1407)
* move setup.py to pyproject.toml * move dev tool config to pyproject.toml * update integration.yml to use hatch commands * update main.yml to use hatch commands * update scripts for pyproject.toml and hatch.toml references * update release workflow to use hatch --------- Co-authored-by: Colin Rogers <[email protected]>
1 parent 827fc78 commit e1b6e74

21 files changed

+657
-444
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Under the Hood
2+
body: Move from setup.py to pyproject.toml and to hatch as a dev tool
3+
time: 2024-11-17T19:47:46.341-05:00
4+
custom:
5+
Author: mikealfare
6+
Issue: "1407"
File renamed without changes.

.github/scripts/update_dependencies.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
set -e
33

44
git_branch=$1
5-
target_req_file="dev-requirements.txt"
6-
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${git_branch}#egg=dbt-core|g"
7-
tests_req_sed_pattern="s|dbt-core.git.*#egg=dbt-tests|dbt-core.git@${git_branch}#egg=dbt-tests|g"
5+
target_req_file="hatch.toml"
6+
core_req_sed_pattern="s|dbt-core.git.*#subdirectory=core|dbt-core.git@${git_branch}#subdirectory=core|g"
7+
tests_req_sed_pattern="s|dbt-adapters.git.*#subdirectory=dbt-tests-adapter|dbt-adapters.git@${git_branch}#subdirectory=dbt-tests-adapter|g"
88
if [[ "$OSTYPE" == darwin* ]]; then
99
# mac ships with a different version of sed that requires a delimiter arg
1010
sed -i "" "$core_req_sed_pattern" $target_req_file

.github/scripts/update_dev_dependency_branches.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -e
55
dbt_adapters_branch=$1
66
dbt_core_branch=$2
77
dbt_common_branch=$3
8-
target_req_file="dev-requirements.txt"
9-
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${dbt_core_branch}#egg=dbt-core|g"
8+
target_req_file="hatch.toml"
9+
core_req_sed_pattern="s|dbt-core.git.*#subdirectory=core|dbt-core.git@${dbt_core_branch}#subdirectory=core|g"
1010
adapters_req_sed_pattern="s|dbt-adapters.git|dbt-adapters.git@${dbt_adapters_branch}|g"
1111
common_req_sed_pattern="s|dbt-common.git|dbt-common.git@${dbt_common_branch}|g"
1212
if [[ "$OSTYPE" == darwin* ]]; then

.github/workflows/integration.yml

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ jobs:
127127
bigquery:
128128
- 'dbt/**'
129129
- 'tests/**'
130-
- 'dev-requirements.txt'
130+
- 'hatch.toml'
131+
- 'pyproject.toml'
131132
- '.github/**'
132133
- '*.py'
133134
@@ -164,8 +165,6 @@ jobs:
164165
matrix: ${{ fromJSON(needs.test-metadata.outputs.matrix) }}
165166

166167
env:
167-
TOXENV: integration-${{ matrix.adapter }}
168-
PYTEST_ADDOPTS: "-v --color=yes -n4 --csv integration_results.csv"
169168
DBT_INVOCATION_ENV: github-actions
170169
DD_CIVISIBILITY_AGENTLESS_ENABLED: true
171170
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
@@ -201,12 +200,7 @@ jobs:
201200
with:
202201
python-version: ${{ matrix.python-version }}
203202

204-
- name: Install python dependencies
205-
run: |
206-
python -m pip install --user --upgrade pip
207-
python -m pip install tox
208-
python -m pip --version
209-
tox --version
203+
- uses: pypa/hatch@install
210204

211205
- name: Update Adapters and Core branches (update dev_requirements.txt)
212206
if: github.event_name == 'workflow_dispatch'
@@ -215,10 +209,9 @@ jobs:
215209
${{ inputs.dbt_adapters_branch }} \
216210
${{ inputs.dbt_core_branch }} \
217211
${{ inputs.dbt_common_branch }}
218-
cat dev-requirements.txt
212+
cat hatch.toml
219213
220-
- name: Run tox (bigquery)
221-
if: matrix.adapter == 'bigquery'
214+
- run: hatch run integration-tests tests/functional -k "not TestPython"
222215
env:
223216
BIGQUERY_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.BIGQUERY_TEST_SERVICE_ACCOUNT_JSON }}
224217
BIGQUERY_TEST_ALT_DATABASE: ${{ secrets.BIGQUERY_TEST_ALT_DATABASE }}
@@ -229,36 +222,13 @@ jobs:
229222
DATAPROC_REGION: us-central1
230223
DATAPROC_CLUSTER_NAME: dbt-test-1
231224
GCS_BUCKET: dbt-ci
232-
run: tox -- --ddtrace
233-
234-
- name: Get current date
235-
if: always()
236-
id: date
237-
run: |
238-
echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
239-
240-
- uses: actions/upload-artifact@v4
241-
if: always()
242-
with:
243-
name: logs_${{ matrix.python-version }}_${{ matrix.os }}_${{ matrix.adapter }}-${{ steps.date.outputs.date }}
244-
path: ./logs
245-
overwrite: true
246-
247-
- uses: actions/upload-artifact@v4
248-
if: always()
249-
with:
250-
name: integration_results_${{ matrix.python-version }}_${{ matrix.os }}_${{ matrix.adapter }}-${{ steps.date.outputs.date }}.csv
251-
path: integration_results.csv
252-
overwrite: true
253225

254226
# python integration tests are slow so we only run them seperately and for a single OS / python version
255227
test-python:
256228
name: "test-python"
257-
needs: test-metadata
229+
needs: test
258230
runs-on: ubuntu-latest
259231
if: >-
260-
needs.test-metadata.outputs.matrix &&
261-
fromJSON( needs.test-metadata.outputs.matrix ).include[0] &&
262232
(
263233
github.event_name != 'pull_request_target' ||
264234
github.event.pull_request.head.repo.full_name == github.repository ||
@@ -286,14 +256,9 @@ jobs:
286256
with:
287257
python-version: "3.9"
288258

289-
- name: Install python dependencies
290-
run: |
291-
python -m pip install --user --upgrade pip
292-
python -m pip install tox
293-
python -m pip --version
294-
tox --version
259+
- uses: pypa/hatch@install
295260

296-
- name: Run tox (python models)
261+
- run: hatch run integration-tests tests/functional -n1 -k "TestPython" --ddtrace
297262
env:
298263
BIGQUERY_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.BIGQUERY_TEST_SERVICE_ACCOUNT_JSON }}
299264
BIGQUERY_TEST_ALT_DATABASE: ${{ secrets.BIGQUERY_TEST_ALT_DATABASE }}
@@ -304,7 +269,6 @@ jobs:
304269
DATAPROC_REGION: us-central1
305270
DATAPROC_CLUSTER_NAME: dbt-test-1
306271
GCS_BUCKET: dbt-ci
307-
run: tox -e python-tests -- --ddtrace
308272

309273
require-label-comment:
310274
runs-on: ubuntu-latest

.github/workflows/main.yml

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,8 @@ jobs:
5252
with:
5353
python-version: '3.9'
5454

55-
- name: Install python dependencies
56-
run: |
57-
python -m pip install --user --upgrade pip
58-
python -m pip install -r dev-requirements.txt
59-
python -m pip --version
60-
pre-commit --version
61-
dbt --version
62-
- name: Run pre-comit hooks
63-
run: pre-commit run --all-files --show-diff-on-failure
55+
- name: Run pre-commit hooks
56+
uses: pre-commit/[email protected]
6457

6558
unit:
6659
name: unit test / python ${{ matrix.python-version }}
@@ -72,10 +65,6 @@ jobs:
7265
matrix:
7366
python-version: ['3.9', '3.10', '3.11', '3.12']
7467

75-
env:
76-
TOXENV: "unit"
77-
PYTEST_ADDOPTS: "-v --color=yes --csv unit_results.csv"
78-
7968
steps:
8069
- name: Check out the repository
8170
uses: actions/checkout@v4
@@ -88,27 +77,9 @@ jobs:
8877
python-version: ${{ matrix.python-version }}
8978

9079
- name: Install python dependencies
91-
run: |
92-
python -m pip install --user --upgrade pip
93-
python -m pip install tox
94-
python -m pip --version
95-
tox --version
96-
97-
- name: Run tox
98-
run: tox
80+
uses: pypa/hatch@install
9981

100-
- name: Get current date
101-
if: always()
102-
id: date
103-
run: |
104-
echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
105-
106-
- uses: actions/upload-artifact@v4
107-
if: always()
108-
with:
109-
name: unit_results_${{ matrix.python-version }}-${{ steps.date.outputs.date }}.csv
110-
path: unit_results.csv
111-
overwrite: true
82+
- run: hatch run unit-tests
11283

11384
build:
11485
name: build packages
@@ -129,25 +100,16 @@ jobs:
129100
with:
130101
python-version: '3.9'
131102

132-
- name: Install python dependencies
133-
run: |
134-
python -m pip install --user --upgrade pip
135-
python -m pip install --upgrade setuptools wheel twine check-wheel-contents
136-
python -m pip --version
103+
- uses: pypa/hatch@install
137104

138105
- name: Build distributions
139-
run: ./scripts/build-dist.sh
106+
run: hatch build
140107

141108
- name: Show distributions
142109
run: ls -lh dist/
143110

144111
- name: Check distribution descriptions
145-
run: |
146-
twine check dist/*
147-
148-
- name: Check wheel contents
149-
run: |
150-
check-wheel-contents dist/*.whl --ignore W007,W008
112+
run: hatch run build:check-all
151113

152114
- name: Check if this is an alpha version
153115
id: check-is-alpha
@@ -174,7 +136,7 @@ jobs:
174136
strategy:
175137
fail-fast: false
176138
matrix:
177-
os: [ubuntu-latest, macos-14, windows-latest]
139+
os: [ubuntu-22.04, macos-14, windows-2022]
178140
python-version: ['3.9', '3.10', '3.11', '3.12']
179141
dist-type: ["whl", "gz"]
180142

@@ -184,12 +146,6 @@ jobs:
184146
with:
185147
python-version: ${{ matrix.python-version }}
186148

187-
- name: Install python dependencies
188-
run: |
189-
python -m pip install --user --upgrade pip
190-
python -m pip install --upgrade wheel
191-
python -m pip --version
192-
193149
- uses: actions/download-artifact@v4
194150
with:
195151
name: dist

.github/workflows/nightly-release.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ jobs:
5050
commit_sha=$(git rev-parse HEAD)
5151
echo "release_commit=$commit_sha" >> $GITHUB_OUTPUT
5252
53-
- name: "Get Current Version Number"
54-
id: version-number-sources
55-
run: |
56-
current_version=`awk -F"current_version = " '{print $2}' .bumpversion.cfg | tr '\n' ' '`
57-
echo "current_version=$current_version" >> $GITHUB_OUTPUT
53+
- name: Set up Python
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: '3.9'
57+
58+
- uses: pypa/hatch@install
59+
60+
- id: version-number-sources
61+
run: echo "current_version=$(hatch version)" >> $GITHUB_OUTPUT
5862

5963
- name: "Audit Version And Parse Into Parts"
6064
id: semver
@@ -108,10 +112,5 @@ jobs:
108112
sha: ${{ needs.aggregate-release-data.outputs.commit_sha }}
109113
target_branch: ${{ needs.aggregate-release-data.outputs.release_branch }}
110114
version_number: ${{ needs.aggregate-release-data.outputs.version_number }}
111-
build_script_path: "scripts/build-dist.sh"
112-
env_setup_script_path: "scripts/env-setup.sh"
113-
s3_bucket_name: "core-team-artifacts"
114-
package_test_command: "dbt -h"
115-
test_run: true
116115
nightly_release: true
117116
secrets: inherit

0 commit comments

Comments
 (0)