diff --git a/.circleci/integration-tests/master_dag.py b/.circleci/integration-tests/master_dag.py index 331826a4b..bb7d2197f 100644 --- a/.circleci/integration-tests/master_dag.py +++ b/.circleci/integration-tests/master_dag.py @@ -2,7 +2,7 @@ import os import time from datetime import datetime -from typing import List +from typing import Any, List from airflow import DAG from airflow.contrib.operators.slack_webhook_operator import SlackWebhookOperator @@ -19,11 +19,16 @@ SLACK_USERNAME = os.getenv("SLACK_USERNAME", "airflow_app") -def get_report(dag_run_ids: List[str]) -> None: +def get_report(dag_run_ids: List[str], **context: Any) -> None: """Fetch dags run details and generate report""" with create_session() as session: last_dags_runs: List[DagRun] = session.query(DagRun).filter(DagRun.run_id.in_(dag_run_ids)).all() message_list: List[str] = [] + + airflow_version = context["ti"].xcom_pull(task_ids="get_airflow_version") + airflow_version_message = f"Airflow version for the below run is `{airflow_version}` \n\n" + message_list.append(airflow_version_message) + for dr in last_dags_runs: dr_status = f" *{dr.dag_id} : {dr.get_state()}* \n" message_list.append(dr_status) @@ -94,6 +99,10 @@ def prepare_dag_dependency(task_info, execution_time): task_id="list_installed_pip_packages", bash_command="pip freeze" ) + get_airflow_version = BashOperator( + task_id="get_airflow_version", bash_command="airflow version", do_xcom_push=True + ) + dag_run_ids = [] # AWS S3 and Redshift DAG amazon_task_info = [ @@ -194,6 +203,7 @@ def prepare_dag_dependency(task_info, execution_time): python_callable=get_report, op_kwargs={"dag_run_ids": dag_run_ids}, trigger_rule="all_done", + provide_context=True, ) end = DummyOperator( @@ -203,6 +213,7 @@ def prepare_dag_dependency(task_info, execution_time): start >> [ list_installed_pip_packages, + get_airflow_version, amazon_trigger_tasks[0], emr_trigger_tasks[0], google_trigger_tasks[0], @@ -218,6 +229,7 @@ def prepare_dag_dependency(task_info, execution_time): last_task = [ list_installed_pip_packages, + get_airflow_version, amazon_trigger_tasks[-1], emr_trigger_tasks[-1], google_trigger_tasks[-1],