From 086fa8b9d4ea610f6e0063b8c53e330afa8ef7b4 Mon Sep 17 00:00:00 2001 From: colin-rogers-dbt <111200756+colin-rogers-dbt@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:59:54 -0800 Subject: [PATCH] Update test requirements in pyproject.toml via bash script (#15) Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com> --- .github/scripts/update_dev_packages.sh | 17 +++++++++++++ .github/workflows/code-quality.yml | 26 +++++++++++++++++++- .github/workflows/integration-tests.yml | 32 +++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 .github/scripts/update_dev_packages.sh diff --git a/.github/scripts/update_dev_packages.sh b/.github/scripts/update_dev_packages.sh new file mode 100755 index 00000000..c0f207b4 --- /dev/null +++ b/.github/scripts/update_dev_packages.sh @@ -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 diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index dedea94b..081079fc 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -7,6 +7,19 @@ 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 @@ -14,18 +27,29 @@ permissions: read-all 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 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index af2383bd..874001c4 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -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 @@ -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