Skip to content

Commit

Permalink
Move the entirety of dbt-tests-adapter into the dbt-tests-adapter dir…
Browse files Browse the repository at this point in the history
…ectory (#118)
  • Loading branch information
mikealfare authored Mar 1, 2024
1 parent 5bc38c3 commit 7620c4f
Show file tree
Hide file tree
Showing 159 changed files with 80 additions and 38 deletions.
9 changes: 2 additions & 7 deletions .github/actions/build-hatch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ inputs:
archive-name:
description: Where to upload the artifacts
required: true
changelog-path:
description: Path to changelog file
required: true

runs:
using: composite
Expand All @@ -35,8 +32,6 @@ runs:
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.archive-name}}
path: |
${{ inputs.changelog-path }}
${{ inputs.working-dir }}dist/
name: ${{ inputs.archive-name }}
path: ${{ inputs.working-dir }}dist/
retention-days: 3
6 changes: 5 additions & 1 deletion .github/actions/publish-pypi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ runs:
uses: actions/download-artifact@v3
with:
name: ${{ inputs.archive-name }}
path: .
path: dist/

- name: "[DEBUG]"
run : ls -R
shell: bash

- name: Publish artifacts to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
64 changes: 44 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,55 @@ defaults:
shell: bash

jobs:
release-inputs:
name: "Release inputs"
runs-on: ubuntu-latest
outputs:
working-dir: ${{ steps.release-inputs.outputs.working-dir }}
run-unit-tests: ${{ steps.release-inputs.outputs.run-unit-tests }}
archive-name: ${{ steps.release-inputs.outputs.archive-name }}
steps:
- name: "Inputs"
id: release-inputs
run: |
working_dir="./"
run_unit_tests=true
archive_name=${{ inputs.package }}-${{ inputs.version_number }}-${{ inputs.deploy-to }}
if test "${{ inputs.package }}" = "dbt-tests-adapter"
then
working_dir="./dbt-tests-adapter/"
run_unit_tests=false
fi
echo "working-dir=$working_dir" >> $GITHUB_OUTPUT
echo "run-unit-tests=$run_unit_tests" >> $GITHUB_OUTPUT
echo "archive-name=$archive_name" >> $GITHUB_OUTPUT
- name: "[DEBUG]"
run: |
echo package : ${{ inputs.package }}
echo working-dir : ${{ steps.release-inputs.outputs.working-dir }}
echo run-unit-tests : ${{ steps.release-inputs.outputs.run-unit-tests }}
echo archive-name : ${{ steps.release-inputs.outputs.archive-name }}
bump-version-generate-changelog:
name: "Bump package version, Generate changelog"
uses: dbt-labs/dbt-adapters/.github/workflows/release_prep_hatch.yml@main
needs: [release-inputs]
with:
version_number: ${{ inputs.version_number }}
deploy_to: ${{ inputs.deploy-to }}
nightly_release: ${{ inputs.nightly_release }}
target_branch: ${{ inputs.target_branch }}
working-dir: ${{ needs.release-inputs.outputs.working-dir }}
run-unit-tests: ${{ fromJSON(needs.release-inputs.outputs.run-unit-tests) }}
secrets: inherit

log-outputs-bump-version-generate-changelog:
name: "[Log output] Bump package version, Generate changelog"
if: ${{ !failure() && !cancelled() }}
needs: [bump-version-generate-changelog]
needs: [release-inputs, bump-version-generate-changelog]
runs-on: ubuntu-latest
steps:
- name: Print variables
Expand All @@ -95,7 +130,7 @@ jobs:
build-and-test:
name: "Build and Test"
needs: [log-outputs-bump-version-generate-changelog, bump-version-generate-changelog]
needs: [release-inputs, bump-version-generate-changelog]
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
Expand All @@ -108,38 +143,29 @@ jobs:
- name: "Setup `hatch`"
uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main

- name: "Build `dbt-adapters`"
if: ${{ inputs.package == 'dbt-adapters' }}
uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main
with:
changelog-path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
archive-name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}

- name: "Build `dbt-tests-adapter`"
if: ${{ inputs.package == 'dbt-tests-adapter' }}
- name: "Build ${{ inputs.package }}"
uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main
with:
changelog-path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
working-dir: "./dbt-tests-adapter/"
archive-name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}
working-dir: ${{ needs.release-inputs.outputs.working-dir }}
archive-name: ${{ needs.release-inputs.outputs.archive-name }}

github-release:
name: "GitHub Release"
# ToDo: update GH release to handle adding dbt-tests-adapter and dbt-adapter assets to the same release
if: ${{ !failure() && !cancelled() && inputs.package == 'dbt-adapters' }}
needs: [build-and-test, bump-version-generate-changelog]
needs: [release-inputs, build-and-test, bump-version-generate-changelog]
uses: dbt-labs/dbt-adapters/.github/workflows/github-release.yml@main
with:
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
version_number: ${{ inputs.version_number }}
changelog_path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
test_run: ${{ inputs.deploy-to == 'test' && true || false }}
archive_name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}
archive_name: ${{ needs.release-inputs.outputs.archive-name }}

pypi-release:
name: "Publish to PyPI"
runs-on: ubuntu-latest
needs: [github-release]
needs: [release-inputs, build-and-test]
environment:
name: ${{ inputs.deploy-to }}
url: ${{ vars.PYPI_PROJECT_URL }}
Expand All @@ -151,6 +177,4 @@ jobs:
uses: dbt-labs/dbt-adapters/.github/actions/publish-pypi@main
with:
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
archive-name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}


archive-name: ${{ needs.release-inputs.outputs.archive-name }}
16 changes: 15 additions & 1 deletion .github/workflows/release_prep_hatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ on:
type: string
required: false
default: ''
run-unit-tests:
type: boolean
default: false
run-integration-tests:
type: boolean
default: false
Expand All @@ -61,6 +64,10 @@ on:
type: string
required: false
default: main
working-dir:
description: "The working directory to use for run statements"
type: string
default: "./"
outputs:
changelog_path:
description: The path to the changelog for this version
Expand Down Expand Up @@ -100,6 +107,9 @@ jobs:
echo Target branch: ${{ inputs.target_branch }}
echo Nightly release: ${{ inputs.nightly_release }}
echo Optional env setup script: ${{ inputs.env_setup_script_path }}
echo run-unit-tests: ${{ inputs.run-unit-tests }}
echo run-integration-tests: ${{ inputs.run-integration-tests }}
echo working-dir: ${{ inputs.working-dir }}
# ENVIRONMENT VARIABLES
echo Python target version: ${{ env.PYTHON_TARGET_VERSION }}
echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }}
Expand Down Expand Up @@ -191,6 +201,8 @@ jobs:
is_updated=true
fi
echo "up_to_date=$is_updated" >> $GITHUB_OUTPUT
working-directory: ${{ inputs.working-dir }}

- name: "[Notification] Check Current Version In Code"
run: |
title="Version check"
Expand Down Expand Up @@ -339,6 +351,7 @@ jobs:
if: needs.audit-version-in-code.outputs.up_to_date == 'false'
run: |
hatch version ${{ inputs.version_number }}
working-directory: ${{ inputs.working-dir }}
- name: "[Notification] Bump Version To ${{ inputs.version_number }}"
if: needs.audit-version-in-code.outputs.up_to_date == 'false'
run: |
Expand Down Expand Up @@ -373,6 +386,7 @@ jobs:
git push
run-unit-tests:
if: inputs.run-unit-tests == true
runs-on: ubuntu-latest
needs: [create-temp-branch, generate-changelog-bump-version]

Expand Down Expand Up @@ -433,7 +447,7 @@ jobs:
python-version: ${{ env.PYTHON_TARGET_VERSION }}

- name: Run tests
run: hatch run test:integration
run: hatch run integration-tests:all

merge-changes-into-target-branch:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions dbt-tests-adapter/dbt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# N.B.
# This will add to the package’s __path__ all subdirectories of directories on sys.path named after the package which effectively combines both modules into a single namespace (dbt.adapters)

from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 6 additions & 8 deletions dbt-tests-adapter/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ Changelog = "https://github.com/dbt-labs/dbt-adapters/blob/main/CHANGELOG.md"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist.force-include]
"../dbt/tests" = "dbt/tests"
"../dbt/__init__.py" = "dbt/__init__.py"
[tool.hatch.version]
path = "dbt/tests/__about__.py"

[tool.hatch.build.targets.wheel.force-include]
"../dbt/tests" = "dbt/tests"
"../dbt/__init__.py" = "dbt/__init__.py"
[tool.hatch.build.targets.sdist]
include = ["dbt/tests", "dbt/__init__.py"]

[tool.hatch.version]
path = "../dbt/tests/__about__.py"
[tool.hatch.build.targets.wheel]
include = ["dbt/tests", "dbt/__init__.py"]

[tool.hatch.envs.build]
detached = true
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.0a2"
version = "1.0.0a2"
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ files = [
]
exclude = [
"dbt/adapters/events/adapter_types_pb2.py",
"dbt-tests-adapter/dbt/__init__.py", # overlaps with `dbt/__init__.py` as expected for namespaces
"venv",
]
[[tool.mypy.overrides]]
Expand Down

0 comments on commit 7620c4f

Please sign in to comment.