Skip to content

Commit

Permalink
Attempt to use an env var (may not work)
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Mar 22, 2024
1 parent 48ff055 commit 874d678
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions .github/workflows/internal-archive-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,37 @@ defaults:
shell: bash

env:
PYTHON_TARGET_VERSION: 3.11
PYTHON_TARGET_VERSION: 3.8
NOTIFICATION_PREFIX: "[Internal Archive Release]"
TEMP_PROFILE_NAME: "temp_aws_profile"
HATCH_ADAPTERS: '["postgres"]' # Must be valid JSON



jobs:
env-var-setup:
runs-on: ubuntu-latest
outputs:
is_hatch_adapter: ${{ steps.condition_check.outputs.is_hatch_adapter }}
steps:
- name: Check if dbms_name is not contained in HATCH_ADAPTERS
id: condition_check
env:
HATCH_ADAPTERS: "${{ env.HATCH_ADAPTERS }}
run: |
echo "HATCH_ADAPTERS=$HATCH_ADAPTERS" >> $GITHUB_ENV
ADAPTERS=$(jq -r '.' <<< "${HATCH_ADAPTERS}")
DBMS_NAME="${{ github.event.inputs.dbms_name }}"
if jq -e --arg dbms "$DBMS_NAME" '.[] <<< "${ADAPTERS}" | select(. == $dbms)'; then
echo "::set-output name=is_hatch_adapter::false"
else
echo "::set-output name=is_hatch_adapter::true"
fi

job-setup:
name: Job Setup
runs-on: ubuntu-latest
needs: [env-var-setup]
steps:
- name: "[DEBUG] Print Variables"
run: |
Expand All @@ -66,7 +89,7 @@ jobs:
run-unit-tests:
runs-on: ubuntu-latest
needs: [job-setup]
needs: [job-setup, env-var-setup]

env:
TOXENV: unit
Expand All @@ -86,26 +109,27 @@ jobs:
# Testing with Tox
#
- name: "Install Python Dependencies"
if: contains(fromJSON( '["redshift", "snowflake", "bigquery"]' ), inputs.dbms_name)
if: ! "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"

run: |
python -m pip install --user --upgrade pip
python -m pip install tox
python -m pip --version
python -m tox --version
- name: "Run Tests using tox"
if: contains(fromJSON( '["redshift", "snowflake", "bigquery"]' ), inputs.dbms_name)
if: ! "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"
run: tox

#
# Testing with Hatch
#
- name: "Setup `hatch`"
if: contains(fromJSON('["postgres"]'), inputs.dbms_name)
if: "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"
uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main

- name: "Run Tests using hatch"
if: contains(fromJSON('["postgres"]'), inputs.dbms_name)
if: "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"
run: hatch run unit-tests:all

####################
Expand All @@ -115,8 +139,8 @@ jobs:
run-integration-tests:
name: 'Integration Tests (Tox)'
runs-on: ubuntu-latest
needs: [job-setup]
if: contains(fromJSON( '["redshift", "snowflake", "bigquery"]' ), inputs.dbms_name)
needs: [job-setup, env-var-setup]
if: ! "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"

env:
TOXENV: integration
Expand Down Expand Up @@ -178,8 +202,8 @@ jobs:

run-integration-tests-hatch:
name: 'Integration Tests (Hatch)'
needs: [job-setup]
if: contains(fromJSON('["postgres"]'), inputs.dbms_name)
needs: [job-setup, env-var-setup]
if: "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"

uses: "dbt-labs/dbt-postgres/.github/workflows/integration-tests.yml@main"
with:
Expand All @@ -194,7 +218,7 @@ jobs:
create-internal-release:
name: Create release for internal archive
runs-on: ubuntu-latest
needs: [run-unit-tests, run-integration-tests, run-integration-tests-hatch]
needs: [env-var-setup, run-unit-tests, run-integration-tests, run-integration-tests-hatch]
# Build artifact if
# 1. All succeed
# 2. Spark invoked (it runs tests via its in-repo workflow)
Expand Down Expand Up @@ -253,13 +277,13 @@ jobs:
v="${base}${new_number}"
tee <<< "version = \"${v}\"" "${version_file}"
if [ -f "${setup_file}" ]; then
sed -i "s/^package_version = \".*\"/package_version = \"${v}\"/" "${setup_file}"
sed -i "s/^package_version = .*$/package_version = \"${v}\"/" "${setup_file}"
fi
else
v="${version_in_file}+build1"
tee <<< "version = \"${v}\"" "${version_file}"
if [ -f "${setup_file}" ]; then
sed -i "s/^package_version = \".*\"/package_version = \"${v}\"/" "${setup_file}"
sed -i "s/^package_version = .*$/package_version = \"${v}\"/" "${setup_file}"
fi
fi
Expand All @@ -271,18 +295,18 @@ jobs:
# 1. Build with setup.py
#
- name: "Build Distributions - scripts/build-dist.sh"
if: contains(fromJSON( '["redshift", "snowflake", "bigquery", "spark"]' ), inputs.dbms_name)
if: ! "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"
run: scripts/build-dist.sh

#
# 2. Build with Hatch
#
- name: "Setup `hatch`"
if: contains(fromJSON('["postgres"]'), inputs.dbms_name)
if: "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"
uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main

- name: "Build Distributions - hatch"
if: contains(fromJSON('["postgres"]'), inputs.dbms_name)
if: "${{ needs.env-var-setup.outputs.is_hatch_adapter }}"
run: hatch build

###################
Expand All @@ -295,7 +319,7 @@ jobs:
- name: "Check Distribution Descriptions"
run: |
version_file="dbt/adapters//__version__.py"
if [[ "${{ inputs.dbms_name }}" == 'postgres' ]]; then
if [[ "${{ needs.env-var-setup.outputs.is_hatch_adapter }}" == 'true' ]]; then
hatch run build:check-all
else
twine check dist/*
Expand Down

0 comments on commit 874d678

Please sign in to comment.