From ee3da67db6f69baca576f6b758550257f8c1d575 Mon Sep 17 00:00:00 2001 From: Mila Page <67295367+VersusFacit@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:06:21 -0700 Subject: [PATCH 1/6] Add release internal workflow (#36) Co-authored-by: Mila Page --- .github/workflows/release-internal.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release-internal.yml b/.github/workflows/release-internal.yml index d560787e..01f1a9e3 100644 --- a/.github/workflows/release-internal.yml +++ b/.github/workflows/release-internal.yml @@ -1,19 +1,16 @@ # What? # -# Send a sha as a fully fledged relase to an internal archive for further processing. +# Tag and release an arbitrary ref. Uploads to an internal archive for further processing. # # How? # -# Checkout the sha -# Test it -# Build it -# Upload it +# After checking out and testing the provided ref, the image is built and uploaded. # # When? # -# Manual trigger +# Manual trigger. -name: Release internal patch +name: "Release internal patch" on: workflow_dispatch: @@ -22,10 +19,11 @@ on: description: "The release version number (i.e. 1.0.0b1)" type: string required: true - sha: - description: "The sha to use (leave empty to use latest on main)" + ref: + description: "The ref (sha or branch name) to use" type: string - required: false + default: "main" + required: true package_test_command: description: "Package test command" type: string @@ -36,19 +34,16 @@ defaults: run: shell: "bash" -env: - PYTHON_TARGET_VERSION: 3.11 - jobs: invoke-reusable-workflow: name: "Build and Release Internally" - uses: "dbt-labs/dbt-release/.github/workflows/internal-archive-release.yml@mp/finish_internal_workflow" + uses: "dbt-labs/dbt-release/.github/workflows/internal-archive-release.yml@main" with: version_number: "${{ inputs.version_number }}" package_test_command: "${{ inputs.package_test_command }}" dbms_name: "postgres" - sha: "${{ inputs.sha }}" + ref: "${{ inputs.ref }}" secrets: "inherit" From b35ce40e6d594a04c2dec7401c18378798e77782 Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:43:24 -0400 Subject: [PATCH 2/6] Pin `black>=24.3` (#40) --- .changes/unreleased/Security-20240327-193942.yaml | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Security-20240327-193942.yaml diff --git a/.changes/unreleased/Security-20240327-193942.yaml b/.changes/unreleased/Security-20240327-193942.yaml new file mode 100644 index 00000000..66dee543 --- /dev/null +++ b/.changes/unreleased/Security-20240327-193942.yaml @@ -0,0 +1,6 @@ +kind: Security +body: Pin `black>=24.3` in `pyproject.toml` +time: 2024-03-27T19:39:42.633016-04:00 +custom: + Author: mikealfare + Issue: "40" diff --git a/pyproject.toml b/pyproject.toml index acef4e33..10fd7f7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ dependencies = [ [tool.hatch.envs.lint] detached = true dependencies = [ - "black", + "black>=24.3", "flake8", "Flake8-pyproject", ] From 1c95a75a4cc5b03440a20bbf45c9c82e96a96e16 Mon Sep 17 00:00:00 2001 From: colin-rogers-dbt <111200756+colin-rogers-dbt@users.noreply.github.com> Date: Mon, 1 Apr 2024 20:07:27 -0700 Subject: [PATCH 3/6] revert default psycopg2 back to psycopg2-binary (#41) --- .../Dependencies-20240328-133507.yaml | 6 +++ hatch_build.py | 54 +++++++++++++++++++ pyproject.toml | 17 +++--- 3 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 .changes/unreleased/Dependencies-20240328-133507.yaml create mode 100644 hatch_build.py diff --git a/.changes/unreleased/Dependencies-20240328-133507.yaml b/.changes/unreleased/Dependencies-20240328-133507.yaml new file mode 100644 index 00000000..c7dbd319 --- /dev/null +++ b/.changes/unreleased/Dependencies-20240328-133507.yaml @@ -0,0 +1,6 @@ +kind: Dependencies +body: add "no-binary" install option +time: 2024-03-28T13:35:07.300121-07:00 +custom: + Author: colin-rogers-dbt + Issue: "6" diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 00000000..02693cf0 --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,54 @@ +import os +from typing import Any, Dict + +from hatchling.builders.config import BuilderConfig +from hatchling.builders.hooks.plugin.interface import BuildHookInterface +from hatchling.plugin import hookimpl + +BASE_DEPS = [ + # psycopg2 dependency installed in custom hatch_build.py + "dbt-adapters>=0.1.0a1,<2.0", + # installed via dbt-adapters but used directly + "dbt-common>=0.1.0a1,<2.0", + "agate>=1.0,<2.0", +] + +PSYCOPG2_MESSAGE = """ +No package name override was set. +Using 'psycopg2-binary' package to satisfy 'psycopg2' + +If you experience segmentation faults, silent crashes, or installation errors, +consider retrying with the 'DBT_PSYCOPG2_NAME' environment variable set to +'psycopg2'. It may require a compiler toolchain and development libraries! +""".strip() + + +def _dbt_psycopg2_name(): + # if the user chose something, use that + package_name = os.getenv("DBT_PSYCOPG2_NAME", "") + if package_name: + return package_name + + # default to psycopg2-binary for all OSes/versions + print(PSYCOPG2_MESSAGE) + return "psycopg2-binary" + + +class CustomBuildHook(BuildHookInterface[BuilderConfig]): + """ + Custom build hook to install psycopg2 instead of psycopg2-binary based on the presence of `DBT_PSYCOPG2_NAME` env + var. This is necessary as psycopg2-binary is better for local development, but psycopg2 is better for production. + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + def initialize(self, version: str, build_data: Dict) -> None: + build_data["dependencies"] = BASE_DEPS + psycopg2_pkg_name = _dbt_psycopg2_name() + build_data["dependencies"].append(f"{psycopg2_pkg_name}>=2.9,<3.0") + + +@hookimpl +def hatch_register_build_hook(): + return CustomBuildHook diff --git a/pyproject.toml b/pyproject.toml index 10fd7f7f..e9d880a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -dynamic = ["version"] +dynamic = ["version", "dependencies"] name = "dbt-postgres" description = "The set of adapter protocols and base functionality that supports integration with dbt-core" readme = "README.md" @@ -22,13 +22,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ] -dependencies = [ - "dbt-adapters>=0.1.0a1,<2.0", - "psycopg2>=2.9,<3.0", - # installed via dbt-adapters but used directly - "dbt-common>=0.1.0a1,<2.0", - "agate>=1.0,<2.0", -] + [project.urls] Homepage = "https://github.com/dbt-labs/dbt-postgres" Documentation = "https://docs.getdbt.com" @@ -49,6 +43,9 @@ packages = ["dbt"] [tool.hatch.version] path = "dbt/adapters/postgres/__version__.py" +[tool.hatch.build.hooks.custom] +path = "./hatch_build.py" + [tool.hatch.envs.default] dependencies = [ "dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git", @@ -119,6 +116,8 @@ dependencies = [ "twine", "check-wheel-contents", ] + + [tool.hatch.envs.build.scripts] check-all = [ "- check-wheel", @@ -166,4 +165,4 @@ env_files = ["test.env"] testpaths = [ "tests/functional", "tests/unit", -] +] \ No newline at end of file From 5deb88864861acc5a367d391cfcbc1c207a0d41a Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:53:34 -0400 Subject: [PATCH 4/6] Add `dbt-core~=1.8.0a1` as convenience dep (#44) --- .changes/unreleased/Dependencies-20240403-135902.yaml | 6 ++++++ hatch_build.py | 2 ++ tests/functional/shared_tests/test_query_comment.py | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Dependencies-20240403-135902.yaml diff --git a/.changes/unreleased/Dependencies-20240403-135902.yaml b/.changes/unreleased/Dependencies-20240403-135902.yaml new file mode 100644 index 00000000..126b2178 --- /dev/null +++ b/.changes/unreleased/Dependencies-20240403-135902.yaml @@ -0,0 +1,6 @@ +kind: Dependencies +body: Add `dbt-core` as a dependency to preserve backwards compatibility for installation +time: 2024-04-03T13:59:02.539298-04:00 +custom: + Author: mikealfare + Issue: "44" diff --git a/hatch_build.py b/hatch_build.py index 02693cf0..a44d06c7 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -8,6 +8,8 @@ BASE_DEPS = [ # psycopg2 dependency installed in custom hatch_build.py "dbt-adapters>=0.1.0a1,<2.0", + # add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency + "dbt-core>=1.8.0a1", # installed via dbt-adapters but used directly "dbt-common>=0.1.0a1,<2.0", "agate>=1.0,<2.0", diff --git a/tests/functional/shared_tests/test_query_comment.py b/tests/functional/shared_tests/test_query_comment.py index 30399b24..ea2ddeaf 100644 --- a/tests/functional/shared_tests/test_query_comment.py +++ b/tests/functional/shared_tests/test_query_comment.py @@ -6,6 +6,7 @@ BaseNullQueryComments, BaseEmptyQueryComments, ) +import pytest class TestQueryComments(BaseQueryComments): @@ -17,7 +18,12 @@ class TestMacroQueryComments(BaseMacroQueryComments): class TestMacroArgsQueryComments(BaseMacroArgsQueryComments): - pass + @pytest.mark.skip( + "This test is incorrectly comparing the version of `dbt-core`" + "to the version of `dbt-postgres`, which is not always the same." + ) + def test_matches_comment(self, project, get_package_version): + pass class TestMacroInvalidQueryComments(BaseMacroInvalidQueryComments): From 0b70805f8937a0e74d7076ec51342caa18723c08 Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:13:36 -0400 Subject: [PATCH 5/6] Add version bump workflow (#46) --- .github/workflows/version-bump.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/version-bump.yml diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 00000000..bde34d68 --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,28 @@ +# **what?** +# This workflow will take the new version number to bump to. With that +# it will run versionbump to update the version number everywhere in the +# code base and then run changie to create the corresponding changelog. +# A PR will be created with the changes that can be reviewed before committing. + +# **why?** +# This is to aid in releasing dbt and making sure we have updated +# the version in all places and generated the changelog. + +# **when?** +# This is triggered manually + +name: Version Bump + +on: + workflow_dispatch: + inputs: + version_number: + description: 'The version number to bump to (ex. 1.2.0, 1.3.0b1)' + required: true + +jobs: + version_bump_and_changie: + uses: dbt-labs/actions/.github/workflows/version-bump.yml@main + with: + version_number: ${{ inputs.version_number }} + secrets: inherit # ok since what we are calling is internally maintained From 336d5921fa9f5a62f97306abf1c66873c519bfc9 Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:59:35 -0400 Subject: [PATCH 6/6] Manual version bump (#47) --- .changes/1.8.0-b2.md | 14 ++++++++++++++ .../Dependencies-20240328-133507.yaml | 0 .../Dependencies-20240403-135902.yaml | 0 .../Security-20240327-193942.yaml | 0 .../Under the Hood-20240226-225642.yaml | 0 CHANGELOG.md | 14 +++++++++++++- dbt/adapters/postgres/__version__.py | 2 +- 7 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .changes/1.8.0-b2.md rename .changes/{unreleased => 1.8.0}/Dependencies-20240328-133507.yaml (100%) rename .changes/{unreleased => 1.8.0}/Dependencies-20240403-135902.yaml (100%) rename .changes/{unreleased => 1.8.0}/Security-20240327-193942.yaml (100%) rename .changes/{unreleased => 1.8.0}/Under the Hood-20240226-225642.yaml (100%) diff --git a/.changes/1.8.0-b2.md b/.changes/1.8.0-b2.md new file mode 100644 index 00000000..193206cc --- /dev/null +++ b/.changes/1.8.0-b2.md @@ -0,0 +1,14 @@ +## dbt-postgres 1.8.0-b2 - April 03, 2024 + +### Under the Hood + +* Add unit test for transaction semantics. + +### Dependencies + +* add "no-binary" install option +* Add `dbt-core` as a dependency to preserve backwards compatibility for installation + +### Security + +* Pin `black>=24.3` in `pyproject.toml` diff --git a/.changes/unreleased/Dependencies-20240328-133507.yaml b/.changes/1.8.0/Dependencies-20240328-133507.yaml similarity index 100% rename from .changes/unreleased/Dependencies-20240328-133507.yaml rename to .changes/1.8.0/Dependencies-20240328-133507.yaml diff --git a/.changes/unreleased/Dependencies-20240403-135902.yaml b/.changes/1.8.0/Dependencies-20240403-135902.yaml similarity index 100% rename from .changes/unreleased/Dependencies-20240403-135902.yaml rename to .changes/1.8.0/Dependencies-20240403-135902.yaml diff --git a/.changes/unreleased/Security-20240327-193942.yaml b/.changes/1.8.0/Security-20240327-193942.yaml similarity index 100% rename from .changes/unreleased/Security-20240327-193942.yaml rename to .changes/1.8.0/Security-20240327-193942.yaml diff --git a/.changes/unreleased/Under the Hood-20240226-225642.yaml b/.changes/1.8.0/Under the Hood-20240226-225642.yaml similarity index 100% rename from .changes/unreleased/Under the Hood-20240226-225642.yaml rename to .changes/1.8.0/Under the Hood-20240226-225642.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ca9d33a..29a31234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,5 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## dbt-postgres 1.8.0-b2 - April 03, 2024 -No releases yet, this file will be updated when generating your first release. +### Under the Hood + +* Add unit test for transaction semantics. + +### Dependencies + +* add "no-binary" install option +* Add `dbt-core` as a dependency to preserve backwards compatibility for installation + +### Security + +* Pin `black>=24.3` in `pyproject.toml` diff --git a/dbt/adapters/postgres/__version__.py b/dbt/adapters/postgres/__version__.py index 6496f3e2..7d16c28f 100644 --- a/dbt/adapters/postgres/__version__.py +++ b/dbt/adapters/postgres/__version__.py @@ -1 +1 @@ -version = "1.8.0b1" +version = "1.8.0b2"