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

Commit b687ac4

Browse files
authored
ADAP-1115: Move to hatch and pyproject.toml (#1250)
* move config files into pyproject.toml and hatch.toml * update workflow files to use hatch.toml * move test matrix into the workflow * fix pytest config in pyproject.toml
1 parent b8607e9 commit b687ac4

18 files changed

+635
-551
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-17T18:44:30.85288-05:00
4+
custom:
5+
Author: mikealfare
6+
Issue: "1250"

.github/scripts/integration-test-matrix.js

Lines changed: 0 additions & 95 deletions
This file was deleted.

.github/scripts/update_dependencies.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/scripts/update_dev_dependency_branches.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ 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"
11+
tests_req_sed_pattern="s|dbt-adapters.git.*#subdirectory=dbt-tests-adapter|dbt-adapters.git@${dbt_adapters_branch}#subdirectory=dbt-tests-adapter|g"
1112
common_req_sed_pattern="s|dbt-common.git|dbt-common.git@${dbt_common_branch}|g"
1213
if [[ "$OSTYPE" == darwin* ]]; then
1314
# mac ships with a different version of sed that requires a delimiter arg
1415
sed -i "" "$adapters_req_sed_pattern" $target_req_file
16+
sed -i "" "$tests_req_sed_pattern" $target_req_file
1517
sed -i "" "$core_req_sed_pattern" $target_req_file
1618
sed -i "" "$common_req_sed_pattern" $target_req_file
1719
else
1820
sed -i "$adapters_req_sed_pattern" $target_req_file
21+
sed -i "$tests_req_sed_pattern" $target_req_file
1922
sed -i "$core_req_sed_pattern" $target_req_file
2023
sed -i "$common_req_sed_pattern" $target_req_file
2124
fi

.github/workflows/integration.yml

Lines changed: 13 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -76,85 +76,31 @@ defaults:
7676
shell: bash
7777

7878
jobs:
79-
# generate test metadata about what files changed and the testing matrix to use
80-
test-metadata:
81-
# run if not a PR from a forked repository or has a label to mark as safe to test
82-
if: >-
83-
github.event_name != 'pull_request_target' ||
84-
github.event.pull_request.head.repo.full_name == github.repository ||
85-
contains(github.event.pull_request.labels.*.name, 'ok to test')
86-
runs-on: ubuntu-latest
87-
outputs:
88-
matrix: ${{ steps.generate-matrix.outputs.result }}
89-
90-
steps:
91-
- name: Check out the repository (non-PR)
92-
if: github.event_name != 'pull_request_target'
93-
uses: actions/checkout@v4
94-
with:
95-
persist-credentials: false
96-
97-
- name: Check out the repository (PR)
98-
if: github.event_name == 'pull_request_target'
99-
uses: actions/checkout@v4
100-
with:
101-
persist-credentials: false
102-
ref: ${{ github.event.pull_request.head.sha }}
103-
104-
- name: Check if relevant files changed
105-
if: github.event_name == 'pull_request_target'
106-
# https://github.com/marketplace/actions/paths-changes-filter
107-
# For each filter, it sets output variable named by the filter to the text:
108-
# 'true' - if any of changed files matches any of filter rules
109-
# 'false' - if none of changed files matches any of filter rules
110-
# also, returns:
111-
# `changes` - JSON array with names of all filters matching any of the changed files
112-
uses: dorny/paths-filter@v3
113-
id: get-changes
114-
with:
115-
token: ${{ secrets.GITHUB_TOKEN }}
116-
filters: |
117-
snowflake:
118-
- '.github/**/*.yml'
119-
- '.github/**/*.sh'
120-
- 'dbt/**'
121-
- 'tests/**'
122-
- 'dev-requirements.txt'
123-
- '*.py'
124-
- name: Generate integration test matrix
125-
id: generate-matrix
126-
uses: actions/github-script@v7
127-
env:
128-
CHANGES: ${{ steps.get-changes.outputs.changes }}
129-
with:
130-
script: |
131-
const script = require('./.github/scripts/integration-test-matrix.js')
132-
const matrix = script({ context })
133-
console.log(matrix)
134-
return matrix
13579
test:
136-
name: ${{ matrix.adapter }} / python ${{ matrix.python-version }} / ${{ matrix.os }}
80+
name: ${{ matrix.os }} / python ${{ matrix.python-version }}
13781

13882
# run if not a PR from a forked repository or has a label to mark as safe to test
13983
# also checks that the matrix generated is not empty
14084
if: >-
141-
needs.test-metadata.outputs.matrix &&
142-
fromJSON( needs.test-metadata.outputs.matrix ).include[0] &&
14385
(
14486
github.event_name != 'pull_request_target' ||
14587
github.event.pull_request.head.repo.full_name == github.repository ||
14688
contains(github.event.pull_request.labels.*.name, 'ok to test')
14789
)
14890
runs-on: ${{ matrix.os }}
149-
needs: test-metadata
15091

15192
strategy:
15293
fail-fast: false
153-
matrix: ${{ fromJSON(needs.test-metadata.outputs.matrix) }}
94+
matrix:
95+
os: [ubuntu-22.04]
96+
python-version: ["3.9", "3.10", "3.11", "3.12"]
97+
include:
98+
- os: macos-14
99+
python-version: "3.9"
100+
- os: windows-2022
101+
python-version: "3.9"
154102

155103
env:
156-
TOXENV: integration-${{ matrix.adapter }}
157-
PYTEST_ADDOPTS: "-v --color=yes -n4 --csv integration_results.csv"
158104
DBT_INVOCATION_ENV: github-actions
159105
DD_CIVISIBILITY_AGENTLESS_ENABLED: true
160106
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
@@ -190,24 +136,19 @@ jobs:
190136
with:
191137
python-version: ${{ matrix.python-version }}
192138

193-
- name: Update Adapters and Core branches (update dev_requirements.txt)
139+
- name: Update Adapters and Core branches (update hatch.toml)
194140
if: ${{ github.event_name == 'workflow_dispatch' }}
195141
run: |
196142
./.github/scripts/update_dev_dependency_branches.sh \
197143
${{ inputs.dbt_adapters_branch }} \
198144
${{ inputs.dbt_core_branch }} \
199145
${{ inputs.dbt_common_branch }}
200-
cat dev-requirements.txt
146+
cat hatch.toml
201147
202148
- name: Install python dependencies
203-
run: |
204-
python -m pip install --user --upgrade pip
205-
python -m pip install tox
206-
python -m pip --version
207-
tox --version
149+
uses: pypa/hatch@install
208150

209-
- name: Run tox (snowflake)
210-
if: matrix.adapter == 'snowflake'
151+
- run: hatch run integration-tests tests/functional --ddtrace
211152
env:
212153
SNOWFLAKE_TEST_ACCOUNT: ${{ secrets.SNOWFLAKE_TEST_ACCOUNT }}
213154
SNOWFLAKE_TEST_PASSWORD: ${{ secrets.SNOWFLAKE_TEST_PASSWORD }}
@@ -226,26 +167,6 @@ jobs:
226167
DBT_TEST_USER_1: dbt_test_role_1
227168
DBT_TEST_USER_2: dbt_test_role_2
228169
DBT_TEST_USER_3: dbt_test_role_3
229-
run: tox -- --ddtrace
230-
231-
- name: Get current date
232-
if: always()
233-
id: date
234-
run: echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
235-
236-
- uses: actions/upload-artifact@v4
237-
if: always()
238-
with:
239-
name: logs_${{ matrix.python-version }}_${{ matrix.os }}_${{ matrix.adapter }}-${{ steps.date.outputs.date }}
240-
path: ./logs
241-
overwrite: true
242-
243-
- uses: actions/upload-artifact@v4
244-
if: always()
245-
with:
246-
name: integration_results_${{ matrix.python-version }}_${{ matrix.os }}_${{ matrix.adapter }}-${{ steps.date.outputs.date }}.csv
247-
path: integration_results.csv
248-
overwrite: true
249170

250171
require-label-comment:
251172
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)