Skip to content

Commit

Permalink
labeler should ignore latest version (anchore#2588)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman authored Feb 2, 2024
1 parent 2b3cbc5 commit 699524f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/scripts/labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]

Expand Down
5 changes: 5 additions & 0 deletions .github/scripts/labeler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def test_sort_json_schema_files(self):
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()

0 comments on commit 699524f

Please sign in to comment.