From fd3844853a8d332608fabd4a3eae46830028c88f Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 2 Feb 2024 18:08:15 -0500 Subject: [PATCH] labeler should ignore latest version (#2588) Signed-off-by: Alex Goodman --- .github/scripts/labeler.py | 5 +++-- .github/scripts/labeler_test.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/scripts/labeler.py b/.github/scripts/labeler.py index 21f1e3c15..8b608293f 100644 --- a/.github/scripts/labeler.py +++ b/.github/scripts/labeler.py @@ -176,7 +176,8 @@ def filter_to_schema_files(list_of_files: list[str]) -> list[str]: def list_json_schema_files() -> list[str]: # list files in "schema/json" directory matching the pattern of "schema-*.json" - return sort_json_schema_files(list(glob.glob("schema/json/schema-*.json"))) + # special case: always ignore the "latest" schema file + return sort_json_schema_files([f for f in glob.glob("schema/json/schema-*.json") if "latest" not in f]) def run(command: str, **kwargs) -> subprocess.CompletedProcess: @@ -197,7 +198,7 @@ def sort_json_schema_files(files: list[str]) -> list[str]: # so that "schema/json/schema-1.2.1.json" comes before "schema/json/schema-1.12.1.json". versions = [get_semver(file) for file in files if file] - versions = sorted(versions, key=lambda s: [int(u) for u in s.split('.')]) + versions = sorted(versions, key=lambda s: [int(u) for u in s.split('.') if "." in s]) return [f"schema/json/schema-{version}.json" for version in versions] diff --git a/.github/scripts/labeler_test.py b/.github/scripts/labeler_test.py index 33e583f82..36eebd18c 100644 --- a/.github/scripts/labeler_test.py +++ b/.github/scripts/labeler_test.py @@ -60,6 +60,11 @@ class Labeler(unittest.TestCase): expected_sorted_files = ["schema/json/schema-1.2.1.json", "schema/json/schema-1.12.1.json"] self.assertEqual(labeler.sort_json_schema_files(files), expected_sorted_files) + # ensure that "latest" doesn't cause a problem and is ultimately ignored + files = ["schema/json/schema-1.12.1.json", "schema/json/schema-_bogus.json"] + expected_sorted_files = ["schema/json/schema-_bogus.json", "schema/json/schema-1.12.1.json"] + self.assertEqual(labeler.sort_json_schema_files(files), expected_sorted_files) + if __name__ == "__main__": unittest.main()