Skip to content

Commit

Permalink
Merge branch 'main' into dbeatty/unknown-data-type-code-8912
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 authored Apr 12, 2024
2 parents 120603e + 336d592 commit 2ed4d49
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .changes/1.8.0-b2.md
Original file line number Diff line number Diff line change
@@ -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`
6 changes: 6 additions & 0 deletions .changes/1.8.0/Dependencies-20240328-133507.yaml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions .changes/1.8.0/Dependencies-20240403-135902.yaml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions .changes/1.8.0/Security-20240327-193942.yaml
Original file line number Diff line number Diff line change
@@ -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"
25 changes: 10 additions & 15 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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"
28 changes: 28 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 1 addition & 1 deletion dbt/adapters/postgres/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.0b1"
version = "1.8.0b2"
56 changes: 56 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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",
# 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",
]

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
19 changes: 9 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -22,13 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git@dbeatty/unknown-data-type-code-8912",
"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"
Expand All @@ -52,6 +46,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@dbeatty/unknown-data-type-code-8912",
Expand All @@ -61,7 +58,7 @@ dependencies = [
[tool.hatch.envs.lint]
detached = true
dependencies = [
"black",
"black>=24.3",
"flake8",
"Flake8-pyproject",
]
Expand Down Expand Up @@ -122,6 +119,8 @@ dependencies = [
"twine",
"check-wheel-contents",
]


[tool.hatch.envs.build.scripts]
check-all = [
"- check-wheel",
Expand Down Expand Up @@ -169,4 +168,4 @@ env_files = ["test.env"]
testpaths = [
"tests/functional",
"tests/unit",
]
]
8 changes: 7 additions & 1 deletion tests/functional/shared_tests/test_query_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
BaseNullQueryComments,
BaseEmptyQueryComments,
)
import pytest


class TestQueryComments(BaseQueryComments):
Expand All @@ -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):
Expand Down

0 comments on commit 2ed4d49

Please sign in to comment.