Skip to content

Commit

Permalink
fix(pipeline): deactivate unit test in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
hlecuyer committed Jan 9, 2025
1 parent 18001f1 commit 90c5aff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ x-airflow-common:
AIRFLOW_VAR_DORA_API_TOKEN: ${AIRFLOW_VAR_DORA_API_TOKEN}
AIRFLOW_VAR_DORA_API_URL: ${AIRFLOW_VAR_DORA_API_URL}
AIRFLOW_VAR_EMPLOIS_API_TOKEN: ${AIRFLOW_VAR_EMPLOIS_API_TOKEN}
AIRFLOW_VAR_ENVIRONMENT: ${AIRFLOW_VAR_ENVIRONMENT}
AIRFLOW_VAR_FREDO_API_TOKEN: ${AIRFLOW_VAR_FREDO_API_TOKEN}
AIRFLOW_VAR_FT_API_TOKEN: ${AIRFLOW_VAR_FT_API_TOKEN}
AIRFLOW_VAR_MES_AIDES_AIRTABLE_KEY: ${AIRFLOW_VAR_MES_AIDES_AIRTABLE_KEY}
Expand Down
1 change: 1 addition & 0 deletions deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ resource "null_resource" "up" {
AIRFLOW_VAR_DORA_API_TOKEN='${var.dora_api_token}'
AIRFLOW_VAR_DORA_API_URL='${var.dora_api_url}'
AIRFLOW_VAR_EMPLOIS_API_TOKEN='${var.emplois_api_token}'
AIRFLOW_VAR_ENVIRONMENT='${var.environment}'
AIRFLOW_VAR_FREDO_API_TOKEN='${var.fredo_api_token}'
AIRFLOW_VAR_FT_API_TOKEN='${var.ft_api_token}'
AIRFLOW_VAR_MES_AIDES_AIRTABLE_KEY='${var.mes_aides_airtable_key}'
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ x-airflow-common:
AIRFLOW_VAR_MES_AIDES_AIRTABLE_KEY: ${AIRFLOW_VAR_MES_AIDES_AIRTABLE_KEY}
AIRFLOW_VAR_SOLIGUIDE_API_TOKEN: ${AIRFLOW_VAR_SOLIGUIDE_API_TOKEN}
AIRFLOW_VAR_TWOCAPTCHA_API_KEY: ${AIRFLOW_VAR_TWOCAPTCHA_API_KEY}
AIRFLOW_VAR_ENVIRONMENT: test

volumes:
- ./pipeline/dbt:/opt/airflow/dbt
Expand Down
5 changes: 5 additions & 0 deletions pipeline/dags/dag_utils/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def dbt_operator_factory(
select: Optional[str] = None,
exclude: Optional[str] = None,
trigger_rule: TriggerRule = TriggerRule.ALL_SUCCESS,
exclude_unit_tests: bool = False,
) -> bash.BashOperator:
"""A basic factory for bash operators operating dbt commands."""

Expand All @@ -28,6 +29,8 @@ def dbt_operator_factory(
if dbt_vars is not None:
dbt_vars = json.dumps(dbt_vars)
dbt_args += f" --vars '{dbt_vars}'"
if exclude_unit_tests:
dbt_args += " --exclude-resource-type unit_test"

return bash.BashOperator(
task_id=task_id,
Expand Down Expand Up @@ -96,6 +99,7 @@ def get_staging_tasks():


def get_intermediate_tasks():
exclude_unit_tests = True if Variable.get("ENVIRONMENT", None) == "prod" else False
return dbt_operator_factory(
task_id="dbt_build_intermediate",
command="build",
Expand Down Expand Up @@ -128,4 +132,5 @@ def get_intermediate_tasks():
]
),
trigger_rule=TriggerRule.ALL_DONE,
exclude_unit_tests=exclude_unit_tests,
)

0 comments on commit 90c5aff

Please sign in to comment.