Skip to content

Commit

Permalink
move inline test scripts to dedicated directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaneve committed Jan 31, 2024
1 parent 969805e commit 9a5b50c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 105 deletions.
137 changes: 32 additions & 105 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ description = "Orchestrate your dbt projects in Airflow"
readme = "README.rst"
license = "Apache-2.0"
requires-python = ">=3.8"
authors = [
{ name = "Astronomer", email = "[email protected]" },
]
keywords = [
"airflow",
"apache-airflow",
"astronomer",
"dags",
"dbt",
]
authors = [{ name = "Astronomer", email = "[email protected]" }]
keywords = ["airflow", "apache-airflow", "astronomer", "dags", "dbt"]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
Expand Down Expand Up @@ -55,48 +47,23 @@ dbt-all = [
"dbt-spark",
"dbt-vertica",
]
dbt-athena = [
"dbt-athena-community",
"apache-airflow-providers-amazon>=8.0.0",
]
dbt-bigquery = [
"dbt-bigquery",
]
dbt-databricks = [
"dbt-databricks",
]
dbt-exasol = [
"dbt-exasol",
]
dbt-postgres = [
"dbt-postgres",
]
dbt-redshift = [
"dbt-redshift",
]
dbt-snowflake = [
"dbt-snowflake",
]
dbt-spark = [
"dbt-spark",
]
dbt-vertica = [
"dbt-vertica<=1.5.4",
]
openlineage = [
"openlineage-integration-common",
"openlineage-airflow",
]
all = [
"astronomer-cosmos[dbt-all]",
"astronomer-cosmos[openlineage]"
]
docs =[
dbt-athena = ["dbt-athena-community", "apache-airflow-providers-amazon>=8.0.0"]
dbt-bigquery = ["dbt-bigquery"]
dbt-databricks = ["dbt-databricks"]
dbt-exasol = ["dbt-exasol"]
dbt-postgres = ["dbt-postgres"]
dbt-redshift = ["dbt-redshift"]
dbt-snowflake = ["dbt-snowflake"]
dbt-spark = ["dbt-spark"]
dbt-vertica = ["dbt-vertica<=1.5.4"]
openlineage = ["openlineage-integration-common", "openlineage-airflow"]
all = ["astronomer-cosmos[dbt-all]", "astronomer-cosmos[openlineage]"]
docs = [
"sphinx",
"pydata-sphinx-theme",
"sphinx-autobuild",
"sphinx-autoapi",
"apache-airflow-providers-cncf-kubernetes>=5.1.1"
"apache-airflow-providers-cncf-kubernetes>=5.1.1",
]
tests = [
"packaging",
Expand All @@ -111,15 +78,9 @@ tests = [
"mypy",
"sqlalchemy-stubs", # Change when sqlalchemy is upgraded https://docs.sqlalchemy.org/en/14/orm/extensions/mypy.html
]
docker = [
"apache-airflow-providers-docker>=3.5.0",
]
kubernetes = [
"apache-airflow-providers-cncf-kubernetes>=5.1.1",
]
pydantic = [
"pydantic>=1.10.0",
]
docker = ["apache-airflow-providers-docker>=3.5.0"]
kubernetes = ["apache-airflow-providers-cncf-kubernetes>=5.1.1"]
pydantic = ["pydantic>=1.10.0"]

[project.entry-points.cosmos]
provider_info = "cosmos:get_provider_info"
Expand All @@ -133,9 +94,7 @@ Documentation = "https://astronomer.github.io/astronomer-cosmos"
path = "cosmos/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/cosmos",
]
include = ["/cosmos"]

[tool.hatch.build.targets.wheel]
packages = ["cosmos"]
Expand All @@ -156,13 +115,14 @@ dependencies = [
"apache-airflow-providers-docker>=3.5.0",
]
# Airflow install with constraint file, Airflow versions < 2.7 require a workaround for PyYAML
pre-install-commands = ["""
pre-install-commands = [
"""
if [[ "2.3 2.4 2.5 2.6" =~ "{matrix:airflow}" ]]; then
echo "Cython < 3" >> /tmp/constraint.txt
pip wheel "PyYAML==6.0.0" -c /tmp/constraint.txt
fi
pip install 'apache-airflow=={matrix:airflow}' --constraint 'https://raw.githubusercontent.com/apache/airflow/constraints-{matrix:airflow}.0/constraints-{matrix:python}.txt'
"""
""",
]
[[tool.hatch.envs.tests.matrix]]
python = ["3.8", "3.9", "3.10"]
Expand All @@ -172,51 +132,18 @@ airflow = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8"]
[tool.hatch.envs.tests.scripts]
freeze = "pip freeze"
type-check = "mypy cosmos"
test = 'pytest -vv --durations=0 . -m "not integration" --ignore=tests/test_example_dags.py --ignore=tests/test_example_dags_no_connections.py'
test-cov = """pytest -vv --cov=cosmos --cov-report=term-missing --cov-report=xml --durations=0 -m "not integration" --ignore=tests/test_example_dags.py --ignore=tests/test_example_dags_no_connections.py"""
# we install using the following workaround to overcome installation conflicts, such as:
# apache-airflow 2.3.0 and dbt-core [0.13.0 - 1.5.2] and jinja2>=3.0.0 because these package versions have conflicting dependencies
test-integration-setup = """pip uninstall -y dbt-postgres dbt-databricks dbt-vertica; \
rm -rf airflow.*; \
airflow db init; \
pip install 'dbt-core' 'dbt-databricks' 'dbt-postgres' 'dbt-vertica' 'openlineage-airflow'"""
test-integration = """rm -rf dbt/jaffle_shop/dbt_packages;
pytest -vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m integration \
-k 'not (sqlite or example_cosmos_sources or example_cosmos_python_models or example_virtualenv)'"""
test-integration-expensive = """pytest -vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m integration \
-k 'example_cosmos_python_models or example_virtualenv'"""
test-integration-sqlite-setup = """pip uninstall -y dbt-core dbt-sqlite openlineage-airflow openlineage-integration-common; \
rm -rf airflow.*; \
airflow db init; \
pip install 'dbt-core==1.4' 'dbt-sqlite<=1.4' 'dbt-databricks<=1.4' 'dbt-postgres<=1.4' """
test-integration-sqlite = """
pytest -vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m integration \
-k 'example_cosmos_sources or sqlite'"""
test-unit = 'sh scripts/test/unit.sh'
test-unit-cov = 'sh scripts/test/unit-cov.sh'
test-integration-setup = 'sh scripts/test/integration-setup.sh'
test-integration = 'sh scripts/test/integration.sh'
test-integration-expensive = 'sh scripts/test/integration-expensive.sh'
test-integration-sqlite-setup = 'sh scripts/test/integration-sqlite-setup.sh'
test-integration-sqlite = 'sh scripts/test/integration-sqlite.sh'

[tool.pytest.ini_options]
filterwarnings = [
"ignore::DeprecationWarning",
]
filterwarnings = ["ignore::DeprecationWarning"]
minversion = "6.0"
markers = [
"integration",
"sqlite"
]
markers = ["integration", "sqlite"]

######################################
# DOCS
Expand All @@ -230,7 +157,7 @@ dependencies = [
"sphinx-autobuild",
"sphinx-autoapi",
"openlineage-airflow",
"apache-airflow-providers-cncf-kubernetes>=5.1.1"
"apache-airflow-providers-cncf-kubernetes>=5.1.1",
]

[tool.hatch.envs.docs.scripts]
Expand Down
7 changes: 7 additions & 0 deletions scripts/test/integration-expensive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pytest -vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m integration \
-k 'example_cosmos_python_models or example_virtualenv'
6 changes: 6 additions & 0 deletions scripts/test/integration-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# we install using the following workaround to overcome installation conflicts, such as:
# apache-airflow 2.3.0 and dbt-core [0.13.0 - 1.5.2] and jinja2>=3.0.0 because these package versions have conflicting dependencies
pip uninstall -y dbt-postgres dbt-databricks dbt-vertica; \
rm -rf airflow.*; \
airflow db init; \
pip install 'dbt-core' 'dbt-databricks' 'dbt-postgres' 'dbt-vertica' 'openlineage-airflow'
4 changes: 4 additions & 0 deletions scripts/test/integration-sqlite-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip uninstall -y dbt-core dbt-sqlite openlineage-airflow openlineage-integration-common; \
rm -rf airflow.*; \
airflow db init; \
pip install 'dbt-core==1.4' 'dbt-sqlite<=1.4' 'dbt-databricks<=1.4' 'dbt-postgres<=1.4'
7 changes: 7 additions & 0 deletions scripts/test/integration-sqlite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pytest -vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m integration \
-k 'example_cosmos_sources or sqlite'"""
8 changes: 8 additions & 0 deletions scripts/test/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rm -rf dbt/jaffle_shop/dbt_packages;
pytest -vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m integration \
-k 'not (sqlite or example_cosmos_sources or example_cosmos_python_models or example_virtualenv)'
9 changes: 9 additions & 0 deletions scripts/test/unit-cov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pytest \
-vv \
--cov=cosmos \
--cov-report=term-missing \
--cov-report=xml \
--durations=0 \
-m "not integration" \
--ignore=tests/test_example_dags.py \
--ignore=tests/test_example_dags_no_connections.p
6 changes: 6 additions & 0 deletions scripts/test/unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pytest \
-vv \
--durations=0 \
-m "not integration" \
--ignore=tests/test_example_dags.py \
--ignore=tests/test_example_dags_no_connections.py

0 comments on commit 9a5b50c

Please sign in to comment.