Skip to content

Commit

Permalink
Update test requirements in pyproject.toml via bash script (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Alfare <[email protected]>
  • Loading branch information
colin-rogers-dbt and mikealfare authored Feb 20, 2024
1 parent 5fa52ca commit 086fa8b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/scripts/update_dev_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e
set -e


adapters_git_branch=$1
core_git_branch=$2
target_req_file="pyproject.toml"
core_req_sed_pattern="s|dbt-core.git.*#subdirectory=core|dbt-core.git@${core_git_branch}#subdirectory=core|g"
adapters_req_sed_pattern="s|dbt-adapters.git|dbt-adapters.git@${adapters_git_branch}|g"
if [[ "$OSTYPE" == darwin* ]]; then
# mac ships with a different version of sed that requires a delimiter arg
sed -i "" "$core_req_sed_pattern" $target_req_file
sed -i "" "$adapters_req_sed_pattern" $target_req_file
else
sed -i "$core_req_sed_pattern" $target_req_file
sed -i "$adapters_req_sed_pattern" $target_req_file
fi
26 changes: 25 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,49 @@ on:
- "*.latest"
pull_request:
workflow_dispatch:
inputs:
dbt_adapters_branch:
description: "The branch of dbt-adapters to evaluate"
type: string
required: true
default: "main"
workflow_call:
inputs:
dbt_adapters_branch:
description: "The branch of dbt-adapters to evaluate"
type: string
required: true
default: "main"

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

env:
# set DBT_ADAPTERS_BRANCH to the input value if the event is a workflow_dispatch (workflow_call uses the same event_name),
# otherwise use 'main'
DBT_ADAPTERS_BRANCH: ${{ github.event_name == 'workflow_dispatch' && inputs.dbt_adapters_branch || 'main' }}
jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest


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

- name: Update Adapters and Core branches
shell: bash
run: |
./.github/scripts/update_dev_packages.sh \
$DBT_ADAPTERS_BRANCH \
"main"
- name: Setup `hatch`
uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main

Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ on:
- "*.latest"
pull_request:
workflow_dispatch:
inputs:
dbt_adapters_branch:
description: "The branch of dbt-adapters to use"
type: string
required: false
default: "main"
core_branch:
description: "The branch of dbt-core to use"
type: string
required: false
default: "main"
workflow_call:
inputs:
dbt_adapters_branch:
description: "The branch of dbt-adapters to use"
type: string
required: false
default: "main"
core_branch:
description: "The branch of dbt-core to use"
type: string
required: false
default: "main"


permissions: read-all

Expand Down Expand Up @@ -42,6 +66,14 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Update Adapters and Core branches
if: ${{ github.event_name == 'workflow_call' || github.event_name == 'workflow_dispatch'}}
shell: bash
run: |
./.github/scripts/update_dev_packages.sh \
${{ github.event.inputs.dbt_adapters_branch }} \
${{ github.event.inputs.core_branch }}
- name: Setup postgres
shell: bash
run: psql -f ./scripts/setup_test_database.sql
Expand Down

0 comments on commit 086fa8b

Please sign in to comment.