Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tatiana committed May 9, 2024
1 parent 049ae75 commit 7f9927a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/test_example_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
EXAMPLE_DAGS_DIR = Path(__file__).parent.parent / "dev/dags"
AIRFLOW_IGNORE_FILE = EXAMPLE_DAGS_DIR / ".airflowignore"
DBT_VERSION = Version(get_dbt_version().to_version_string()[1:])
AIRFLOW_VERSION = Version(airflow.__version__)

MIN_VER_DAG_FILE: dict[str, list[str]] = {
"2.4": ["cosmos_seed_dag.py"],
Expand Down Expand Up @@ -51,12 +52,12 @@ def session():
@cache
def get_dag_bag() -> DagBag:
"""Create a DagBag by adding the files that are not supported to .airflowignore"""
if AIRFLOW_VERSION in PARTIALLY_SUPPORTED_AIRFLOW_VERSIONS:
return DagBag(dag_folder=None, include_examples=False)

with open(AIRFLOW_IGNORE_FILE, "w+") as file:
for min_version, files in MIN_VER_DAG_FILE_VER.items():
if (
Version(airflow.__version__) < min_version
or Version(airflow.__version__) in PARTIALLY_SUPPORTED_AIRFLOW_VERSIONS
):
if AIRFLOW_VERSION < min_version:
print(f"Adding {files} to .airflowignore")
file.writelines([f"{file}\n" for file in files])

Expand All @@ -83,6 +84,10 @@ def get_dag_ids() -> list[str]:
return dag_bag.dag_ids


@pytest.mark.skipif(
AIRFLOW_VERSION in PARTIALLY_SUPPORTED_AIRFLOW_VERSIONS,
reason="Airflow 2.9.0 and 2.9.1 have a breaking change in Dataset URIs, and Cosmos errors if `emit_datasets` is not False",
)
@pytest.mark.integration
@pytest.mark.parametrize("dag_id", get_dag_ids())
def test_example_dag(session, dag_id: str):
Expand Down

0 comments on commit 7f9927a

Please sign in to comment.