Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ class PrepareReleaseDocsUserQuitException(Exception):
}


def classification_result(changed_files):
def classification_result(provider_id, changed_files):
provider_path = f"providers/{provider_id}/"
changed_files = list(filter(lambda f: f.startswith(provider_path), changed_files))

if not changed_files:
return "other"

Expand All @@ -214,7 +217,7 @@ def classification_result(changed_files):
return "other"


def classify_provider_pr_files(commit_hash: str) -> str:
def classify_provider_pr_files(provider_id: str, commit_hash: str) -> str:
"""
Classify a provider commit based on changed files.

Expand All @@ -235,7 +238,7 @@ def classify_provider_pr_files(commit_hash: str) -> str:
# safe to return other here
return "other"

return classification_result(changed_files)
return classification_result(provider_id, changed_files)


def _get_git_log_command(
Expand Down Expand Up @@ -827,7 +830,7 @@ def update_release_notes(
)
change = list_of_list_of_changes[0][table_iter]

classification = classify_provider_pr_files(change.full_hash)
classification = classify_provider_pr_files(provider_id, change.full_hash)
if classification == "documentation":
get_console().print(
f"[green]Automatically classifying change as DOCUMENTATION since it contains only doc changes:[/]\n"
Expand Down
39 changes: 32 additions & 7 deletions dev/breeze/tests/test_provider_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,20 @@ def test_get_most_impactful_change(changes, expected):


@pytest.mark.parametrize(
"changed_files, expected",
"provider_id, changed_files, expected",
[
pytest.param(["providers/slack/docs/slack.rst"], "documentation", id="only_docs"),
pytest.param(["providers/slack/tests/test_slack.py"], "test_or_example_only", id="only_tests"),
pytest.param("slack", ["providers/slack/docs/slack.rst"], "documentation", id="only_docs"),
pytest.param(
"slack", ["providers/slack/tests/test_slack.py"], "test_or_example_only", id="only_tests"
),
pytest.param(
"slack",
["providers/slack/src/airflow/providers/slack/example_dags/example_notify.py"],
"test_or_example_only",
id="only_example_dags",
),
pytest.param(
"slack",
[
"providers/slack/tests/test_slack.py",
"providers/slack/src/airflow/providers/slack/example_dags/example_notify.py",
Expand All @@ -413,6 +417,7 @@ def test_get_most_impactful_change(changes, expected):
id="tests_and_example_dags",
),
pytest.param(
"slack",
[
"providers/slack/tests/test_slack.py",
"providers/slack/docs/slack.rst",
Expand All @@ -421,6 +426,7 @@ def test_get_most_impactful_change(changes, expected):
id="docs_and_tests",
),
pytest.param(
"slack",
[
"providers/slack/src/airflow/providers/slack/hooks/slack.py",
"providers/slack/docs/slack.rst",
Expand All @@ -429,17 +435,36 @@ def test_get_most_impactful_change(changes, expected):
id="docs_and_real_code",
),
pytest.param(
"slack",
[
"providers/slack/src/airflow/providers/slack/hooks/slack.py",
"providers/slack/tests/test_slack.py",
],
"other",
id="real_code_and_tests",
),
pytest.param(["airflow/utils/db.py"], "other", id="non_provider_file"),
pytest.param([], "other", id="empty_commit"),
pytest.param(
"google",
[
"providers/google/tests/some_test.py",
"providers/amazon/tests/test_something.py",
],
"test_or_example_only",
id="tests_in_multiple_providers",
),
pytest.param(
"amazon",
[
"providers/google/tests/some_test.py",
"providers/amazon/tests/test_something.py",
],
"test_or_example_only",
id="tests_in_multiple_providers",
),
pytest.param("slack", ["airflow/utils/db.py"], "other", id="non_provider_file"),
pytest.param("slack", [], "other", id="empty_commit"),
],
)
def test_classify_provider_pr_files_logic(changed_files, expected):
result = classification_result(changed_files)
def test_classify_provider_pr_files_logic(provider_id, changed_files, expected):
result = classification_result(provider_id, changed_files)
assert result == expected