Skip to content

Commit

Permalink
Merge branch 'main' into patch-persist_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dataders authored Jun 26, 2024
2 parents 09a15f6 + f21b89c commit 4e60170
Show file tree
Hide file tree
Showing 67 changed files with 868 additions and 7,863 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20240605-202614.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Default to psycopg2-binary and allow overriding to psycopg2 via DBT_PSYCOPG2_NAME
(restores previous behavior)
time: 2024-06-05T20:26:14.801254-04:00
custom:
Author: mikealfare
Issue: "96"
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ updates:
schedule:
interval: "weekly"
rebase-strategy: "disabled"
- package-ecosystem: "docker"
directory: "/docker"
schedule:
interval: "weekly"
rebase-strategy: "disabled"
20 changes: 20 additions & 0 deletions .github/scripts/psycopg2-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
python -m venv venv
source venv/bin/activate
python -m pip install .

if [[ "$PSYCOPG2_WORKAROUND" == true ]]; then
if [[ $(pip show psycopg2-binary) ]]; then
PSYCOPG2_VERSION=$(pip show psycopg2-binary | grep Version | cut -d " " -f 2)
pip uninstall -y psycopg2-binary
pip install psycopg2==$PSYCOPG2_VERSION
fi
fi

PSYCOPG2_NAME=$((pip show psycopg2 || pip show psycopg2-binary) | grep Name | cut -d " " -f 2)
if [[ "$PSYCOPG2_NAME" != "$PSYCOPG2_EXPECTED_NAME" ]]; then
echo -e 'Expected: "$PSYCOPG2_EXPECTED_NAME" but found: "$PSYCOPG2_NAME"'
exit 1
fi
deactivate
rm -r ./venv
29 changes: 29 additions & 0 deletions .github/workflows/changelog-entry-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Changelog entry check

on:
pull_request:
types:
- opened
- reopened
- labeled
- unlabeled
- synchronize

defaults:
run:
shell: bash

permissions:
contents: read
pull-requests: write

jobs:
changelog-entry-check:
uses: dbt-labs/actions/.github/workflows/changelog-existence.yml@main
with:
changelog_comment: >-
Thank you for your pull request! We could not find a changelog entry for this change.
For details on how to document a change, see the
[dbt-postgres contributing guide](https://github.com/dbt-labs/dbt-postgres/blob/main/CONTRIBUTING.md).
skip_label: "Skip Changelog"
secrets: inherit
41 changes: 41 additions & 0 deletions .github/workflows/docs-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# **what?**
# Open an issue in docs.getdbt.com when an issue is labeled `user docs` and closed as completed

# **why?**
# To reduce barriers for keeping docs up to date

# **when?**
# When an issue is labeled `user docs` and is closed as completed. Can be labeled before or after the issue is closed.


name: Open issues in docs.getdbt.com repo when an issue is labeled
run-name: "Open an issue in docs.getdbt.com for issue #${{ github.event.issue.number }}"

on:
issues:
types: [labeled, closed]

defaults:
run:
shell: bash

permissions:
issues: write # comments on issues

jobs:
open_issues:
# we only want to run this when the issue is closed as completed and the label `user docs` has been assigned.
# If this logic does not exist in this workflow, it runs the
# risk of duplicaton of issues being created due to merge and label both triggering this workflow to run and neither having
# generating the comment before the other runs. This lives here instead of the shared workflow because this is where we
# decide if it should run or not.
if: |
(github.event.issue.state == 'closed' && github.event.issue.state_reason == 'completed') && (
(github.event.action == 'closed' && contains(github.event.issue.labels.*.name, 'user docs')) ||
(github.event.action == 'labeled' && github.event.label.name == 'user docs'))
uses: dbt-labs/actions/.github/workflows/open-issue-in-repo.yml@main
with:
issue_repository: "dbt-labs/docs.getdbt.com"
issue_title: "Docs Changes Needed from ${{ github.event.repository.name }} Issue #${{ github.event.issue.number }}"
issue_body: "At a minimum, update body to include a link to the page on docs.getdbt.com requiring updates and what part(s) of the page you would like to see updated."
secrets: inherit
47 changes: 32 additions & 15 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defaults:
jobs:
integration:
name: Integration Tests
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
fail-fast: false
Expand Down Expand Up @@ -102,24 +102,41 @@ jobs:

psycopg2-check:
name: "Test psycopg2 build version"
runs-on: ${{ matrix.scenario.platform }}
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
scenario:
- {platform: ubuntu-latest, psycopg2-name: psycopg2}
- {platform: macos-12, psycopg2-name: psycopg2-binary}
platform: [ubuntu-22.04, macos-12]
python-version: ["3.8", "3.11"]
steps:
- name: "Check out repository"
uses: actions/checkout@v4

- name: "Test psycopg2 name"
run: |
python -m pip install .
PSYCOPG2_PIP_ENTRY=$(pip list | grep "psycopg2 " || pip list | grep psycopg2-binary)
echo $PSYCOPG2_PIP_ENTRY
PSYCOPG2_NAME="${PSYCOPG2_PIP_ENTRY%% *}"
echo $PSYCOPG2_NAME
if [[ "${PSYCOPG2_NAME}" != "${{ matrix.scenario.psycopg2-name }}" ]]; then
exit 1
fi
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: "Test psycopg2 name - default"
run: .github/scripts/psycopg2-check.sh
env:
PSYCOPG2_EXPECTED_NAME: psycopg2-binary

- name: "Test psycopg2 name - invalid override"
run: .github/scripts/psycopg2-check.sh
env:
DBT_PSYCOPG2_NAME: rubber-baby-buggy-bumpers
PSYCOPG2_EXPECTED_NAME: psycopg2-binary

- name: "Test psycopg2 name - override"
run: .github/scripts/psycopg2-check.sh
env:
DBT_PSYCOPG2_NAME: psycopg2
PSYCOPG2_EXPECTED_NAME: psycopg2-binary # we have not implemented the hook yet, so this doesn't work

- name: "Test psycopg2 name - manual override"
# verify that the workaround documented in the `README.md` continues to work
run: .github/scripts/psycopg2-check.sh
env:
PSYCOPG2_WORKAROUND: true
PSYCOPG2_EXPECTED_NAME: psycopg2
11 changes: 6 additions & 5 deletions .github/workflows/release-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ name: "Release internal patch"
on:
workflow_dispatch:
inputs:
version_number:
description: "The release version number (i.e. 1.0.0b1)"
type: string
required: true
ref:
description: "The ref (sha or branch name) to use"
type: string
Expand All @@ -29,6 +25,11 @@ on:
type: string
default: "python -c \"import dbt.adapters.postgres\""
required: true
skip_tests:
description: "Should the tests be skipped? (default to false)"
type: boolean
required: true
default: false

defaults:
run:
Expand All @@ -41,9 +42,9 @@ jobs:
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"
ref: "${{ inputs.ref }}"
skip_tests: "${{ inputs.skip_tests }}"

secrets: "inherit"
115 changes: 83 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,111 @@ name: Release
on:
workflow_dispatch:
inputs:
deploy-to:
type: choice
description: Choose where to publish (test/prod)
options:
- prod
- test
default: prod
ref:
description: "The ref (sha or branch name) to use"
branch:
description: "The branch to release from"
type: string
default: "main"
version:
description: "The version to release"
required: true
type: string
deploy-to:
description: "Deploy to test or prod"
type: environment
default: prod
only_docker:
description: "Only release Docker image, skip GitHub & PyPI"
type: boolean
default: false

permissions: read-all
permissions:
contents: write # this is the permission that allows creating a new release

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}-${{ inputs.deploy-to }}
group: "${{ github.workflow }}-${{ github.event_name }}-${{ inputs.version }}-${{ inputs.deploy-to }}"
cancel-in-progress: true

jobs:
release:
name: PyPI - ${{ inputs.deploy-to }}
runs-on: ubuntu-latest
environment:
name: ${{ inputs.deploy-to }}
url: ${{ vars.PYPI_PROJECT_URL }}
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
release-prep:
name: "Release prep: generate changelog, bump version"
uses: dbt-labs/dbt-postgres/.github/workflows/release_prep_hatch.yml@main
with:
branch: ${{ inputs.branch }}
version: ${{ inputs.version }}
deploy-to: ${{ inputs.deploy-to }}
secrets: inherit

build-release:
name: "Build release"
needs: release-prep
runs-on: ubuntu-latest
outputs:
archive-name: ${{ steps.archive.outputs.name }}
steps:
- name: Check out repository
- name: "Checkout ${{ github.event.repository.name }}@${{ needs.release-prep.outputs.release-branch }}"
uses: actions/checkout@v4
with:
ref: ${{ needs.release-prep.outputs.release-branch }}
persist-credentials: false
ref: "${{ inputs.ref }}"

- name: Setup `hatch`
- name: "Setup `hatch`"
uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main

- name: Inputs
id: release-inputs
- name: "Set archive name"
id: archive
run: |
version=$(hatch version)
archive_name=dbt-postgres-$version-${{ inputs.deploy-to }}
echo "archive-name=$archive_name" >> $GITHUB_OUTPUT
archive_name=${{ github.event.repository.name }}-${{ inputs.version }}-${{ inputs.deploy-to }}
echo "name=$archive_name" >> $GITHUB_OUTPUT
- name: Build `dbt-postgres`
- name: "Build ${{ github.event.repository.name }}"
uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main
with:
archive-name: ${{ steps.release-inputs.outputs.archive-name }}
archive-name: ${{ steps.archive.outputs.name }}

- name: Publish to PyPI
pypi-release:
name: "PyPI release"
if: ${{ !failure() && !cancelled() && !inputs.only_docker }}
runs-on: ubuntu-latest
needs: build-release
environment:
name: ${{ inputs.deploy-to }}
url: ${{ vars.PYPI_PROJECT_URL }}
permissions:
# this permission is required for trusted publishing
# see https://github.com/marketplace/actions/pypi-publish
id-token: write
steps:
- name: "Publish to PyPI"
uses: dbt-labs/dbt-adapters/.github/actions/publish-pypi@main
with:
pypi-repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
archive-name: ${{ steps.release-inputs.outputs.archive-name }}
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
archive-name: ${{ needs.build-release.outputs.archive-name }}

github-release:
name: "GitHub release"
if: ${{ !failure() && !cancelled() && !inputs.only_docker }}
needs:
- build-release
- release-prep
uses: dbt-labs/dbt-adapters/.github/workflows/github-release.yml@main
with:
sha: ${{ needs.release-prep.outputs.release-sha }}
version_number: ${{ inputs.version }}
changelog_path: ${{ needs.release-prep.outputs.changelog-path }}
test_run: ${{ inputs.deploy-to == 'test' }}
archive_name: ${{ needs.build-release.outputs.archive-name }}

docker-release:
name: "Docker release"
# We cannot release to docker on a test run because it uses the tag in GitHub as
# what we need to release but draft releases don't actually tag the commit so it
# finds nothing to release
if: ${{ !failure() && !cancelled() && (inputs.deploy-to == 'prod' || inputs.only_docker) }}
needs: github-release # docker relies on the published tag from github-release
permissions:
packages: write # this permission is required for publishing to GHCR
uses: dbt-labs/dbt-release/.github/workflows/release-docker.yml@main
with:
version_number: ${{ inputs.version }}
test_run: ${{ inputs.deploy-to == 'test' }}
Loading

0 comments on commit 4e60170

Please sign in to comment.