Skip to content

Commit 4138171

Browse files
perf: optimize CI by skipping redundant dbt test artifacts upload and adding schema cleanup
- Add --vars to dbt test step to disable artifact autoupload (already done during dbt run) and skip per-table temp table cleanup (schema will be dropped at end) - Add drop_test_schemas macro and CI step to drop both main and elementary schemas after tests - This significantly reduces on-run-end hook time, especially for Athena where each query has high overhead (~3-5s) and the hook was issuing 100+ individual queries Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
1 parent c0a9602 commit 4138171

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

.github/workflows/test-warehouse.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ jobs:
192192
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
193193
continue-on-error: true
194194
run: |
195-
dbt test --target "${{ inputs.warehouse-type }}"
195+
dbt test --target "${{ inputs.warehouse-type }}" --vars '{disable_dbt_artifacts_autoupload: true, clean_elementary_temp_tables: false}'
196196
197197
- name: Run help
198198
run: edr --help
@@ -277,3 +277,10 @@ jobs:
277277

278278
- name: Run Python package e2e tests
279279
run: pytest -vv tests/e2e --warehouse-type ${{ inputs.warehouse-type }}
280+
281+
- name: Drop test schemas
282+
if: always()
283+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
284+
continue-on-error: true
285+
run: |
286+
dbt run-operation elementary_tests.drop_test_schemas --target "${{ inputs.warehouse-type }}"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{% macro drop_test_schemas() %}
2+
{# Drop both the main test schema and the elementary schema used by the CLI.
3+
The schema names are derived from the profile's target schema. #}
4+
{% set main_schema = target.schema %}
5+
{% set elementary_schema = main_schema ~ '_elementary' %}
6+
7+
{% do elementary_tests.edr_drop_schema(elementary_schema) %}
8+
{% do elementary_tests.edr_drop_schema(main_schema) %}
9+
{% do log("Dropped schemas: " ~ main_schema ~ ", " ~ elementary_schema, info=true) %}
10+
{% endmacro %}
11+
12+
{% macro edr_drop_schema(schema_name) %}
13+
{% do return(adapter.dispatch('edr_drop_schema', 'elementary_tests')(schema_name)) %}
14+
{% endmacro %}
15+
16+
{% macro default__edr_drop_schema(schema_name) %}
17+
{% set schema_relation = api.Relation.create(database=target.database, schema=schema_name) %}
18+
{% do dbt.drop_schema(schema_relation) %}
19+
{% do adapter.commit() %}
20+
{% endmacro %}
21+
22+
{% macro bigquery__edr_drop_schema(schema_name) %}
23+
{% set schema_relation = api.Relation.create(database=target.database, schema=schema_name) %}
24+
{% do dbt.drop_schema(schema_relation) %}
25+
{% endmacro %}
26+
27+
{% macro clickhouse__edr_drop_schema(schema_name) %}
28+
{% do run_query("DROP DATABASE IF EXISTS " ~ schema_name) %}
29+
{% do adapter.commit() %}
30+
{% endmacro %}
31+
32+
{% macro athena__edr_drop_schema(schema_name) %}
33+
{% set schema_relation = api.Relation.create(database=target.database, schema=schema_name) %}
34+
{% do dbt.drop_schema(schema_relation) %}
35+
{% endmacro %}

0 commit comments

Comments
 (0)