Skip to content

Commit

Permalink
ADAP-1116: Move to hatch and pyproject.toml (#1407)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
mikealfare and colin-rogers-dbt authored Dec 11, 2024
1 parent 827fc78 commit e1b6e74
Show file tree
Hide file tree
Showing 21 changed files with 657 additions and 444 deletions.
35 changes: 0 additions & 35 deletions .bumpversion.cfg

This file was deleted.

6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20241117-194746.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Move from setup.py to pyproject.toml and to hatch as a dev tool
time: 2024-11-17T19:47:46.341-05:00
custom:
Author: mikealfare
Issue: "1407"
File renamed without changes.
6 changes: 3 additions & 3 deletions .github/scripts/update_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
set -e

git_branch=$1
target_req_file="dev-requirements.txt"
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${git_branch}#egg=dbt-core|g"
tests_req_sed_pattern="s|dbt-core.git.*#egg=dbt-tests|dbt-core.git@${git_branch}#egg=dbt-tests|g"
target_req_file="hatch.toml"
core_req_sed_pattern="s|dbt-core.git.*#subdirectory=core|dbt-core.git@${git_branch}#subdirectory=core|g"
tests_req_sed_pattern="s|dbt-adapters.git.*#subdirectory=dbt-tests-adapter|dbt-adapters.git@${git_branch}#subdirectory=dbt-tests-adapter|g"
if [[ "$OSTYPE" == darwin* ]]; then
# mac ships with a different version of sed that requires a delimiter arg
sed -i "" "$core_req_sed_pattern" $target_req_file
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/update_dev_dependency_branches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e
dbt_adapters_branch=$1
dbt_core_branch=$2
dbt_common_branch=$3
target_req_file="dev-requirements.txt"
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${dbt_core_branch}#egg=dbt-core|g"
target_req_file="hatch.toml"
core_req_sed_pattern="s|dbt-core.git.*#subdirectory=core|dbt-core.git@${dbt_core_branch}#subdirectory=core|g"
adapters_req_sed_pattern="s|dbt-adapters.git|dbt-adapters.git@${dbt_adapters_branch}|g"
common_req_sed_pattern="s|dbt-common.git|dbt-common.git@${dbt_common_branch}|g"
if [[ "$OSTYPE" == darwin* ]]; then
Expand Down
52 changes: 8 additions & 44 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ jobs:
bigquery:
- 'dbt/**'
- 'tests/**'
- 'dev-requirements.txt'
- 'hatch.toml'
- 'pyproject.toml'
- '.github/**'
- '*.py'
Expand Down Expand Up @@ -164,8 +165,6 @@ jobs:
matrix: ${{ fromJSON(needs.test-metadata.outputs.matrix) }}

env:
TOXENV: integration-${{ matrix.adapter }}
PYTEST_ADDOPTS: "-v --color=yes -n4 --csv integration_results.csv"
DBT_INVOCATION_ENV: github-actions
DD_CIVISIBILITY_AGENTLESS_ENABLED: true
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
Expand Down Expand Up @@ -201,12 +200,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install tox
python -m pip --version
tox --version
- uses: pypa/hatch@install

- name: Update Adapters and Core branches (update dev_requirements.txt)
if: github.event_name == 'workflow_dispatch'
Expand All @@ -215,10 +209,9 @@ jobs:
${{ inputs.dbt_adapters_branch }} \
${{ inputs.dbt_core_branch }} \
${{ inputs.dbt_common_branch }}
cat dev-requirements.txt
cat hatch.toml
- name: Run tox (bigquery)
if: matrix.adapter == 'bigquery'
- run: hatch run integration-tests tests/functional -k "not TestPython"
env:
BIGQUERY_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.BIGQUERY_TEST_SERVICE_ACCOUNT_JSON }}
BIGQUERY_TEST_ALT_DATABASE: ${{ secrets.BIGQUERY_TEST_ALT_DATABASE }}
Expand All @@ -229,36 +222,13 @@ jobs:
DATAPROC_REGION: us-central1
DATAPROC_CLUSTER_NAME: dbt-test-1
GCS_BUCKET: dbt-ci
run: tox -- --ddtrace

- name: Get current date
if: always()
id: date
run: |
echo "date=$(date +'%Y-%m-%dT%H_%M_%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
- uses: actions/upload-artifact@v4
if: always()
with:
name: logs_${{ matrix.python-version }}_${{ matrix.os }}_${{ matrix.adapter }}-${{ steps.date.outputs.date }}
path: ./logs
overwrite: true

- uses: actions/upload-artifact@v4
if: always()
with:
name: integration_results_${{ matrix.python-version }}_${{ matrix.os }}_${{ matrix.adapter }}-${{ steps.date.outputs.date }}.csv
path: integration_results.csv
overwrite: true

# python integration tests are slow so we only run them seperately and for a single OS / python version
test-python:
name: "test-python"
needs: test-metadata
needs: test
runs-on: ubuntu-latest
if: >-
needs.test-metadata.outputs.matrix &&
fromJSON( needs.test-metadata.outputs.matrix ).include[0] &&
(
github.event_name != 'pull_request_target' ||
github.event.pull_request.head.repo.full_name == github.repository ||
Expand Down Expand Up @@ -286,14 +256,9 @@ jobs:
with:
python-version: "3.9"

- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install tox
python -m pip --version
tox --version
- uses: pypa/hatch@install

- name: Run tox (python models)
- run: hatch run integration-tests tests/functional -n1 -k "TestPython" --ddtrace
env:
BIGQUERY_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.BIGQUERY_TEST_SERVICE_ACCOUNT_JSON }}
BIGQUERY_TEST_ALT_DATABASE: ${{ secrets.BIGQUERY_TEST_ALT_DATABASE }}
Expand All @@ -304,7 +269,6 @@ jobs:
DATAPROC_REGION: us-central1
DATAPROC_CLUSTER_NAME: dbt-test-1
GCS_BUCKET: dbt-ci
run: tox -e python-tests -- --ddtrace

require-label-comment:
runs-on: ubuntu-latest
Expand Down
60 changes: 8 additions & 52 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,8 @@ jobs:
with:
python-version: '3.9'

- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install -r dev-requirements.txt
python -m pip --version
pre-commit --version
dbt --version
- name: Run pre-comit hooks
run: pre-commit run --all-files --show-diff-on-failure
- name: Run pre-commit hooks
uses: pre-commit/[email protected]

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

env:
TOXENV: "unit"
PYTEST_ADDOPTS: "-v --color=yes --csv unit_results.csv"

steps:
- name: Check out the repository
uses: actions/checkout@v4
Expand All @@ -88,27 +77,9 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install tox
python -m pip --version
tox --version
- name: Run tox
run: tox
uses: pypa/hatch@install

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

build:
name: build packages
Expand All @@ -129,25 +100,16 @@ jobs:
with:
python-version: '3.9'

- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install --upgrade setuptools wheel twine check-wheel-contents
python -m pip --version
- uses: pypa/hatch@install

- name: Build distributions
run: ./scripts/build-dist.sh
run: hatch build

- name: Show distributions
run: ls -lh dist/

- name: Check distribution descriptions
run: |
twine check dist/*
- name: Check wheel contents
run: |
check-wheel-contents dist/*.whl --ignore W007,W008
run: hatch run build:check-all

- name: Check if this is an alpha version
id: check-is-alpha
Expand All @@ -174,7 +136,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
os: [ubuntu-22.04, macos-14, windows-2022]
python-version: ['3.9', '3.10', '3.11', '3.12']
dist-type: ["whl", "gz"]

Expand All @@ -184,12 +146,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install --upgrade wheel
python -m pip --version
- uses: actions/download-artifact@v4
with:
name: dist
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ jobs:
commit_sha=$(git rev-parse HEAD)
echo "release_commit=$commit_sha" >> $GITHUB_OUTPUT
- name: "Get Current Version Number"
id: version-number-sources
run: |
current_version=`awk -F"current_version = " '{print $2}' .bumpversion.cfg | tr '\n' ' '`
echo "current_version=$current_version" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- uses: pypa/hatch@install

- id: version-number-sources
run: echo "current_version=$(hatch version)" >> $GITHUB_OUTPUT

- name: "Audit Version And Parse Into Parts"
id: semver
Expand Down Expand Up @@ -108,10 +112,5 @@ jobs:
sha: ${{ needs.aggregate-release-data.outputs.commit_sha }}
target_branch: ${{ needs.aggregate-release-data.outputs.release_branch }}
version_number: ${{ needs.aggregate-release-data.outputs.version_number }}
build_script_path: "scripts/build-dist.sh"
env_setup_script_path: "scripts/env-setup.sh"
s3_bucket_name: "core-team-artifacts"
package_test_command: "dbt -h"
test_run: true
nightly_release: true
secrets: inherit
Loading

0 comments on commit e1b6e74

Please sign in to comment.