Skip to content

Commit d5e5dff

Browse files
github-actions[bot]amoghrajesh
authored andcommitted
[v3-0-test] Advanced auto classification for provider documentation (#52902) (#52925)
(cherry picked from commit 1996171) Co-authored-by: Amogh Desai <[email protected]>
1 parent 29c6781 commit d5e5dff

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

dev/breeze/src/airflow_breeze/prepare_providers/provider_documentation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ class PrepareReleaseDocsUserQuitException(Exception):
195195
}
196196

197197

198-
def classification_result(changed_files):
198+
def classification_result(provider_id, changed_files):
199+
provider_path = f"providers/{provider_id}/"
200+
changed_files = list(filter(lambda f: f.startswith(provider_path), changed_files))
201+
199202
if not changed_files:
200203
return "other"
201204

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

216219

217-
def classify_provider_pr_files(commit_hash: str) -> str:
220+
def classify_provider_pr_files(provider_id: str, commit_hash: str) -> str:
218221
"""
219222
Classify a provider commit based on changed files.
220223
@@ -235,7 +238,7 @@ def classify_provider_pr_files(commit_hash: str) -> str:
235238
# safe to return other here
236239
return "other"
237240

238-
return classification_result(changed_files)
241+
return classification_result(provider_id, changed_files)
239242

240243

241244
def _get_git_log_command(
@@ -827,7 +830,7 @@ def update_release_notes(
827830
)
828831
change = list_of_list_of_changes[0][table_iter]
829832

830-
classification = classify_provider_pr_files(change.full_hash)
833+
classification = classify_provider_pr_files(provider_id, change.full_hash)
831834
if classification == "documentation":
832835
get_console().print(
833836
f"[green]Automatically classifying change as DOCUMENTATION since it contains only doc changes:[/]\n"

dev/breeze/tests/test_provider_documentation.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,20 @@ def test_get_most_impactful_change(changes, expected):
395395

396396

397397
@pytest.mark.parametrize(
398-
"changed_files, expected",
398+
"provider_id, changed_files, expected",
399399
[
400-
pytest.param(["providers/slack/docs/slack.rst"], "documentation", id="only_docs"),
401-
pytest.param(["providers/slack/tests/test_slack.py"], "test_or_example_only", id="only_tests"),
400+
pytest.param("slack", ["providers/slack/docs/slack.rst"], "documentation", id="only_docs"),
402401
pytest.param(
402+
"slack", ["providers/slack/tests/test_slack.py"], "test_or_example_only", id="only_tests"
403+
),
404+
pytest.param(
405+
"slack",
403406
["providers/slack/src/airflow/providers/slack/example_dags/example_notify.py"],
404407
"test_or_example_only",
405408
id="only_example_dags",
406409
),
407410
pytest.param(
411+
"slack",
408412
[
409413
"providers/slack/tests/test_slack.py",
410414
"providers/slack/src/airflow/providers/slack/example_dags/example_notify.py",
@@ -413,6 +417,7 @@ def test_get_most_impactful_change(changes, expected):
413417
id="tests_and_example_dags",
414418
),
415419
pytest.param(
420+
"slack",
416421
[
417422
"providers/slack/tests/test_slack.py",
418423
"providers/slack/docs/slack.rst",
@@ -421,6 +426,7 @@ def test_get_most_impactful_change(changes, expected):
421426
id="docs_and_tests",
422427
),
423428
pytest.param(
429+
"slack",
424430
[
425431
"providers/slack/src/airflow/providers/slack/hooks/slack.py",
426432
"providers/slack/docs/slack.rst",
@@ -429,17 +435,36 @@ def test_get_most_impactful_change(changes, expected):
429435
id="docs_and_real_code",
430436
),
431437
pytest.param(
438+
"slack",
432439
[
433440
"providers/slack/src/airflow/providers/slack/hooks/slack.py",
434441
"providers/slack/tests/test_slack.py",
435442
],
436443
"other",
437444
id="real_code_and_tests",
438445
),
439-
pytest.param(["airflow/utils/db.py"], "other", id="non_provider_file"),
440-
pytest.param([], "other", id="empty_commit"),
446+
pytest.param(
447+
"google",
448+
[
449+
"providers/google/tests/some_test.py",
450+
"providers/amazon/tests/test_something.py",
451+
],
452+
"test_or_example_only",
453+
id="tests_in_multiple_providers",
454+
),
455+
pytest.param(
456+
"amazon",
457+
[
458+
"providers/google/tests/some_test.py",
459+
"providers/amazon/tests/test_something.py",
460+
],
461+
"test_or_example_only",
462+
id="tests_in_multiple_providers",
463+
),
464+
pytest.param("slack", ["airflow/utils/db.py"], "other", id="non_provider_file"),
465+
pytest.param("slack", [], "other", id="empty_commit"),
441466
],
442467
)
443-
def test_classify_provider_pr_files_logic(changed_files, expected):
444-
result = classification_result(changed_files)
468+
def test_classify_provider_pr_files_logic(provider_id, changed_files, expected):
469+
result = classification_result(provider_id, changed_files)
445470
assert result == expected

0 commit comments

Comments
 (0)