From 10c5361df60cfca17baf0de59127301fc6fafa69 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sun, 1 Jan 2023 23:28:25 +0100 Subject: [PATCH] Improve check for system tests TOC in providers (#28666) The TOC for system tests check did not check if the index has been added before automatically generated part of the index. This PR checks if the index is added before the automatically generated lines and explains that the entry should be added before the comment indicating beginning of the automatucally generated part. --- docs/apache-airflow-providers-ftp/index.rst | 13 ++++++------- ...pre_commit_check_system_tests_hidden_in_index.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/apache-airflow-providers-ftp/index.rst b/docs/apache-airflow-providers-ftp/index.rst index 75bc3bd5756b7..f3194e77d6965 100644 --- a/docs/apache-airflow-providers-ftp/index.rst +++ b/docs/apache-airflow-providers-ftp/index.rst @@ -43,8 +43,13 @@ Content PyPI Repository Installing from sources -.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME! +.. toctree:: + :hidden: + :caption: System tests + System Tests <_api/tests/system/providers/ftp/index> + +.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME! .. toctree:: :maxdepth: 1 @@ -52,12 +57,6 @@ Content Detailed list of commits -.. toctree:: - :hidden: - :caption: System tests - - System Tests <_api/tests/system/providers/ftp/index> - Package apache-airflow-providers-ftp ------------------------------------------------------ diff --git a/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py b/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py index 3cc29e5a03b3e..c8adab41b45fb 100755 --- a/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py +++ b/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py @@ -56,10 +56,16 @@ def check_system_test_entry_hidden(provider_index: Path): """ index_text = provider_index.read_text() system_tests_path = AIRFLOW_SOURCES_ROOT / "tests" / "system" / "providers" / provider_path + index_text_manual = index_text.split( + ".. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME!" + )[0] if system_tests_path.exists(): - if expected_text not in index_text: + if expected_text not in index_text_manual: console.print(f"[red]The {provider_index} does not contain System Tests TOC.\n") - console.print(f"[yellow]Make sure to add those lines to {provider_index}:\n") + console.print( + f"[yellow]Make sure to add those lines to {provider_index} BEFORE (!) the line " + f"starting with '.. THE REMINDER OF THE FILE':\n" + ) console.print(expected_text, markup=False) errors.append(provider_index) else: