Skip to content

Commit

Permalink
update workflows to account for new dbt-tests-adapter structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Mar 1, 2024
1 parent 148c499 commit 372c38b
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 100 deletions.
6 changes: 3 additions & 3 deletions .github/actions/build-hatch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ runs:
using: composite
steps:

- name: Build artifacts
- name: "Build artifacts"
run: ${{ inputs.build-command }}
shell: bash
working-directory: ${{ inputs.working-dir }}

- name: Check artifacts
- name: "Check artifacts"
run: ${{ inputs.check-command }}
shell: bash
working-directory: ${{ inputs.working-dir }}

- name: Upload artifacts
- name: "Upload artifacts"
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.archive-name}}
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/publish-pypi/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish - PyPI
name: "Publish - PyPI"
description: Publish artifacts saved during build step to PyPI

inputs:
Expand All @@ -13,13 +13,13 @@ runs:
using: composite
steps:

- name: Download artifacts
- name: "Download artifacts"
uses: actions/download-artifact@v3
with:
name: ${{ inputs.archive-name }}
path: .

- name: Publish artifacts to PyPI
- name: "Publish artifacts to PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ inputs.repository-url }}
10 changes: 6 additions & 4 deletions .github/actions/publish-results/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Publish results
name: "Publish - Test Results"
description: Publish test results with a unique archive name

inputs:
file-name:
description: File type for file name stub (e.g. "unit-tests")
required: true
python-version:
description: Python version for the file name stub (e.g. "3.8")
description: Python version for the archive name stub (e.g. "3.8")
required: true
source-file:
description: File to be uploaded
Expand All @@ -14,12 +15,13 @@ inputs:
runs:
using: composite
steps:
- name: Get timestamp
- name: "Get timestamp"
id: timestamp
run: echo "ts=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_OUTPUT #no colons allowed for artifacts
shell: bash

- uses: actions/upload-artifact@v3
- name: "Publish test results to archive"
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.file-name }}_python-${{ inputs.python-version }}_${{ steps.timestamp.outputs.ts }}.csv
path: ${{ inputs.source-file }}
6 changes: 3 additions & 3 deletions .github/actions/setup-hatch/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Setup - `hatch`
name: "Setup - `hatch`"
description: Setup a python environment with `hatch` installed

inputs:
Expand All @@ -12,11 +12,11 @@ inputs:
runs:
using: composite
steps:
- name: Set up Python ${{ inputs.python-version }}
- name: "Set up Python ${{ inputs.python-version }}"
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install dev dependencies
- name: "Install dev dependencies"
run: ${{ inputs.setup-command }}
shell: bash
39 changes: 20 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **what?**
# Verifies python build on all code commited to the repository. This workflow
# Verifies python build on all code committed 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.

Expand All @@ -19,8 +19,22 @@ on:
merge_group:
types: [checks_requested]
workflow_dispatch:
inputs:
package:
type: choice
description: Choose what to publish
options:
- dbt-adapters
- dbt-tests-adapter
changelog_path:
description: "Path to changelog file"
required: true
type: string
workflow_call:
inputs:
package:
type: string
description: Choose what to publish
changelog_path:
description: "Path to changelog file"
required: true
Expand All @@ -30,7 +44,7 @@ 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 }}
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}-${{ inputs.package }}
cancel-in-progress: true

defaults:
Expand All @@ -39,35 +53,22 @@ defaults:

jobs:
build:
name: Build, Test and publish to PyPi
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`
if: ${{ inputs.package == 'dbt-adapters' }}
uses: ./.github/actions/build-hatch

- name: Build `dbt-tests-adapter`
if: ${{ inputs.package == 'dbt-tests-adapter' }}
uses: ./.github/actions/build-hatch
with:
working-dir: "./dbt-tests-adapter/"

- name: Setup `hatch`
- name: "Setup `hatch`"
uses: ./.github/actions/setup-hatch

- name: Build `dbt-adapters`
- name: "Build `dbt-adapters`"
if: ${{ inputs.package == 'dbt-adapters' }}
uses: ./.github/actions/build-hatch

- name: Build `dbt-tests-adapter`
- name: "Build `dbt-tests-adapter`"
if: ${{ inputs.package == 'dbt-tests-adapter' }}
uses: ./.github/actions/build-hatch
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog-existence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# 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
name: "Check Changelog Entry"

on:
pull_request_target:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Quality
name: "Code Quality"

on:
push:
Expand All @@ -21,20 +21,20 @@ concurrency:

jobs:
lint:
name: Code Quality
name: "Code Quality"
runs-on: ubuntu-latest

steps:
- name: Check out repository
- name: "Check out repository"
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup `hatch`
- name: "Setup `hatch`"
uses: ./.github/actions/setup-hatch

- name: Run linters
- name: "Run linters"
run: hatch run lint:all

- name: Run typechecks
- name: "Run typechecks"
run: hatch run typecheck:all
2 changes: 1 addition & 1 deletion .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# 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
name: "GitHub Release"

on:
workflow_call:
Expand Down
51 changes: 29 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Release
run-name: Release ${{ inputs.package }}==${{ inputs.version_number }} to ${{ inputs.deploy-to }}
name: "Release"
run-name: "Release ${{ inputs.package }}==${{ inputs.version_number }} to ${{ inputs.deploy-to }}"

on:
workflow_dispatch:
inputs:
package:
description: "Choose what to publish"
type: choice
description: Choose what to publish
options:
- dbt-adapters
- dbt-tests-adapter
Expand All @@ -15,8 +15,8 @@ on:
type: string
required: true
deploy-to:
description: "Choose where to publish"
type: choice
description: Choose where to publish
options:
- prod
- test
Expand All @@ -25,36 +25,32 @@ on:
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:
description: "Choose what to publish"
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:
description: "Choose where to publish"
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
Expand All @@ -72,14 +68,26 @@ defaults:
shell: bash

jobs:
bump-version-generate-changelog:
name: "Bump package version, Generate changelog"
uses: dbt-labs/dbt-adapters/.github/workflows/release_prep_hatch.yml@main
bump-version-generate-changelog-dbt-adapters:
name: "Bump package version, Generate changelog - dbt-adapters"
uses: .github/workflows/release_prep_hatch.yml
with:
version_number: ${{ inputs.version_number }}
deploy_to: ${{ inputs.deploy-to }}
nightly_release: ${{ inputs.nightly_release }}
target_branch: ${{ inputs.target_branch }}
run-unit-tests: true
secrets: inherit

bump-version-generate-changelog-dbt-tests-adapter:
name: "Bump package version, Generate changelog - dbt-tests-adapter"
uses: .github/workflows/release_prep_hatch.yml
with:
version_number: ${{ inputs.version_number }}
deploy_to: ${{ inputs.deploy-to }}
nightly_release: ${{ inputs.nightly_release }}
target_branch: ${{ inputs.target_branch }}
working-dir: "./dbt-tests-adapter"
secrets: inherit

log-outputs-bump-version-generate-changelog:
Expand All @@ -106,29 +114,29 @@ jobs:
ref: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}

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

- name: "Build `dbt-adapters`"
if: ${{ inputs.package == 'dbt-adapters' }}
uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main
uses: .github/actions/build-hatch
with:
changelog-path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
archive-name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}

- name: "Build `dbt-tests-adapter`"
if: ${{ inputs.package == 'dbt-tests-adapter' }}
uses: dbt-labs/dbt-adapters/.github/actions/build-hatch@main
uses: .github/actions/build-hatch
with:
changelog-path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }}
working-dir: "./dbt-tests-adapter/"
archive-name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}
working-dir: "./dbt-tests-adapter/"

github-release:
name: "GitHub Release"
# ToDo: update GH release to handle adding dbt-tests-adapter and dbt-adapter assets to the same release
if: ${{ !failure() && !cancelled() && inputs.package == 'dbt-adapters' }}
needs: [build-and-test, bump-version-generate-changelog]
uses: dbt-labs/dbt-adapters/.github/workflows/github-release.yml@main
uses: .github/workflows/github-release.yml
with:
sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }}
version_number: ${{ inputs.version_number }}
Expand All @@ -139,6 +147,7 @@ jobs:
pypi-release:
name: "Publish to PyPI"
runs-on: ubuntu-latest
if: ${{ !failure() && !cancelled() }}
needs: [github-release]
environment:
name: ${{ inputs.deploy-to }}
Expand All @@ -148,9 +157,7 @@ jobs:
uses: actions/checkout@v4

- name: "Publish to PyPI"
uses: dbt-labs/dbt-adapters/.github/actions/publish-pypi@main
uses: .github/actions/publish-pypi
with:
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
archive-name: ${{ inputs.version_number }}-${{ inputs.package }}-${{ inputs.deploy-to }}


repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
Loading

0 comments on commit 372c38b

Please sign in to comment.