Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo prep #355

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 0 additions & 38 deletions .github/actions/build-hatch/action.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/actions/publish-pypi/action.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/actions/publish-results/action.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/actions/setup-hatch/action.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/_code-quality.yml
Original file line number Diff line number Diff line change
@@ -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 test, (used primarily when testing 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 test, (used primarily when testing 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/[email protected]
216 changes: 216 additions & 0 deletions .github/workflows/_generate-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
name: Version Bump and Changelog Generation

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"
outputs:
release-sha:
description: "The SHA to release"
value: ${{ jobs.release-branch.outputs.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

jobs:
version:
runs-on: ${{ vars.DEFAULT_RUNNER }}
outputs:
full: ${{ steps.version.outputs.version }}
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 "version=$(hatch version)" >> $GITHUB_OUTPUT
working-directory: ./${{ inputs.package }}
- id: semver
uses: dbt-labs/actions/[email protected]
with:
version: ${{ steps.version.outputs.version }}

changelog:
runs-on: ${{ vars.DEFAULT_RUNNER }}
needs: version
outputs:
path: ${{ steps.changelog.outputs.path }}
exists: ${{ steps.changelog.outputs.exists }}
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: 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: ./${{ inputs.package }}

temp-branch:
runs-on: ${{ vars.DEFAULT_RUNNER }}
needs: [version, changelog]
if: needs.changelog.outputs.exists == 'false'
outputs:
name: ${{ steps.branch.outputs.name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- id: branch
run: |
name="prep-release/${{ inputs.deploy_to }}/${{ needs.version.outputs.full }}_$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:
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:
runs-on: ${{ vars.DEFAULT_RUNNER }}
needs: [version, changelog, temp-branch, dbt-membership]
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
- if: needs.changelog.outputs.exists == 'false'
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
git status
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/*
git status
working-directory: ./${{ inputs.package }}
continue-on-error: true
- run: |
git config user.name "Github Build Bot"
git config user.email "[email protected]"
git pull
git add .
git commit -m "generate changelog"
git push
working-directory: ./${{ inputs.package }}

merge-changes:
runs-on: ${{ vars.DEFAULT_RUNNER }}
needs: [temp-branch, generate-changelog]
if: |
!failure() && !cancelled() &&
inputs.deploy-to == 'prod' &&
needs.changelog.outputs.exists == 'false'
steps:
- uses: actions/checkout@v4
- uses: everlytic/[email protected]
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"

release-branch:
runs-on: ${{ vars.DEFAULT_RUNNER }}
needs: [temp-branch, merge-changes]
# 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:
sha: ${{ steps.commit.outputs.sha }}
steps:
- id: branch
run: |
branch=""
if [ ${{ inputs.deploy-to == 'test' }}]
then
branch=${{ needs.temp-branch.outputs.name }}
else
branch="${{ inputs.branch }}"
fi
echo "name=$branch" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.branch.outputs.name }}
- id: commit
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- if: ${{ inputs.deploy-to == 'prod' && needs.temp-branch.outputs.name != '' }}
run: git push origin -d ${{ needs.temp-branch.outputs.name }}
Loading
Loading