From 37138ec7da50445dd302ebfd8971d3e4b51cf3f7 Mon Sep 17 00:00:00 2001 From: Austin <93135983+austinFlipside@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:27:37 -0400 Subject: [PATCH] LQ (#197) --- .github/workflows/dbt_alter_gha_task.yml | 46 +++++++++++++++++++ .github/workflows/dbt_run_abi_refresh.yml | 2 +- .../workflows/dbt_run_full_observability.yml | 2 +- .github/workflows/dbt_run_heal_models.yml | 2 +- .../dbt_run_incremental_non_realtime.yml | 7 ++- .github/workflows/dbt_run_operation_reorg.yml | 2 +- .../workflows/dbt_run_scheduled_curated.yml | 5 +- .../dbt_run_streamline_chainhead.yml | 7 ++- .../workflows/dbt_run_streamline_decoder.yml | 7 ++- .../dbt_run_streamline_decoder_history.yml | 2 +- .../dbt_run_streamline_history_adhoc.yml | 4 +- .github/workflows/dbt_test_daily.yml | 2 +- .github/workflows/dbt_test_intraday.yml | 4 +- .github/workflows/dbt_test_monthly.yml | 2 +- .github/workflows/dbt_test_tasks.yml | 27 +++++++++++ data/github_actions__workflows.csv | 6 +++ dbt_project.yml | 1 + .../github_actions__current_task_status.sql | 6 +++ .../github_actions__current_task_status.yml | 17 +++++++ .../github_actions__task_history.sql | 5 ++ .../github_actions__task_performance.sql | 5 ++ .../github_actions__task_schedule.sql | 5 ++ .../github_actions/github_actions__tasks.sql | 5 ++ models/sources.yml | 5 ++ packages.yml | 2 +- 25 files changed, 151 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/dbt_alter_gha_task.yml create mode 100644 .github/workflows/dbt_test_tasks.yml create mode 100644 data/github_actions__workflows.csv create mode 100644 models/github_actions/github_actions__current_task_status.sql create mode 100644 models/github_actions/github_actions__current_task_status.yml create mode 100644 models/github_actions/github_actions__task_history.sql create mode 100644 models/github_actions/github_actions__task_performance.sql create mode 100644 models/github_actions/github_actions__task_schedule.sql create mode 100644 models/github_actions/github_actions__tasks.sql diff --git a/.github/workflows/dbt_alter_gha_task.yml b/.github/workflows/dbt_alter_gha_task.yml new file mode 100644 index 00000000..da996d80 --- /dev/null +++ b/.github/workflows/dbt_alter_gha_task.yml @@ -0,0 +1,46 @@ +name: dbt_alter_gha_task +run-name: dbt_alter_gha_task + +on: + workflow_dispatch: + branches: + - "main" + inputs: + workflow_name: + type: string + description: Name of the workflow to perform the action on, no .yml extension + required: true + task_action: + type: choice + description: Action to perform + required: true + options: + - SUSPEND + - RESUME + default: SUSPEND + +env: + DBT_PROFILES_DIR: ./ + + ACCOUNT: "${{ vars.ACCOUNT }}" + ROLE: "${{ vars.ROLE }}" + USER: "${{ vars.USER }}" + PASSWORD: "${{ secrets.PASSWORD }}" + REGION: "${{ vars.REGION }}" + DATABASE: "${{ vars.DATABASE }}" + WAREHOUSE: "${{ vars.WAREHOUSE }}" + SCHEMA: "${{ vars.SCHEMA }}" + +concurrency: + group: ${{ github.workflow }} + +jobs: + called_workflow_template: + uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/dbt_alter_gha_tasks.yml@main + with: + workflow_name: | + ${{ inputs.workflow_name }} + task_action: | + ${{ inputs.task_action }} + environment: workflow_prod + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/dbt_run_abi_refresh.yml b/.github/workflows/dbt_run_abi_refresh.yml index fd4690d6..5ead2d50 100644 --- a/.github/workflows/dbt_run_abi_refresh.yml +++ b/.github/workflows/dbt_run_abi_refresh.yml @@ -42,7 +42,7 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run -m tag:abis + dbt run -m "optimism_models,tag:abis" diff --git a/.github/workflows/dbt_run_full_observability.yml b/.github/workflows/dbt_run_full_observability.yml index f18c0f66..b21059cf 100644 --- a/.github/workflows/dbt_run_full_observability.yml +++ b/.github/workflows/dbt_run_full_observability.yml @@ -42,7 +42,7 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run --threads 2 --vars '{"OBSERV_FULL_TEST":True}' -m tag:observability + dbt run --threads 2 --vars '{"OBSERV_FULL_TEST":True}' -m "optimism_models,tag:observability" diff --git a/.github/workflows/dbt_run_heal_models.yml b/.github/workflows/dbt_run_heal_models.yml index 7747c609..240de804 100644 --- a/.github/workflows/dbt_run_heal_models.yml +++ b/.github/workflows/dbt_run_heal_models.yml @@ -42,4 +42,4 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run -m tag:heal --var '{"HEAL_MODEL":True}' \ No newline at end of file + dbt run -m "optimism_models,tag:heal" --var '{"HEAL_MODEL":True}' \ No newline at end of file diff --git a/.github/workflows/dbt_run_incremental_non_realtime.yml b/.github/workflows/dbt_run_incremental_non_realtime.yml index e2301ace..3d2fdec7 100644 --- a/.github/workflows/dbt_run_incremental_non_realtime.yml +++ b/.github/workflows/dbt_run_incremental_non_realtime.yml @@ -3,9 +3,8 @@ run-name: dbt_run_scheduled_non_realtime on: workflow_dispatch: - schedule: - # Runs "at minute 35, every hour" (see https://crontab.guru) - - cron: '6,18,30,42,54 * * * *' + branches: + - "main" env: DBT_PROFILES_DIR: ./ @@ -42,5 +41,5 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run --threads 8 --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m tag:non_realtime tag:streamline_decoded_logs_complete tag:streamline_decoded_logs_realtime + dbt run --threads 8 --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m "optimism_models,tag:non_realtime" "optimism_models,tag:streamline_decoded_logs_complete" "optimism_models,tag:streamline_decoded_logs_realtime" \ No newline at end of file diff --git a/.github/workflows/dbt_run_operation_reorg.yml b/.github/workflows/dbt_run_operation_reorg.yml index accbf36a..b4e1124d 100644 --- a/.github/workflows/dbt_run_operation_reorg.yml +++ b/.github/workflows/dbt_run_operation_reorg.yml @@ -44,7 +44,7 @@ jobs: - name: List reorg models id: list_models run: | - reorg_model_list=$(dbt list --select tag:reorg --resource-type model | awk -F'.' '{print $NF}' | tr '\n' ',' | sed 's/,$//') + reorg_model_list=$(dbt list --select "optimism_models,tag:reorg" --resource-type model | awk -F'.' '{print $NF}' | tr '\n' ',' | sed 's/,$//') echo "::set-output name=model_list::$reorg_model_list" - name: Execute block_reorg macro diff --git a/.github/workflows/dbt_run_scheduled_curated.yml b/.github/workflows/dbt_run_scheduled_curated.yml index 98b30657..e0158afa 100644 --- a/.github/workflows/dbt_run_scheduled_curated.yml +++ b/.github/workflows/dbt_run_scheduled_curated.yml @@ -3,9 +3,8 @@ run-name: dbt_run_scheduled_curated on: workflow_dispatch: - schedule: - # Runs at minutes 10 and 40" (see https://crontab.guru) - - cron: '10,40 * * * *' + branches: + - "main" env: DBT_PROFILES_DIR: ./ diff --git a/.github/workflows/dbt_run_streamline_chainhead.yml b/.github/workflows/dbt_run_streamline_chainhead.yml index f2682152..33e0d16b 100644 --- a/.github/workflows/dbt_run_streamline_chainhead.yml +++ b/.github/workflows/dbt_run_streamline_chainhead.yml @@ -3,9 +3,8 @@ run-name: dbt_run_streamline_chainhead on: workflow_dispatch: - schedule: - # Runs at minutes 0,12,24,46,48 (see https://crontab.guru) - - cron: '0,12,24,46,48 * * * *' + branches: + - "main" env: DBT_PROFILES_DIR: ./ @@ -42,4 +41,4 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m tag:streamline_core_complete tag:streamline_core_realtime \ No newline at end of file + dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m "optimism_models,tag:streamline_core_complete" "optimism_models,tag:streamline_core_realtime" \ No newline at end of file diff --git a/.github/workflows/dbt_run_streamline_decoder.yml b/.github/workflows/dbt_run_streamline_decoder.yml index 22b5a37a..c787dcc3 100644 --- a/.github/workflows/dbt_run_streamline_decoder.yml +++ b/.github/workflows/dbt_run_streamline_decoder.yml @@ -3,9 +3,8 @@ run-name: dbt_run_streamline_decoder on: workflow_dispatch: - schedule: - # Runs at minutes 3,15,27,39,51 (see https://crontab.guru) - - cron: '3,15,27,39,51 * * * *' + branches: + - "main" env: DBT_PROFILES_DIR: ./ @@ -42,4 +41,4 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run -m tag:decoded_logs \ No newline at end of file + dbt run -m "optimism_models,tag:decoded_logs" \ No newline at end of file diff --git a/.github/workflows/dbt_run_streamline_decoder_history.yml b/.github/workflows/dbt_run_streamline_decoder_history.yml index b93e0830..983245cc 100644 --- a/.github/workflows/dbt_run_streamline_decoder_history.yml +++ b/.github/workflows/dbt_run_streamline_decoder_history.yml @@ -42,4 +42,4 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run --threads 8 --vars '{"STREAMLINE_INVOKE_STREAMS":True,"WAIT":120}' -m tag:streamline_decoded_logs_complete tag:streamline_decoded_logs_history \ No newline at end of file + dbt run --threads 8 --vars '{"STREAMLINE_INVOKE_STREAMS":True,"WAIT":120}' -m "optimism_models,tag:streamline_decoded_logs_complete" "optimism_models,tag:streamline_decoded_logs_history" \ No newline at end of file diff --git a/.github/workflows/dbt_run_streamline_history_adhoc.yml b/.github/workflows/dbt_run_streamline_history_adhoc.yml index 4130e5fc..6b70faee 100644 --- a/.github/workflows/dbt_run_streamline_history_adhoc.yml +++ b/.github/workflows/dbt_run_streamline_history_adhoc.yml @@ -29,8 +29,8 @@ on: description: 'DBT Run Command' required: true options: - - dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m tag:streamline_core_complete tag:streamline_core_history - - dbt run --threads 8 --vars '{"STREAMLINE_INVOKE_STREAMS":True,"WAIT":120}' -m tag:streamline_decoded_logs_complete tag:streamline_decoded_logs_history + - dbt run --vars '{"STREAMLINE_INVOKE_STREAMS":True}' -m "optimism_models,tag:streamline_core_complete" "optimism_models,tag:streamline_core_history" + - dbt run --threads 8 --vars '{"STREAMLINE_INVOKE_STREAMS":True,"WAIT":120}' -m "optimism_models,tag:streamline_decoded_logs_complete" "optimism_models,tag:streamline_decoded_logs_history" env: DBT_PROFILES_DIR: ./ diff --git a/.github/workflows/dbt_test_daily.yml b/.github/workflows/dbt_test_daily.yml index 91661b4c..a3ba375b 100644 --- a/.github/workflows/dbt_test_daily.yml +++ b/.github/workflows/dbt_test_daily.yml @@ -42,7 +42,7 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt test --exclude tag:full_test tag:recent_test + dbt test --exclude "optimism_models,tag:full_test" "optimism_models,tag:recent_test" "optimism_models,tag:gha_tasks" livequery_models diff --git a/.github/workflows/dbt_test_intraday.yml b/.github/workflows/dbt_test_intraday.yml index 2ce3788c..49472e5f 100644 --- a/.github/workflows/dbt_test_intraday.yml +++ b/.github/workflows/dbt_test_intraday.yml @@ -42,8 +42,8 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt run -m tag:observability - dbt test -m tag:recent_test + dbt run -m "optimism_models,tag:observability" + dbt test -m "optimism_models,tag:recent_test" diff --git a/.github/workflows/dbt_test_monthly.yml b/.github/workflows/dbt_test_monthly.yml index ec3d9779..ccc0c991 100644 --- a/.github/workflows/dbt_test_monthly.yml +++ b/.github/workflows/dbt_test_monthly.yml @@ -42,7 +42,7 @@ jobs: dbt deps - name: Run DBT Jobs run: | - dbt test -m tag:full_test + dbt test -m "optimism_models,tag:full_test" diff --git a/.github/workflows/dbt_test_tasks.yml b/.github/workflows/dbt_test_tasks.yml new file mode 100644 index 00000000..976440bd --- /dev/null +++ b/.github/workflows/dbt_test_tasks.yml @@ -0,0 +1,27 @@ +name: dbt_test_tasks +run-name: dbt_test_tasks + +on: + workflow_dispatch: + branches: + - "main" + +env: + DBT_PROFILES_DIR: ./ + + ACCOUNT: "${{ vars.ACCOUNT }}" + ROLE: "${{ vars.ROLE }}" + USER: "${{ vars.USER }}" + PASSWORD: "${{ secrets.PASSWORD }}" + REGION: "${{ vars.REGION }}" + DATABASE: "${{ vars.DATABASE }}" + WAREHOUSE: "${{ vars.WAREHOUSE }}" + SCHEMA: "${{ vars.SCHEMA }}" + +concurrency: + group: ${{ github.workflow }} + +jobs: + called_workflow_template: + uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/dbt_test_tasks.yml@main + secrets: inherit \ No newline at end of file diff --git a/data/github_actions__workflows.csv b/data/github_actions__workflows.csv new file mode 100644 index 00000000..c9c98471 --- /dev/null +++ b/data/github_actions__workflows.csv @@ -0,0 +1,6 @@ +workflow_name,workflow_schedule +dbt_run_scheduled_non_realtime,"6,18,30,42,54 * * * *" +dbt_run_streamline_chainhead,"0,12,24,46,48 * * * *" +dbt_run_streamline_decoder,"3,15,27,39,51 * * * *" +dbt_run_scheduled_curated,"10,40 * * * *" +dbt_test_tasks,"15,45 * * * *" \ No newline at end of file diff --git a/dbt_project.yml b/dbt_project.yml index 0c863a4e..41f5d2cb 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -64,3 +64,4 @@ vars: WAIT: 0 OBSERV_FULL_TEST: False HEAL_MODEL: False + START_GHA_TASKS: False diff --git a/models/github_actions/github_actions__current_task_status.sql b/models/github_actions/github_actions__current_task_status.sql new file mode 100644 index 00000000..577a2266 --- /dev/null +++ b/models/github_actions/github_actions__current_task_status.sql @@ -0,0 +1,6 @@ +{{ config( + materialized = 'view', + tags = ['gha_tasks'] +) }} + +{{ fsc_utils.gha_task_current_status_view() }} \ No newline at end of file diff --git a/models/github_actions/github_actions__current_task_status.yml b/models/github_actions/github_actions__current_task_status.yml new file mode 100644 index 00000000..e28300dd --- /dev/null +++ b/models/github_actions/github_actions__current_task_status.yml @@ -0,0 +1,17 @@ +version: 2 +models: + - name: github_actions__current_task_status + columns: + - name: WAS_SUCCESSFUL + tests: + - dbt_expectations.expect_column_values_to_be_in_set: + value_set: + - TRUE + - name: RETURN_VALUE + tests: + - dbt_expectations.expect_column_values_to_be_in_set: + value_set: + - 204 + config: + severity: warn + warn_if: ">0" diff --git a/models/github_actions/github_actions__task_history.sql b/models/github_actions/github_actions__task_history.sql new file mode 100644 index 00000000..9c35ce78 --- /dev/null +++ b/models/github_actions/github_actions__task_history.sql @@ -0,0 +1,5 @@ +{{ config( + materialized = 'view' +) }} + +{{ fsc_utils.gha_task_history_view() }} \ No newline at end of file diff --git a/models/github_actions/github_actions__task_performance.sql b/models/github_actions/github_actions__task_performance.sql new file mode 100644 index 00000000..117ded55 --- /dev/null +++ b/models/github_actions/github_actions__task_performance.sql @@ -0,0 +1,5 @@ +{{ config( + materialized = 'view' +) }} + +{{ fsc_utils.gha_task_performance_view() }} \ No newline at end of file diff --git a/models/github_actions/github_actions__task_schedule.sql b/models/github_actions/github_actions__task_schedule.sql new file mode 100644 index 00000000..ff95a44b --- /dev/null +++ b/models/github_actions/github_actions__task_schedule.sql @@ -0,0 +1,5 @@ +{{ config( + materialized = 'view' +) }} + +{{ fsc_utils.gha_task_schedule_view() }} \ No newline at end of file diff --git a/models/github_actions/github_actions__tasks.sql b/models/github_actions/github_actions__tasks.sql new file mode 100644 index 00000000..feab82a8 --- /dev/null +++ b/models/github_actions/github_actions__tasks.sql @@ -0,0 +1,5 @@ +{{ config( + materialized = 'view' +) }} + +{{ fsc_utils.gha_tasks_view() }} \ No newline at end of file diff --git a/models/sources.yml b/models/sources.yml index 2c25f5bd..edb8d483 100644 --- a/models/sources.yml +++ b/models/sources.yml @@ -64,3 +64,8 @@ sources: schema: bronze_api tables: - name: contract_abis + - name: github_actions + database: optimism + schema: github_actions + tables: + - name: workflows diff --git a/packages.yml b/packages.yml index f6e3a9f2..7bb0ca92 100644 --- a/packages.yml +++ b/packages.yml @@ -6,6 +6,6 @@ packages: - package: dbt-labs/dbt_utils version: 1.0.0 - git: https://github.com/FlipsideCrypto/fsc-utils.git - revision: v1.6.2 + revision: v1.9.3 - package: get-select/dbt_snowflake_query_tags version: [">=2.0.0", "<3.0.0"] \ No newline at end of file