diff --git a/.github/workflows/_changelog-entry-check.yml b/.github/workflows/_changelog-entry-check.yml new file mode 100644 index 00000000..ddc97290 --- /dev/null +++ b/.github/workflows/_changelog-entry-check.yml @@ -0,0 +1,65 @@ +name: "Changelog entry check" + +# this cannot be tested via workflow_dispatch +# dorny/paths-filter inspects the current trigger to determine how to compare branches +on: + workflow_call: + inputs: + package: + description: "Choose the package to test" + type: string + default: "dbt-adapters" + pull-request: + description: "The PR number" + type: string + required: true + +permissions: + contents: read + pull-requests: write + +jobs: + package: + uses: ./.github/workflows/_package-directory.yml + with: + package: ${{ inputs.package }} + + changelog-check: + needs: package + if: ${{ !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') }} + outputs: + exists: ${{ steps.changelog.outputs.exists }} + runs-on: ${{ vars.DEFAULT_RUNNER }} + steps: + - id: changelog + uses: dorny/paths-filter@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + filters: | + exists: + - added|modified: '${{ needs.package.outputs.directory }}.changes/unreleased/**.yaml' + + comment: + needs: changelog-check + if: needs.changelog-check.outputs.exists == false + runs-on: ${{ vars.DEFAULT_RUNNER }} + env: + AUTHOR: "github-actions[bot]" + COMMENT: >- + Thank you for your pull request! We could not find a changelog entry for this change in the ${{ inputs.package }} package. + For details on how to document a change, see the [Contributing Guide](https://github.com/dbt-labs/dbt-adapters/blob/main/CONTRIBUTING.md). + steps: + - id: comment + uses: peter-evans/find-comment@v3 + with: + issue-number: ${{ inputs.pull-request }} + comment-author: ${{ env.AUTHOR }} + body-includes: ${{ env.COMMENT }} + - if: steps.comment.outputs.comment-body == '' + run: gh issue comment ${{ inputs.pull-request }} --repo ${{ github.repository }} --body "${{ env.COMMENT }}" + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/github-script@v7 + with: + script: core.setFailed('Changelog entry required to merge.') diff --git a/.github/workflows/_code-quality.yml b/.github/workflows/_code-quality.yml new file mode 100644 index 00000000..05d2e6da --- /dev/null +++ b/.github/workflows/_code-quality.yml @@ -0,0 +1,39 @@ +name: "Code quality" + +on: + workflow_call: + inputs: + branch: + description: "Choose the branch to check" + type: string + default: "main" + repository: + description: "Choose the repository to check, when using a fork" + type: string + default: "dbt-labs/dbt-adapters" + workflow_dispatch: + inputs: + branch: + description: "Choose the branch to check" + type: string + default: "main" + repository: + description: "Choose the repository to check, when using a fork" + type: string + default: "dbt-labs/dbt-adapters" + +permissions: + contents: read + +jobs: + code-quality: + runs-on: ${{ vars.DEFAULT_RUNNER }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + repository: ${{ inputs.repository }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ vars.DEFAULT_PYTHON_VERSION }} + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/_generate-changelog.yml b/.github/workflows/_generate-changelog.yml new file mode 100644 index 00000000..37b67bbb --- /dev/null +++ b/.github/workflows/_generate-changelog.yml @@ -0,0 +1,229 @@ +name: "Changelog generation" + +on: + workflow_call: + inputs: + package: + description: "Choose the package getting published" + type: string + default: "dbt-adapters" + merge: + description: "Choose whether to merge the changelog branch" + type: boolean + default: true + branch: + description: "Choose the branch to use" + type: string + default: "main" + outputs: + branch-name: + description: "The SHA to release" + value: ${{ jobs.branch.outputs.name }} + secrets: + FISHTOWN_BOT_PAT: + description: "Token to commit/merge changes into branches" + required: true + IT_TEAM_MEMBERSHIP: + description: "Token that can view org level teams" + required: true + workflow_dispatch: + inputs: + package: + description: "Choose the package getting published" + type: string + default: "dbt-adapters" + merge: + description: "Choose whether to merge the changelog branch" + type: boolean + default: false + branch: + description: "Choose the branch to use" + type: string + default: "main" + secrets: + FISHTOWN_BOT_PAT: + description: "Token to commit/merge changes into branches" + required: true + IT_TEAM_MEMBERSHIP: + description: "Token that can view org level teams" + required: true + +permissions: + contents: write + +defaults: + run: + shell: bash + +jobs: + package: + uses: ./.github/workflows/_package-directory.yml + with: + package: ${{ inputs.package }} + + version: + needs: package + runs-on: ${{ vars.DEFAULT_RUNNER }} + outputs: + raw: ${{ steps.version.outputs.raw }} + base: ${{ steps.semver.outputs.base-version }} + prerelease: ${{ steps.semver.outputs.pre-release }} + is-prerelease: ${{ steps.semver.outputs.is-pre-release }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ vars.DEFAULT_PYTHON_VERSION }} + - uses: pypa/hatch@install + - id: version + run: echo "raw=$(hatch version)" >> $GITHUB_OUTPUT + working-directory: ./${{ needs.package.outputs.directory }} + - id: semver + uses: dbt-labs/actions/parse-semver@v1.1.1 + with: + version: ${{ steps.version.outputs.raw }} + + changelog: + needs: [package, version] + runs-on: ${{ vars.DEFAULT_RUNNER }} + outputs: + path: ${{ steps.changelog.outputs.path }} + exists: ${{ steps.changelog.outputs.exists }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - id: changelog + run: | + path=".changes/${{ needs.version.outputs.base }}" + if [[ ${{ needs.version.outputs.is-prerelease }} -eq 1 ]] + then + path+="-${{ needs.version.outputs.prerelease }}" + fi + path+=".md" + + echo "path=$path" >> $GITHUB_OUTPUT + + exists=false + if test -f $path + then + exists=true + fi + echo "exists=$exists">> $GITHUB_OUTPUT + working-directory: ./${{ needs.package.outputs.directory }} + + temp-branch: + needs: [version, changelog] + if: needs.changelog.outputs.exists == 'false' + runs-on: ${{ vars.DEFAULT_RUNNER }} + outputs: + name: ${{ steps.branch.outputs.name }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - id: branch + run: | + name="prep-release/${{ inputs.package }}/$GITHUB_RUN_ID" + echo "name=$name" >> $GITHUB_OUTPUT + - run: | + git checkout -b ${{ steps.branch.outputs.name }} + git push -u origin ${{ steps.branch.outputs.name }} + + dbt-membership: + needs: [version, changelog] + if: needs.changelog.outputs.exists == 'false' + runs-on: ${{ vars.DEFAULT_RUNNER }} + outputs: + team: ${{ steps.team.outputs.team }} + steps: + - id: temp-file + run: echo "name=output_$GITHUB_RUN_ID.json" >> $GITHUB_OUTPUT + - run: | + gh api -H "Accept: application/vnd.github+json" orgs/dbt-labs/teams/core-group/members > ${{ steps.temp-file.outputs.name }} + env: + GH_TOKEN: ${{ secrets.IT_TEAM_MEMBERSHIP }} + - id: team + run: | + team_list=$(jq -r '.[].login' ${{ steps.temp-file.outputs.name }}) + team_list_single=$(echo $team_list | tr '\n' ' ') + echo "team=$team_list_single" >> $GITHUB_OUTPUT + - run: rm ${{ steps.temp-file.outputs.name }} + + generate-changelog: + needs: [package, version, changelog, temp-branch, dbt-membership] + if: needs.changelog.outputs.exists == 'false' + runs-on: ${{ vars.DEFAULT_RUNNER }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.temp-branch.outputs.name }} + - run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + - run: | + brew install pre-commit + brew tap miniscruff/changie https://github.com/miniscruff/changie + brew install changie + - run: | + if [[ ${{ needs.version.outputs.is-prerelease }} -eq 1 ]] + then + changie batch ${{ needs.version.outputs.base }} --move-dir '${{ needs.version.outputs.base }}' --prerelease ${{ needs.version.outputs.prerelease }} + elif [[ -d ".changes/${{ needs.version.outputs.base }}" ]] + then + changie batch ${{ needs.version.outputs.base }} --include '${{ needs.version.outputs.base }}' --remove-prereleases + else # releasing a final patch with no prereleases + changie batch ${{ needs.version.outputs.base }} + fi + changie merge + working-directory: ./${{ needs.package.outputs.directory }} + env: + CHANGIE_CORE_TEAM: ${{ needs.dbt-membership.outputs.team }} + - run: | + pre-commit run trailing-whitespace --files __version__.py CHANGELOG.md .changes/* + pre-commit run end-of-file-fixer --files __version__.py CHANGELOG.md .changes/* + working-directory: ./${{ needs.package.outputs.directory }} + continue-on-error: true + - run: | + git config user.name "Github Build Bot" + git config user.email "buildbot@fishtownanalytics.com" + git pull + git add . + git commit -m "generate changelog" + git push + working-directory: ./${{ needs.package.outputs.directory }} + + merge-changes: + needs: [temp-branch, generate-changelog] + if: ${{ needs.temp-branch.outputs.name != '' && inputs.merge }} + runs-on: ${{ vars.DEFAULT_RUNNER }} + steps: + - uses: everlytic/branch-merge@1.1.5 + with: + source_ref: ${{ needs.temp-branch.outputs.name }} + target_branch: ${{ inputs.branch }} + github_token: ${{ secrets.FISHTOWN_BOT_PAT }} + commit_message_template: "[Automated] Merged {source_ref} into target {target_branch} during release process" + - run: git push origin -d ${{ needs.temp-branch.outputs.name }} + + branch: + needs: [temp-branch, merge-changes] + if: ${{ !failure() && !cancelled() }} + runs-on: ${{ vars.DEFAULT_RUNNER }} + # always run this job, regardless of whether changelog generation was skipped + # Get the sha that will be released. If the changelog already exists on the input sha and the version has already been bumped, + # then it is what we will release. Otherwise, we generated a changelog and did the version bump in this workflow and there is a + # new sha to use from the merge we just did. Grab that here instead. + outputs: + name: ${{ steps.branch.outputs.name }} + steps: + - id: branch + run: | + branch="" + if [ ${{ needs.temp-branch.outputs.name == '' || inputs.merge }}] + then + branch="${{ inputs.branch }}" + else + branch=${{ needs.temp-branch.outputs.name }} + fi + echo "name=$branch" >> $GITHUB_OUTPUT diff --git a/.github/workflows/_package-directory.yml b/.github/workflows/_package-directory.yml new file mode 100644 index 00000000..d10e9758 --- /dev/null +++ b/.github/workflows/_package-directory.yml @@ -0,0 +1,33 @@ +name: "Package directory" + +on: + workflow_call: + inputs: + package: + description: "Choose the package whose directory you need" + type: string + default: "dbt-adapters" + outputs: + directory: + description: "The root directory of the package" + value: ${{ jobs.package.outputs.directory }} + +defaults: + run: + shell: bash + +jobs: + package: + runs-on: ${{ vars.DEFAULT_RUNNER }} + outputs: + directory: ${{ steps.package.outputs.directory }} + steps: + - id: package + run: | + if [[ ${{ inputs.package }} == "dbt-adapters" ]] + then + directory="" + else + directory="${{ inputs.package }}/" + fi + echo "directory=$directory" >> $GITHUB_OUTPUT diff --git a/.github/workflows/_publish-internal.yml b/.github/workflows/_publish-internal.yml new file mode 100644 index 00000000..42fb6290 --- /dev/null +++ b/.github/workflows/_publish-internal.yml @@ -0,0 +1,106 @@ +name: "Publish internally" + +on: + workflow_call: + inputs: + package: + description: "Choose the package to publish" + type: string + default: "dbt-adapters" + deploy-to: + description: "Choose whether to publish to test or prod" + type: string + default: "prod" + branch: + description: "Choose the branch to publish" + type: string + default: "main" + workflow_dispatch: + inputs: + package: + description: "Choose the package to publish" + type: choice + options: ["dbt-adapters"] + deploy-to: + description: "Choose whether to publish to test or prod" + type: environment + default: "test" + branch: + description: "Choose the branch to publish" + type: string + default: "main" + +defaults: + run: + shell: bash + +jobs: + package: + uses: ./.github/workflows/_package-directory.yml + with: + package: ${{ inputs.package }} + + publish: + needs: package + runs-on: ${{ vars.DEFAULT_RUNNER }} + environment: + name: ${{ inputs.deploy-to }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ vars.DEFAULT_PYTHON_VERSION }} + - uses: pypa/hatch@install + - uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ vars.AWS_REGION }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - id: package + run: | + # strip the pre-release off to find all iterations of this patch + hatch version release + echo "version=$(hatch version)" >> $GITHUB_OUTPUT + working-directory: ./${{ needs.package.outputs.directory }} + - id: published + run: | + versions_published="$(aws codeartifact list-package-versions \ + --domain ${{ vars.AWS_DOMAIN }} \ + --repository ${{ vars.AWS_REPOSITORY }} \ + --format pypi \ + --package ${{ inputs.package }} \ + --output json \ + --query 'versions[*].version' | jq -r '.[]' | grep "^${{ steps.package.outputs.version }}" || true )" # suppress pipefail only here + echo "versions=$(echo "${versions_published[*]}"| tr '\n' ',')" >> $GITHUB_OUTPUT + - id: next + uses: dbt-labs/dbt-release/.github/actions/next-cloud-release-version@main + with: + version_number: ${{ steps.package.outputs.version }} + versions_published: ${{ steps.published.outputs.versions }} + - run: | + VERSION=${{ steps.next.outputs.internal_release_version }}+$(git rev-parse HEAD) + tee <<< "version = \"$VERSION\"" ./src/dbt/adapters/$(cut -c 5- ${{ inputs.package }})/__version__.py + working-directory: ./${{ needs.package.outputs.directory }} + - run: sed -i "/dbt-core[<>~=]/d" ./pyproject.toml + working-directory: ./${{ needs.package.outputs.directory }} + - run: | + export HATCH_INDEX_USER=${{ secrets.AWS_USER }} + + export HATCH_INDEX_AUTH=$(aws codeartifact get-authorization-token \ + --domain ${{ vars.AWS_DOMAIN }} \ + --output text \ + --query authorizationToken) + + export HATCH_INDEX_REPO=$(aws codeartifact get-repository-endpoint \ + --domain ${{ vars.AWS_DOMAIN }} \ + --repository ${{ vars.AWS_REPOSITORY }} \ + --format pypi \ + --output text \ + --query repositoryEndpoint) + + hatch build --clean + hatch run build:check-all + hatch publish + working-directory: ./${{ needs.package.outputs.directory }} diff --git a/.github/workflows/_publish-pypi.yml b/.github/workflows/_publish-pypi.yml new file mode 100644 index 00000000..f05b1fd6 --- /dev/null +++ b/.github/workflows/_publish-pypi.yml @@ -0,0 +1,91 @@ +name: "Publish to PyPI" + +on: + workflow_call: + inputs: + package: + description: "Choose the package to publish" + type: string + default: "dbt-adapters" + deploy-to: + description: "Choose whether to publish to test or prod" + type: string + default: "prod" + branch: + description: "Choose the branch to publish" + type: string + default: "main" + workflow_dispatch: + inputs: + package: + description: "Choose the package to publish" + type: choice + options: ["dbt-adapters"] + deploy-to: + description: "Choose whether to publish to test or prod" + type: environment + default: "test" + branch: + description: "Choose the branch to publish" + type: string + default: "main" + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + package: + uses: ./.github/workflows/_package-directory.yml + with: + package: ${{ inputs.package }} + + publish: + needs: package + runs-on: ${{ vars.DEFAULT_RUNNER }} + environment: + name: ${{ inputs.deploy-to }} + url: ${{ vars.PYPI_PROJECT_URL }}/${{ inputs.package }} + permissions: + # this permission is required for trusted publishing + # see https://github.com/marketplace/actions/pypi-publish + id-token: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ vars.DEFAULT_PYTHON_VERSION }} + - uses: pypa/hatch@install + # hatch will build using test PyPI first and fall back to prod PyPI when deploying to test + # this is done via environment variables in the test environment in GitHub + - run: hatch build && hatch run build:check-all + working-directory: ./${{ needs.package.outputs.directory }} + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: ${{ vars.PYPI_REPOSITORY_URL }} + packages-dir: ./${{ needs.package.outputs.directory }}dist/ + + verify: + runs-on: ${{ vars.DEFAULT_RUNNER }} + needs: [package, publish] + # check the correct index + environment: + name: ${{ inputs.deploy-to }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - id: version + run: echo "version=$(hatch version)" >> $GITHUB_OUTPUT + working-directory: ./${{ needs.package.outputs.directory }} + - uses: nick-fields/retry@v3 + with: + timeout_seconds: 10 + retry_wait_seconds: 10 + max_attempts: 15 # 5 minutes: (10s timeout + 10s delay) * 15 attempts + command: wget ${{ vars.PYPI_PROJECT_URL }}/${{ inputs.package }}/${{ steps.version.outputs.version }} diff --git a/.github/workflows/_unit-tests.yml b/.github/workflows/_unit-tests.yml new file mode 100644 index 00000000..0c0a8215 --- /dev/null +++ b/.github/workflows/_unit-tests.yml @@ -0,0 +1,72 @@ +name: "Unit tests" + +on: + workflow_call: + inputs: + package: + description: "Choose the package to test" + type: string + default: "dbt-adapters" + branch: + description: "Choose the branch to test" + type: string + default: "main" + repository: + description: "Choose the repository to test, when using a fork" + type: string + default: "dbt-labs/dbt-adapters" + os: + description: "Choose the OS to test against" + type: string + default: "ubuntu-22.04" + python-version: + description: "Choose the Python version to test against" + type: string + default: 3.9 + workflow_dispatch: + inputs: + package: + description: "Choose the package to test" + type: choice + options: ["dbt-adapters"] + branch: + description: "Choose the branch to test" + type: string + default: "main" + repository: + description: "Choose the repository to test, when using a fork" + type: string + default: "dbt-labs/dbt-adapters" + os: + description: "Choose the OS to test against" + type: string + default: "ubuntu-22.04" + python-version: + description: "Choose the Python version to test against" + type: choice + options: ["3.9", "3.10", "3.11", "3.12"] + +permissions: + contents: read + +jobs: + package: + uses: ./.github/workflows/_package-directory.yml + with: + package: ${{ inputs.package }} + + unit-tests: + needs: package + runs-on: ${{ inputs.os }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + repository: ${{ inputs.repository }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + - uses: pypa/hatch@install + - run: hatch run unit-tests + shell: bash + working-directory: ./${{ needs.package.outputs.directory }} diff --git a/.github/workflows/_verify-build.yml b/.github/workflows/_verify-build.yml new file mode 100644 index 00000000..f667b600 --- /dev/null +++ b/.github/workflows/_verify-build.yml @@ -0,0 +1,73 @@ +name: "Verify build" + +on: + workflow_call: + inputs: + package: + description: "Choose the package to build" + type: string + default: "dbt-adapters" + branch: + description: "Choose the branch to build" + type: string + default: "main" + repository: + description: "Choose the repository to build, (used primarily when testing a fork)" + type: string + default: "dbt-labs/dbt-adapters" + os: + description: "Choose the OS to test against" + type: string + default: "ubuntu-22.04" + python-version: + description: "Choose the Python version to test against" + type: string + default: "3.9" + workflow_dispatch: + inputs: + package: + description: "Choose the package to build" + type: choice + options: + - "dbt-adapters" + - "dbt-tests-adapter" + branch: + description: "Choose the branch to build" + type: string + default: "main" + repository: + description: "Choose the repository to build, (used primarily when testing a fork)" + type: string + default: "dbt-labs/dbt-adapters" + os: + description: "Choose the OS to test against" + type: string + default: "ubuntu-22.04" + python-version: + description: "Choose the Python version to test against" + type: choice + options: ["3.9", "3.10", "3.11", "3.12"] + +permissions: read-all + +jobs: + package: + uses: ./.github/workflows/_package-directory.yml + with: + package: ${{ inputs.package }} + + build: + needs: package + runs-on: ${{ inputs.os }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + repository: ${{ inputs.repository }} + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + - uses: pypa/hatch@install + - run: hatch build && hatch run build:check-all + shell: bash + working-directory: ./${{ needs.package.outputs.directory }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 00afd704..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,54 +0,0 @@ -# **what?** -# Verifies python build on all code commited to the repository. This workflow -# should not require any secrets since it runs for PRs from forked repos. By -# default, secrets are not passed to workflows running from a forked repos. - -# **why?** -# Ensure code for dbt meets a certain quality standard. - -# **when?** -# This will run for all PRs, when code is pushed to main, and when manually triggered. - -name: "Build" - -on: - push: - branches: - - "main" - pull_request: - merge_group: - types: [checks_requested] - workflow_dispatch: - workflow_call: - -permissions: read-all - -# 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 }} - cancel-in-progress: true - -defaults: - run: - shell: bash - -jobs: - build: - name: Build, Test and publish to PyPi - runs-on: ubuntu-latest - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - steps: - - name: "Check out repository" - uses: actions/checkout@v4 - - - name: Setup `hatch` - uses: ./.github/actions/setup-hatch - - - name: Build `dbt-adapters` - uses: ./.github/actions/build-hatch - - - name: Build `dbt-tests-adapter` - uses: ./.github/actions/build-hatch - with: - working-dir: "./dbt-tests-adapter/" diff --git a/.github/workflows/changelog-existence.yml b/.github/workflows/changelog-existence.yml deleted file mode 100644 index 8732177f..00000000 --- a/.github/workflows/changelog-existence.yml +++ /dev/null @@ -1,37 +0,0 @@ -# **what?** -# Checks that a file has been committed under the /.changes directory -# as a new CHANGELOG entry. Cannot check for a specific filename as -# it is dynamically generated by change type and timestamp. -# This workflow runs on pull_request_target because it requires -# secrets to post comments. - -# **why?** -# Ensure code change gets reflected in the CHANGELOG. - -# **when?** -# This will run for all PRs going into main. It will -# run when they are opened, reopened, when any label is added or removed -# and when new code is pushed to the branch. The action will get -# skipped if the 'Skip Changelog' label is present is any of the labels. - -name: Check Changelog Entry - -on: - pull_request_target: - types: [opened, reopened, labeled, unlabeled, synchronize] - -defaults: - run: - shell: bash - -permissions: - contents: read - pull-requests: write - -jobs: - changelog: - 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 contributing guide](https://github.com/dbt-labs/dbt-adapters/blob/main/CONTRIBUTING.md#adding-changelog-entry).' - skip_label: 'Skip Changelog' - secrets: inherit diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml deleted file mode 100644 index 9c203847..00000000 --- a/.github/workflows/code-quality.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Code Quality - -on: - push: - branches: - - "main" - - "*.latest" - pull_request: - workflow_dispatch: - -permissions: read-all - -# 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 }} - cancel-in-progress: true - -jobs: - code-quality: - name: Code Quality - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup `hatch` - uses: ./.github/actions/setup-hatch - - - name: Run code quality - shell: bash - run: hatch run code-quality diff --git a/.github/workflows/docs-issue.yml b/.github/workflows/docs-issue.yml deleted file mode 100644 index f49cf517..00000000 --- a/.github/workflows/docs-issue.yml +++ /dev/null @@ -1,41 +0,0 @@ -# **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 diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml deleted file mode 100644 index ad0cc2d8..00000000 --- a/.github/workflows/github-release.yml +++ /dev/null @@ -1,259 +0,0 @@ -# **what?** -# Create a new release on GitHub and include any artifacts in the `/dist` directory of the GitHub artifacts store. -# -# Inputs: -# sha: The commit to attach to this release -# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) -# changelog_path: Path to the changelog file for release notes -# test_run: Test run (Publish release as draft) -# -# **why?** -# Reusable and consistent GitHub release process. -# -# **when?** -# Call after a successful build. Build artifacts should be ready to release and live in a dist/ directory. -# -# This workflow expects the artifacts to already be built and living in the artifact store of the workflow. -# -# Validation Checks -# -# 1. If no release already exists for this commit and version, create the tag and release it to GitHub. -# 2. If a release already exists for this commit, skip creating the release but finish with a success. -# 3. If a release exists for this commit under a different tag, fail. -# 4. If the commit is already associated with a different release, fail. - -name: GitHub Release - -on: - workflow_call: - inputs: - sha: - description: The commit to attach to this release - required: true - type: string - version_number: - description: The release version number (i.e. 1.0.0b1) - required: true - type: string - changelog_path: - description: Path to the changelog file for release notes - required: true - type: string - test_run: - description: Test run (Publish release as draft) - required: true - type: boolean - archive_name: - description: artifact name to download - required: true - type: string - outputs: - tag: - description: The path to the changelog for this version - value: ${{ jobs.check-release-exists.outputs.tag }} - -permissions: - contents: write - -env: - REPO_LINK: ${{ github.server_url }}/${{ github.repository }} - NOTIFICATION_PREFIX: "[GitHub Release]" - -jobs: - log-inputs: - runs-on: ubuntu-latest - steps: - - name: "[DEBUG] Print Variables" - run: | - echo The last commit sha in the release: ${{ inputs.sha }} - echo The release version number: ${{ inputs.version_number }} - echo Expected Changelog path: ${{ inputs.changelog_path }} - echo Test run: ${{ inputs.test_run }} - echo Repo link: ${{ env.REPO_LINK }} - echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} - - check-release-exists: - runs-on: ubuntu-latest - outputs: - exists: ${{ steps.release_check.outputs.exists }} - draft_exists: ${{ steps.release_check.outputs.draft_exists }} - tag: ${{ steps.set_tag.outputs.tag }} - - steps: - - name: "Generate Release Tag" - id: set_tag - run: echo "tag=v${{ inputs.version_number }}" >> $GITHUB_OUTPUT - - # When the GitHub CLI doesn't find a release for the given tag, it will exit 1 with a - # message of "release not found". In our case, it's not an actual error, just a - # confirmation that the release does not already exists so we can go ahead and create it. - # The `|| true` makes it so the step does not exit with a non-zero exit code - # Also check if the release already exists is draft state. If it does, and we are not - # testing then we can publish that draft as is. If it's in draft and we are testing, skip the - # release. - - name: "Check If Release Exists For Tag ${{ steps.set_tag.outputs.tag }}" - id: release_check - run: | - output=$((gh release view ${{ steps.set_tag.outputs.tag }} --json isDraft,targetCommitish --repo ${{ env.REPO_LINK }}) 2>&1) || true - if [[ "$output" == "release not found" ]] - then - title="Release for tag ${{ steps.set_tag.outputs.tag }} does not exist." - message="Check passed." - echo "exists=false" >> $GITHUB_OUTPUT - echo "draft_exists=false" >> $GITHUB_OUTPUT - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 0 - fi - commit=$(jq -r '.targetCommitish' <<< "$output") - if [[ $commit != ${{ inputs.sha }} ]] - then - title="Release for tag ${{ steps.set_tag.outputs.tag }} already exists for commit $commit!" - message="Cannot create a new release for commit ${{ inputs.sha }}. Exiting." - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - fi - isDraft=$(jq -r '.isDraft' <<< "$output") - if [[ $isDraft == true ]] && [[ ${{ inputs.test_run }} == false ]] - then - title="Release tag ${{ steps.set_tag.outputs.tag }} already associated with the draft release." - message="Release workflow will publish the associated release." - echo "exists=false" >> $GITHUB_OUTPUT - echo "draft_exists=true" >> $GITHUB_OUTPUT - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 0 - fi - title="Release for tag ${{ steps.set_tag.outputs.tag }} already exists." - message="Skip GitHub Release Publishing." - echo "exists=true" >> $GITHUB_OUTPUT - echo "draft_exists=false" >> $GITHUB_OUTPUT - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ env.REPO_LINK }} - - - name: "[DEBUG] Log Job Outputs" - run: | - echo exists: ${{ steps.release_check.outputs.exists }} - echo draft_exists: ${{ steps.release_check.outputs.draft_exists }} - echo tag: ${{ steps.set_tag.outputs.tag }} - - skip-github-release: - runs-on: ubuntu-latest - needs: [check-release-exists] - if: needs.check-release-exists.outputs.exists == 'true' - - steps: - - name: "Tag Exists, Skip GitHub Release Job" - run: | - echo title="A tag already exists for ${{ needs.check-release-exists.outputs.tag }} and commit." - echo message="Skipping GitHub release." - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - audit-release-different-commit: - runs-on: ubuntu-latest - needs: [check-release-exists] - if: needs.check-release-exists.outputs.exists == 'false' - - steps: - - name: "Check If Release Already Exists For Commit" - uses: cardinalby/git-get-release-action@1.2.4 - id: check_release_commit - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - commitSha: ${{ inputs.sha }} - doNotFailIfNotFound: true # returns blank outputs when not found instead of error - searchLimit: 15 # Since we only care about recent releases, speed up the process - - - name: "[DEBUG] Print Release Details" - run: | - echo steps.check_release_commit.outputs.id: ${{ steps.check_release_commit.outputs.id }} - echo steps.check_release_commit.outputs.tag_name: ${{ steps.check_release_commit.outputs.tag_name }} - echo steps.check_release_commit.outputs.target_commitish: ${{ steps.check_release_commit.outputs.target_commitish }} - echo steps.check_release_commit.outputs.prerelease: ${{ steps.check_release_commit.outputs.prerelease }} - - # Since we already know a release for this tag does not exist, if we find anything it's for the wrong tag, exit - - name: "Check If The Tag Matches The Version Number" - if: steps.check_release_commit.outputs.id != '' - run: | - title="Tag ${{ steps.check_release_commit.outputs.tag_name }} already exists for this commit!" - message="Cannot create a new tag for ${{ needs.check-release-exists.outputs.tag }} for the same commit" - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - - publish-draft-release: - runs-on: ubuntu-latest - needs: [check-release-exists, audit-release-different-commit] - if: >- - needs.check-release-exists.outputs.draft_exists == 'true' && - inputs.test_run == false - - steps: - - name: "Publish Draft Release - ${{ needs.check-release-exists.outputs.tag }}" - run: | - gh release edit $TAG --draft=false --repo ${{ env.REPO_LINK }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ needs.check-release-exists.outputs.tag }} - - create-github-release: - runs-on: ubuntu-latest - needs: [check-release-exists, audit-release-different-commit] - if: needs.check-release-exists.outputs.draft_exists == 'false' - - steps: - - name: "Check out repository" - uses: actions/checkout@v4 - with: - ref: ${{ inputs.sha }} - - - name: "Download Artifact ${{ inputs.archive_name }}" - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.archive_name }} - path: dist/ - - - name: "[DEBUG] Display Structure Of Expected Files" - run: | - ls -R .changes - ls -l dist - - - name: "Set Release Type" - id: release_type - run: | - if ${{ contains(inputs.version_number, 'rc') || contains(inputs.version_number, 'b') }} - then - echo Release will be set as pre-release - echo "prerelease=--prerelease" >> $GITHUB_OUTPUT - else - echo This is not a prerelease - fi - - - name: "Set As Draft Release" - id: draft - run: | - if [[ ${{ inputs.test_run }} == true ]] - then - echo Release will be published as draft - echo "draft=--draft" >> $GITHUB_OUTPUT - else - echo This is not a draft release - fi - - - name: "GitHub Release Workflow Annotation" - run: | - title="Release ${{ needs.check-release-exists.outputs.tag }}" - message="Configuration: ${{ steps.release_type.outputs.prerelease }} ${{ steps.draft.outputs.draft }}" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - - name: "Create New GitHub Release - ${{ needs.check-release-exists.outputs.tag }}" - run: | - gh release create $TAG ./dist/* --title "$TITLE" --notes-file $RELEASE_NOTES --target $COMMIT $PRERELEASE $DRAFT --repo ${{ env.REPO_LINK }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ needs.check-release-exists.outputs.tag }} - TITLE: ${{ github.event.repository.name }} ${{ needs.check-release-exists.outputs.tag }} - RELEASE_NOTES: ${{ inputs.changelog_path }} - COMMIT: ${{ inputs.sha }} - PRERELEASE: ${{ steps.release_type.outputs.prerelease }} - DRAFT: ${{ steps.draft.outputs.draft }} diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml new file mode 100644 index 00000000..7903a732 --- /dev/null +++ b/.github/workflows/issue-triage.yml @@ -0,0 +1,20 @@ +name: "Issue triage" +run-name: "Issue triage - #${{ github.event.issue.number }}: ${{ github.event.issue.title }} - ${{ github.actor }}" + +on: issue_comment + +defaults: + run: + shell: bash + +permissions: + issues: write + +jobs: + triage: + if: contains(github.event.issue.labels.*.name, 'triage:awaiting-response') + uses: dbt-labs/actions/.github/workflows/swap-labels.yml@main + with: + add_label: "triage:dbt" + remove_label: "triage:awaiting-response" + secrets: inherit diff --git a/.github/workflows/precommit-autoupdate.yml b/.github/workflows/precommit-autoupdate.yml deleted file mode 100644 index 74976c48..00000000 --- a/.github/workflows/precommit-autoupdate.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: "Run pre-commit autoupdate" - -on: - schedule: - - cron: "30 1 * * SAT" - workflow_dispatch: - -permissions: - contents: write - -concurrency: - group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.sha }} - cancel-in-progress: true - -jobs: - precommit-autoupdate: - name: "Run pre-commit autoupdate" - uses: dbt-labs/actions/.github/workflows/pre-commit-autoupdate.yml - secrets: - TOKEN: ${{ secrets.FISHTOWN_BOT_PAT }} - SLACK_WEBHOOK_PR_URL: ${{ secrets.SLACK_DEV_ADAPTER_PULL_REQUESTS }} - SLACK_WEBHOOK_ALERTS_URL: ${{ secrets.SLACK_DEV_ADAPTER_ALERTS }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..04a14545 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,68 @@ +name: "Publish" +run-name: "Publish - ${{ inputs.package }} - ${{ inputs.deploy-to }} - ${{ github.actor }}" + +on: + workflow_dispatch: + inputs: + package: + description: "Choose the package to publish" + type: choice + options: + - "dbt-adapters" + - "dbt-tests-adapter" + deploy-to: + description: "Choose whether to publish to test or prod" + type: environment + default: "prod" + branch: + description: "Choose the branch to publish from" + type: string + default: "main" + pypi-internal: + description: "Publish Internally" + type: boolean + default: true + pypi-public: + description: "Publish to PyPI" + type: boolean + default: false + +# don't publish to the same target in parallel +concurrency: + group: ${{ github.workflow }}-${{ inputs.package }}-${{ inputs.deploy-to }} + cancel-in-progress: true + +jobs: + unit-tests: + uses: ./.github/workflows/_unit-tests.yml + with: + package: ${{ inputs.package }} + branch: ${{ inputs.branch }} + + generate-changelog: + needs: unit-tests + uses: ./.github/workflows/_generate-changelog.yml + with: + package: ${{ inputs.package }} + merge: ${{ inputs.deploy-to == 'prod' }} + branch: ${{ inputs.branch }} + secrets: inherit + + publish-internal: + if: ${{ inputs.pypi-internal == true }} + needs: generate-changelog + uses: ./.github/workflows/_publish-internal.yml + with: + package: ${{ inputs.package }} + deploy-to: ${{ inputs.deploy-to }} + branch: ${{ needs.generate-changelog.outputs.branch-name }} + secrets: inherit + + publish-pypi: + if: ${{ inputs.pypi-public == true }} + needs: generate-changelog + uses: ./.github/workflows/_publish-pypi.yml + with: + package: ${{ inputs.package }} + deploy-to: ${{ inputs.deploy-to }} + branch: ${{ needs.generate-changelog.outputs.branch-name }} diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml new file mode 100644 index 00000000..0fd958ee --- /dev/null +++ b/.github/workflows/pull-request-checks.yml @@ -0,0 +1,58 @@ +name: "Pull request checks" +run-name: "Publish - #${{ github.event.number }} - ${{ github.actor }}" + +on: + pull_request_target: + types: [opened, reopened, synchronize, labeled, unlabeled] + +# only run this once per PR at a time +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true + +jobs: + changelog-entry: + uses: ./.github/workflows/_changelog-entry-check.yml + with: + pull-request: ${{ github.event.pull_request.number }} + + code-quality: + uses: ./.github/workflows/_code-quality.yml + with: + branch: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + verify-builds: + uses: ./.github/workflows/_verify-build.yml + strategy: + matrix: + package: ["dbt-adapters", "dbt-tests-adapter"] + python-version: ["3.9", "3.10", "3.11", "3.12"] + with: + package: ${{ matrix.package }} + branch: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + python-version: ${{ matrix.python-version }} + + unit-tests: + uses: ./.github/workflows/_unit-tests.yml + strategy: + matrix: + package: ["dbt-adapters"] + python-version: ["3.9", "3.10", "3.11", "3.12"] + with: + package: ${{ matrix.package }} + branch: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + # This job does nothing and is only used for branch protection + results: + name: "Pull request checks" # keep this name, branch protection references it + if: always() + needs: [changelog-entry, code-quality, verify-builds, unit-tests] + runs-on: ${{ vars.DEFAULT_RUNNER }} + steps: + - uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + allowed-skips: 'changelog-entry' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 828350dd..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,180 +0,0 @@ -name: Release -run-name: Release ${{ inputs.package }}==${{ inputs.version_number }} to ${{ inputs.deploy-to }} - -on: - workflow_dispatch: - inputs: - package: - type: choice - description: Choose what to publish - options: - - dbt-adapters - - dbt-tests-adapter - version_number: - description: "The release version number (i.e. 1.0.0b1)" - type: string - required: true - deploy-to: - type: choice - description: Choose where to publish - options: - - prod - - test - default: prod - nightly_release: - description: "Nightly release to dev environment" - type: boolean - default: false - required: false - target_branch: - description: "The branch to release from" - type: string - required: false - default: main - - workflow_call: - inputs: - package: - type: string - description: Choose what to publish - required: true - version_number: - description: "The release version number (i.e. 1.0.0b1)" - type: string - required: true - deploy-to: - type: string - default: prod - required: false - nightly_release: - description: "Nightly release to dev environment" - type: boolean - default: false - required: false - target_branch: - description: "The branch to release from" - type: string - required: false - default: main - -# this is the permission that allows creating a new release -permissions: - contents: write - id-token: write - -# 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.package }}-${{ inputs.deploy-to }} - cancel-in-progress: true - -defaults: - run: - 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: [release-inputs, bump-version-generate-changelog] - runs-on: ubuntu-latest - steps: - - name: Print variables - run: | - echo Final SHA : ${{ needs.bump-version-generate-changelog.outputs.final_sha }} - echo Changelog path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} - - build-and-test: - name: "Build and Test" - needs: [release-inputs, bump-version-generate-changelog] - runs-on: ubuntu-latest - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - steps: - - name: "Check out repository" - uses: actions/checkout@v4 - with: - ref: ${{ needs.bump-version-generate-changelog.outputs.final_sha }} - - - name: "Setup `hatch`" - uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main - - - name: "Build ${{ inputs.package }}" - uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main - with: - 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-adapters assets to the same release - if: ${{ !failure() && !cancelled() && inputs.package == 'dbt-adapters' }} - 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: ${{ needs.release-inputs.outputs.archive-name }} - - pypi-release: - name: "Publish to PyPI" - runs-on: ubuntu-latest - needs: [release-inputs, build-and-test] - environment: - name: ${{ inputs.deploy-to }} - url: ${{ vars.PYPI_PROJECT_URL }} - steps: - - name: "Check out repository" - uses: actions/checkout@v4 - - - name: "Publish to PyPI" - uses: dbt-labs/dbt-adapters/.github/actions/publish-pypi@main - with: - repository-url: ${{ vars.PYPI_REPOSITORY_URL }} - archive-name: ${{ needs.release-inputs.outputs.archive-name }} diff --git a/.github/workflows/release_prep_hatch.yml b/.github/workflows/release_prep_hatch.yml deleted file mode 100644 index a6105786..00000000 --- a/.github/workflows/release_prep_hatch.yml +++ /dev/null @@ -1,542 +0,0 @@ -# **what?** -# Perform the version bump, generate the changelog and run tests. -# -# Inputs: -# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) -# target_branch: The branch that we will release from -# env_setup_script_path: Path to the environment setup script -# deploy_to: If we are deploying to prod or test, if test then release from branch -# nightly_release: Identifier that this is nightly release -# -# Outputs: -# final_sha: The sha that will actually be released. This can differ from the -# input sha if adding a version bump and/or changelog -# changelog_path: Path to the changelog file (ex .changes/1.2.3-rc1.md) -# -# Branching strategy: -# - During execution workflow execution the temp branch will be generated. -# - For normal runs the temp branch will be removed once changes were merged to target branch; -# - For test runs we will keep temp branch and will use it for release; -# Naming strategy: -# - For normal runs: prep-release/${{ inputs.deploy_to}}/${{ inputs.version_number }}_$GITHUB_RUN_ID -# - For nightly releases: prep-release/nightly-release/${{ inputs.version_number }}_$GITHUB_RUN_ID -# -# **why?** -# Reusable and consistent GitHub release process. -# -# **when?** -# Call when ready to kick off a build and release -# -# Validation Checks -# -# 1. Bump the version if it has not been bumped -# 2. Generate the changelog (via changie) if there is no markdown file for this version -# - -name: Version Bump and Changelog Generation -run-name: Bump to ${{ inputs.version_number }} for release to ${{ inputs.deploy_to }} and generate changelog -on: - workflow_call: - inputs: - version_number: - required: true - type: string - deploy_to: - type: string - default: prod - required: false - nightly_release: - type: boolean - default: false - required: false - env_setup_script_path: - type: string - required: false - default: '' - run-unit-tests: - type: boolean - default: false - run-integration-tests: - type: boolean - default: false - target_branch: - description: "The branch to release from" - 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 - value: ${{ jobs.audit-changelog.outputs.changelog_path }} - final_sha: - description: The sha that will actually be released - value: ${{ jobs.determine-release-branch.outputs.final_sha }} - secrets: - FISHTOWN_BOT_PAT: - description: "Token to commit/merge changes into branches" - required: true - IT_TEAM_MEMBERSHIP: - description: "Token that can view org level teams" - required: true - -permissions: - contents: write - -defaults: - run: - shell: bash - -env: - PYTHON_TARGET_VERSION: 3.11 - NOTIFICATION_PREFIX: "[Release Preparation]" - -jobs: - log-inputs: - runs-on: ubuntu-latest - - steps: - - name: "[DEBUG] Print Variables" - run: | - # WORKFLOW INPUTS - echo The release version number: ${{ inputs.version_number }} - echo Deploy to: ${{ inputs.deploy_to }} - 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 }} - audit-changelog: - runs-on: ubuntu-latest - - outputs: - changelog_path: ${{ steps.set_path.outputs.changelog_path }} - exists: ${{ steps.set_existence.outputs.exists }} - base_version: ${{ steps.semver.outputs.base-version }} - prerelease: ${{ steps.semver.outputs.pre-release }} - is_prerelease: ${{ steps.semver.outputs.is-pre-release }} - - steps: - - name: "Checkout ${{ github.repository }}" - uses: actions/checkout@v4 - with: - ref: ${{ inputs.target_branch }} - - - name: "Audit Version And Parse Into Parts" - id: semver - uses: dbt-labs/actions/parse-semver@v1.1.1 - with: - version: ${{ inputs.version_number }} - - - name: "Set Changelog Path" - id: set_path - run: | - path=".changes/" - if [[ ${{ steps.semver.outputs.is-pre-release }} -eq 1 ]] - then - path+="${{ steps.semver.outputs.base-version }}-${{ steps.semver.outputs.pre-release }}.md" - else - path+="${{ steps.semver.outputs.base-version }}.md" - fi - # Send notification - echo "changelog_path=$path" >> $GITHUB_OUTPUT - title="Changelog path" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$changelog_path" - - name: "Set Changelog Existence For Subsequent Jobs" - id: set_existence - run: | - does_exist=false - if test -f ${{ steps.set_path.outputs.changelog_path }} - then - does_exist=true - fi - echo "exists=$does_exist">> $GITHUB_OUTPUT - - name: "[Notification] Set Changelog Existence For Subsequent Jobs" - run: | - title="Changelog exists" - if [[ ${{ steps.set_existence.outputs.exists }} == true ]] - then - message="Changelog file ${{ steps.set_path.outputs.changelog_path }} already exists" - else - message="Changelog file ${{ steps.set_path.outputs.changelog_path }} doesn't exist" - fi - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - name: "[DEBUG] Print Outputs" - run: | - echo changelog_path: ${{ steps.set_path.outputs.changelog_path }} - echo exists: ${{ steps.set_existence.outputs.exists }} - echo base_version: ${{ steps.semver.outputs.base-version }} - echo prerelease: ${{ steps.semver.outputs.pre-release }} - echo is_prerelease: ${{ steps.semver.outputs.is-pre-release }} - - audit-version-in-code: - runs-on: ubuntu-latest - - outputs: - up_to_date: ${{ steps.version-check.outputs.up_to_date }} - - steps: - - name: "Checkout ${{ github.repository }} Branch ${{ inputs.target_branch }}" - uses: actions/checkout@v4 - with: - ref: ${{ inputs.target_branch }} - - - name: Setup `hatch` - uses: ./.github/actions/setup-hatch - - - name: "Check Current Version In Code" - id: version-check - run: | - is_updated=false - current_version=$(hatch version) - if test "$current_version" = "${{ inputs.version_number }}" - then - 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" - if [[ ${{ steps.version-check.outputs.up_to_date }} == true ]] - then - message="The version in the codebase is equal to the provided version" - else - message="The version in the codebase differs from the provided version" - fi - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - name: "[DEBUG] Print Outputs" - run: | - echo up_to_date: ${{ steps.version-check.outputs.up_to_date }} - - skip-generate-changelog: - runs-on: ubuntu-latest - needs: [audit-changelog] - if: needs.audit-changelog.outputs.exists == 'true' - - steps: - - name: "Changelog Exists, Skip Generating New Changelog" - run: | - # Send notification - title="Skip changelog generation" - message="A changelog file already exists at ${{ needs.audit-changelog.outputs.changelog_path }}, skipping generating changelog" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - skip-version-bump: - runs-on: ubuntu-latest - needs: [audit-version-in-code] - if: needs.audit-version-in-code.outputs.up_to_date == 'true' - - steps: - - name: "Version Already Bumped" - run: | - # Send notification - title="Skip version bump" - message="The version has already been bumped to ${{ inputs.version_number }}, skipping version bump" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - create-temp-branch: - runs-on: ubuntu-latest - needs: [audit-changelog, audit-version-in-code] - if: needs.audit-changelog.outputs.exists == 'false' || needs.audit-version-in-code.outputs.up_to_date == 'false' - - outputs: - branch_name: ${{ steps.variables.outputs.branch_name }} - - steps: - - name: "Checkout ${{ github.repository }}" - uses: actions/checkout@v4 - with: - ref: ${{ inputs.target_branch }} - - - name: "Generate Branch Name" - id: variables - run: | - name="prep-release/" - if [[ ${{ inputs.nightly_release }} == true ]] - then - name+="nightly-release/" - else - name+="${{ inputs.deploy_to }}/" - fi - name+="${{ inputs.version_number }}_$GITHUB_RUN_ID" - echo "branch_name=$name" >> $GITHUB_OUTPUT - - name: "Create Branch - ${{ steps.variables.outputs.branch_name }}" - run: | - git checkout -b ${{ steps.variables.outputs.branch_name }} - git push -u origin ${{ steps.variables.outputs.branch_name }} - - name: "[Notification] Temp branch created" - run: | - # Send notification - title="Temp branch generated" - message="The ${{ steps.variables.outputs.branch_name }} branch created" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - name: "[DEBUG] Print Outputs" - run: | - echo branch_name ${{ steps.variables.outputs.branch_name }} - generate-changelog-bump-version: - runs-on: ubuntu-latest - needs: [audit-changelog, audit-version-in-code, create-temp-branch] - - steps: - - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" - uses: actions/checkout@v4 - with: - ref: ${{ needs.create-temp-branch.outputs.branch_name }} - - name: Setup `hatch` - uses: ./.github/actions/setup-hatch - - name: "Add Homebrew To PATH" - run: | - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - - name: "Install Homebrew Packages" - run: | - brew install pre-commit - brew tap miniscruff/changie https://github.com/miniscruff/changie - brew install changie - - name: "Set json File Name" - id: json_file - run: | - echo "name=output_$GITHUB_RUN_ID.json" >> $GITHUB_OUTPUT - - name: "Get Core Team Membership" - run: | - gh api -H "Accept: application/vnd.github+json" orgs/dbt-labs/teams/core-group/members > ${{ steps.json_file.outputs.name }} - env: - GH_TOKEN: ${{ secrets.IT_TEAM_MEMBERSHIP }} - - name: "Set Core Team Membership for Changie Contributors exclusion" - id: set_team_membership - run: | - team_list=$(jq -r '.[].login' ${{ steps.json_file.outputs.name }}) - echo $team_list - team_list_single=$(echo $team_list | tr '\n' ' ') - echo "CHANGIE_CORE_TEAM=$team_list_single" >> $GITHUB_ENV - - name: "Delete the json File" - run: | - rm ${{ steps.json_file.outputs.name }} - - name: "Generate Release Changelog" - if: needs.audit-changelog.outputs.exists == 'false' - run: | - if [[ ${{ needs.audit-changelog.outputs.is_prerelease }} -eq 1 ]] - then - changie batch ${{ needs.audit-changelog.outputs.base_version }} --move-dir '${{ needs.audit-changelog.outputs.base_version }}' --prerelease ${{ needs.audit-changelog.outputs.prerelease }} - elif [[ -d ".changes/${{ needs.audit-changelog.outputs.base_version }}" ]] - then - changie batch ${{ needs.audit-changelog.outputs.base_version }} --include '${{ needs.audit-changelog.outputs.base_version }}' --remove-prereleases - else # releasing a final patch with no prereleases - changie batch ${{ needs.audit-changelog.outputs.base_version }} - fi - changie merge - git status - - name: "Check Changelog Created Successfully" - if: needs.audit-changelog.outputs.exists == 'false' - run: | - title="Changelog" - if [[ -f ${{ needs.audit-changelog.outputs.changelog_path }} ]] - then - message="Changelog file created successfully" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - else - message="Changelog failed to generate" - echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - exit 1 - fi - - name: "Bump Version To ${{ inputs.version_number }}" - 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: | - title="Version bump" - message="Version successfully bumped in codebase to ${{ inputs.version_number }}" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - # TODO: can these 2 steps be done via hatch? probably. - # this step will fail on whitespace errors but also correct them - - name: "Remove Trailing Whitespace Via Pre-commit" - continue-on-error: true - run: | - pre-commit run trailing-whitespace --files dbt/adapters/__about__.py CHANGELOG.md .changes/* - git status - # this step will fail on newline errors but also correct them - - name: "Removing Extra Newlines Via Pre-commit" - continue-on-error: true - run: | - pre-commit run end-of-file-fixer --files dbt/adapters/__about__.py CHANGELOG.md .changes/* - git status - - name: "Commit & Push Changes" - run: | - #Data for commit - user="Github Build Bot" - email="buildbot@fishtownanalytics.com" - commit_message="Bumping version to ${{ inputs.version_number }} and generate changelog" - #Commit changes to branch - git config user.name "$user" - git config user.email "$email" - git pull - git add . - git commit -m "$commit_message" - git push - - run-unit-tests: - if: inputs.run-unit-tests == true - runs-on: ubuntu-latest - needs: [create-temp-branch, generate-changelog-bump-version] - - steps: - - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" - uses: actions/checkout@v4 - with: - ref: ${{ needs.create-temp-branch.outputs.branch_name }} - - name: "Setup `hatch`" - uses: ./.github/actions/setup-hatch - - name: "Run Unit Tests" - run: hatch run unit-tests - - run-integration-tests: - runs-on: ubuntu-20.04 - needs: [create-temp-branch, generate-changelog-bump-version] - if: inputs.run-integration-tests == true - - steps: - - name: "Checkout ${{ github.repository }} Branch ${{ needs.create-temp-branch.outputs.branch_name }}" - uses: actions/checkout@v4 - with: - ref: ${{ needs.create-temp-branch.outputs.branch_name }} - - - name: "Setup Environment Variables - ./${{ inputs.env_setup_script_path }}" - if: inputs.env_setup_script_path != '' - run: source ./${{ inputs.env_setup_script_path }} - - - name: "Setup Environment Variables - Secrets Context" - if: inputs.env_setup_script_path != '' - uses: actions/github-script@v6 - id: check-env - with: - result-encoding: string - script: | - try { - const { SECRETS_CONTEXT, INTEGRATION_TESTS_SECRETS_PREFIX } = process.env - const secrets = JSON.parse(SECRETS_CONTEXT) - if (INTEGRATION_TESTS_SECRETS_PREFIX) { - for (const [key, value] of Object.entries(secrets)) { - if (key.startsWith(INTEGRATION_TESTS_SECRETS_PREFIX)) { - core.exportVariable(key, value) - } - } - } else { - core.info("The INTEGRATION_TESTS_SECRETS_PREFIX env variable is empty or not defined, skipping the secrets setup.") - } - } catch (err) { - core.error("Error while reading or parsing the JSON") - core.setFailed(err) - } - env: - SECRETS_CONTEXT: ${{ toJson(secrets) }} - - - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" - uses: ./.github/actions/setup-python-env - with: - python-version: ${{ env.PYTHON_TARGET_VERSION }} - - - name: Run tests - run: hatch run integration-tests - - merge-changes-into-target-branch: - runs-on: ubuntu-latest - needs: [run-unit-tests, run-integration-tests, create-temp-branch, audit-version-in-code, audit-changelog] - if: | - !failure() && !cancelled() && - inputs.deploy_to == 'prod' && - ( - needs.audit-changelog.outputs.exists == 'false' || - needs.audit-version-in-code.outputs.up_to_date == 'false' - ) - steps: - - name: "[Debug] Print Variables" - run: | - echo branch_name: ${{ needs.create-temp-branch.outputs.branch_name }} - echo inputs.deploy_to: ${{ inputs.deploy_to }} - echo needs.audit-changelog.outputs.exists: ${{ needs.audit-changelog.outputs.exists }} - echo needs.audit-version-in-code.outputs.up_to_date: ${{ needs.audit-version-in-code.outputs.up_to_date }} - - name: "Checkout Repo ${{ github.repository }}" - uses: actions/checkout@v4 - - - name: "Merge Changes Into ${{ inputs.target_branch }}" - uses: everlytic/branch-merge@1.1.5 - with: - source_ref: ${{ needs.create-temp-branch.outputs.branch_name }} - target_branch: ${{ inputs.target_branch }} - github_token: ${{ secrets.FISHTOWN_BOT_PAT }} - commit_message_template: "[Automated] Merged {source_ref} into target {target_branch} during release process" - - - name: "[Notification] Changes Merged into main" - run: | - title="Changelog and Version Bump Branch Merge" - message="The ${{ needs.create-temp-branch.outputs.branch_name }} branch was merged into mains" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - determine-release-branch: - runs-on: ubuntu-latest - needs: - [ - create-temp-branch, - merge-changes-into-target-branch, - audit-changelog, - audit-version-in-code, - ] - # always run this job, regardless of if the dependant jobs were skipped - if: ${{ !failure() && !cancelled() }} - - # Get the sha that will be released. If the changelog already exists on the input sha and the version has already been bumped, - # then it is what we will release. Otherwise we generated a changelog and did the version bump in this workflow and there is a - # new sha to use from the merge we just did. Grab that here instead. - outputs: - final_sha: ${{ steps.resolve_commit_sha.outputs.release_sha }} - - steps: - - name: "[Debug] Print Variables" - run: | - echo new_branch: ${{ needs.create-temp-branch.outputs.branch_name }} - echo changelog_exists: ${{ needs.audit-changelog.outputs.exists }} - echo up_to_date: ${{ needs.audit-version-in-code.outputs.up_to_date }} - - name: "Resolve Branch To Checkout" - id: resolve_branch - run: | - branch="" - if [ ${{ inputs.deploy_to == 'test' }}] || [ ${{ inputs.nightly_release == 'true' }} ] - then - branch=${{ needs.create-temp-branch.outputs.branch_name }} - else - branch="${{ inputs.target_branch }}" - fi - echo "target_branch=$branch" >> $GITHUB_OUTPUT - - name: "[Notification] Resolve Branch To Checkout" - run: | - title="Branch pick" - message="The ${{ steps.resolve_branch.outputs.target_branch }} branch will be used for release" - echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" - - name: "Checkout Resolved Branch - ${{ steps.resolve_branch.outputs.target_branch }}" - uses: actions/checkout@v4 - with: - ref: ${{ steps.resolve_branch.outputs.target_branch }} - - - name: "[Debug] Log Branch" - run: git status - - - name: "Resolve Commit SHA For Release" - id: resolve_commit_sha - run: | - echo "release_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - - name: "Remove Temp Branch - ${{ needs.create-temp-branch.outputs.branch_name }}" - if: ${{ inputs.deploy_to == 'prod' && inputs.nightly_release == 'false' && needs.create-temp-branch.outputs.branch_name != '' }} - run: | - git push origin -d ${{ needs.create-temp-branch.outputs.branch_name }} diff --git a/.github/workflows/resubmit-for-triage.yml b/.github/workflows/resubmit-for-triage.yml deleted file mode 100644 index 385ef820..00000000 --- a/.github/workflows/resubmit-for-triage.yml +++ /dev/null @@ -1,31 +0,0 @@ -# **what?** -# When triaging submissions, we sometimes need more information from the issue creator. -# In those cases we remove the `triage` label and add the `awaiting_response` label. -# Once we receive a response in the form of a comment, we want the `awaiting_response` label removed -# and the `triage` label added so that we are aware that the issue needs action. - -# **why?** -# This automates a part of issue triaging while also removing noise from triage lists. - -# **when?** -# This will run when a comment is added to an issue and that issue has an `awaiting_response` label. - -name: Resubmit for Triage - -on: issue_comment - -defaults: - run: - shell: bash - -permissions: - issues: write - -jobs: - triage_label: - if: contains(github.event.issue.labels.*.name, 'awaiting_response') - uses: dbt-labs/actions/.github/workflows/swap-labels.yml@main - with: - add_label: "triage" - remove_label: "awaiting_response" - secrets: inherit # this is only acceptable because we own the action we're calling diff --git a/.github/workflows/scheduled-maintenance.yml b/.github/workflows/scheduled-maintenance.yml new file mode 100644 index 00000000..d0b6fe29 --- /dev/null +++ b/.github/workflows/scheduled-maintenance.yml @@ -0,0 +1,41 @@ +name: "Scheduled maintenance" + +on: + schedule: + - cron: "30 1 * * SAT" + +permissions: + contents: write + +# don't run this in parallel +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + +jobs: + pre-commit-autoupdate: + uses: dbt-labs/actions/.github/workflows/pre-commit-autoupdate.yml + secrets: + TOKEN: ${{ secrets.FISHTOWN_BOT_PAT }} + SLACK_WEBHOOK_PR_URL: ${{ secrets.SLACK_DEV_ADAPTER_PULL_REQUESTS }} + SLACK_WEBHOOK_ALERTS_URL: ${{ secrets.SLACK_DEV_ADAPTER_ALERTS }} + + stale: + runs-on: ${{ vars.DEFAULT_RUNNER }} + strategy: + matrix: + include: + - threshold: 90 + labels: 'triage:awaiting-response,triage:more-information-needed' + - threshold: 360 + labels: 'misc:good-first-issue,misc:help-wanted,type:tech-debt' + steps: + - uses: actions/stale@v9 + with: + stale-issue-message: "This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days." + stale-pr-message: "This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days." + close-issue-message: "Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers." + close-pr-message: "Although we are closing this PR as stale, it can still be reopened to continue development. Just add a comment to notify the maintainers." + close-issue-reason: "not_planned" + days-before-stale: ${{ matrix.threshold }} + any-of-labels: ${{ matrix.labels }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 75a14dd4..00000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,30 +0,0 @@ -# **what?** -# For issues that have been open for awhile without activity, label -# them as stale with a warning that they will be closed out. If -# anyone comments to keep the issue open, it will automatically -# remove the stale label and keep it open. - -# Stale label rules: -# awaiting_response, more_information_needed -> 90 days -# good_first_issue, help_wanted -> 360 days (a year) -# tech_debt -> 720 (2 years) -# all else defaults -> 180 days (6 months) - -# **why?** -# To keep the repo in a clean state from issues that aren't relevant anymore - -# **when?** -# Once a day - -name: "Close stale issues and PRs" -on: - schedule: - - cron: "30 1 * * *" - -permissions: - issues: write - pull-requests: write - -jobs: - stale: - uses: dbt-labs/actions/.github/workflows/stale-bot-matrix.yml@main diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index b4ac615d..00000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Unit Tests - -on: - push: - branches: - - "main" - - "*.latest" - pull_request: - workflow_dispatch: - -permissions: read-all - -# 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 }} - cancel-in-progress: true - -jobs: - unit: - name: Unit Tests - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] - - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup `hatch` - uses: ./.github/actions/setup-hatch - with: - python-version: ${{ matrix.python-version }} - - - name: Run unit tests - run: hatch run unit-tests - shell: bash - - - name: Publish results - uses: ./.github/actions/publish-results - if: always() - with: - source-file: "results.csv" - file-name: "unit_results" - python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/user-docs.yml b/.github/workflows/user-docs.yml new file mode 100644 index 00000000..065d1d2e --- /dev/null +++ b/.github/workflows/user-docs.yml @@ -0,0 +1,31 @@ +name: "Open user docs issue" +run-name: "Open user docs issue - #${{ github.event.issue.number }} - ${{ github.actor }}" + +on: + issues: + types: [labeled, closed] + +defaults: + run: + shell: bash + +permissions: + issues: write # comments on issues + +# only run this once per issue +concurrency: + group: ${{ github.workflow }}-${{ github.event.issue.number }} + cancel-in-progress: true + +jobs: + open_issues: + if: | + github.event.issue.state == 'closed' && + github.event.issue.state_reason == 'completed' && + contains(github.event.issue.labels.*.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 dbt-adapters - 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 diff --git a/pyproject.toml b/pyproject.toml index 47cd3ece..0c03b341 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,12 @@ dependencies = [ setup = "pre-commit install" code-quality = "pre-commit run --all-files" unit-tests = "python -m pytest {args:tests/unit}" +workflow-code-quality = "gh workflow run _code-quality.yml --ref $(git rev-parse --abbrev-ref HEAD) -f branch=$(git rev-parse --abbrev-ref HEAD)" +workflow-generate-changelog = "gh workflow run _generate-changelog.yml --ref $(git rev-parse --abbrev-ref HEAD) -f package=dbt-adapters -f merge=false -f branch=$(git rev-parse --abbrev-ref HEAD)" +workflow-publish-pypi = "gh workflow run _publish-pypi.yml --ref $(git rev-parse --abbrev-ref HEAD) -f package=dbt-adapters -f deploy-to=test -f branch=$(git rev-parse --abbrev-ref HEAD)" +workflow-unit-tests = "gh workflow run _unit-tests.yml --ref $(git rev-parse --abbrev-ref HEAD) -f package=dbt-adapters -f branch=$(git rev-parse --abbrev-ref HEAD)" +workflow-verify-build = "gh workflow run _verify-build.yml --ref $(git rev-parse --abbrev-ref HEAD) -f package=dbt-adapters -f branch=$(git rev-parse --abbrev-ref HEAD)" +workflow-publish = "gh workflow run publish.yml --ref $(git rev-parse --abbrev-ref HEAD) -f package=dbt-adapters -f branch=$(git rev-parse --abbrev-ref HEAD) -f deploy-to=test -f pypi-internal=false -f pypi-public=true" [tool.hatch.envs.build] detached = true