From 1a3ea2c2fc562d42a1f3210a87de9318eb12074b Mon Sep 17 00:00:00 2001 From: Shah Newaz Khan Date: Tue, 27 Aug 2024 18:55:29 -0700 Subject: [PATCH] fix gha workflow env (#350) * fix gha workflow env * add dbt_profiles_dir * bump fsc-utils to 1.30.0 & add tag_integration_test * add resource path selector to gha dbt command * revert to fsc-utils package 1.17.2 * add selectors.yml * add reusable dbt run workflow * test python 3.8 * pass in python version * add reusable workflow template and uses python_version * remove inline dbt.yml in favor of reusable template * change to dbt.yml reusable workflow * fix input command and remove python version * remove external browser authenticator * fix profiles in ./ * add password envar * clean up dbt_run_integration_test gha --- .github/workflows/dbt.yml | 59 ---------------------- .github/workflows/dbt_integration_test.yml | 19 ++++--- profiles.yml | 4 +- selectors.yml | 8 +++ 4 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/dbt.yml create mode 100644 selectors.yml diff --git a/.github/workflows/dbt.yml b/.github/workflows/dbt.yml deleted file mode 100644 index 418c1ff..0000000 --- a/.github/workflows/dbt.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: dbt -on: - workflow_call: - inputs: - warehouse: - required: false - type: string - environment: - required: true - type: string - command: - required: true - type: string - python_version: - required: false - type: string - default: "3.10" - -env: - DBT_PROFILES_DIR: ./ - - ACCOUNT: ${{ vars.ACCOUNT }} - ROLE: ${{ vars.ROLE }} - USER: ${{ vars.USER }} - PASSWORD: ${{ secrets.PASSWORD }} - REGION: ${{ vars.REGION }} - DATABASE: ${{ vars.DATABASE }} - WAREHOUSE: ${{ inputs.warehouse }} - SCHEMA: ${{ vars.SCHEMA }} - TARGET: ${{ vars.TARGET }} - -jobs: - dbt: - runs-on: ubuntu-latest - environment: - name: ${{ inputs.environment }} - env: - WAREHOUSE: ${{ inputs.warehouse || vars.WAREHOUSE }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ inputs.python_version }} - cache: "pip" - - name: install dependencies - run: | - pip install -r requirements.txt - dbt deps - - name: Run DBT Jobs - run: | - ${{ inputs.command }} - - name: Store logs - if: always() - uses: actions/upload-artifact@v3 - with: - name: logs-${{ inputs.environment }}-${{ github.run_number }}-${{ github.run_attempt }} - path: | - logs - target diff --git a/.github/workflows/dbt_integration_test.yml b/.github/workflows/dbt_integration_test.yml index ec1f55f..7fa22ae 100644 --- a/.github/workflows/dbt_integration_test.yml +++ b/.github/workflows/dbt_integration_test.yml @@ -1,19 +1,18 @@ -name: integration test +name: dbt_run_integration_test run-name: ${{ github.event.inputs.branch }} on: workflow_dispatch: - concurrency: ${{ github.workflow }} jobs: - test: - name: livequery_integration_test - uses: ./.github/workflows/dbt.yml - secrets: inherit - + called_workflow_template: + uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/dbt.yml@main with: - warehouse: DBT_CLOUD - environment: ${{ github.ref == 'refs/heads/main' && 'prod' || 'stg' }} - command: dbt test -s 'livequery_models.deploy.core.*' + command: > + dbt test --selector 'integration_tests' + environment: ${{ github.ref == 'refs/heads/main' && 'workflow_prod' || 'workflow_dev' }} + warehouse: ${{ vars.WAREHOUSE }} + secrets: inherit + diff --git a/profiles.yml b/profiles.yml index 96d8884..351334d 100644 --- a/profiles.yml +++ b/profiles.yml @@ -5,7 +5,7 @@ flow: type: snowflake account: "{{ env_var('ACCOUNT') }}" user: "{{ env_var('USER') }}" - authenticator: externalbrowser + password: "{{ env_var('PASSWORD') }}" role: "{{ env_var('ROLE') }}" schema: "{{ env_var('SCHEMA') }}" region: "{{ env_var('REGION') }}" @@ -17,7 +17,7 @@ flow: type: snowflake account: "{{ env_var('ACCOUNT') }}" user: "{{ env_var('USER') }}" - authenticator: externalbrowser + password: "{{ env_var('PASSWORD') }}" role: "{{ env_var('ROLE') }}" schema: "{{ env_var('SCHEMA') }}" region: "{{ env_var('REGION') }}" diff --git a/selectors.yml b/selectors.yml new file mode 100644 index 0000000..4561b77 --- /dev/null +++ b/selectors.yml @@ -0,0 +1,8 @@ +selectors: + - name: integration_tests + description: "Selector for integration tests" + definition: + union: + - method: fqn + value: "livequery_models.deploy.core.*" + \ No newline at end of file