diff --git a/komodo/lint_symlink_config.py b/komodo/lint_symlink_config.py index f7b853d8..4dabf8f4 100644 --- a/komodo/lint_symlink_config.py +++ b/komodo/lint_symlink_config.py @@ -1,6 +1,7 @@ import argparse import json import os +import re import sys from pathlib import Path from typing import Mapping, Union @@ -22,6 +23,18 @@ def parse_args(): def lint_symlink_config(link_dict: Mapping[str, Union[Mapping, str]]): assert_root_nodes(link_dict) + + links = link_dict["links"] + komodo_release_regex = r"^\d{4}\.\d{2}\..*-py\d+$" + + for dest in links.values(): + if ( + dest not in links + and "bleeding-py" not in dest + and not re.search(komodo_release_regex, dest) + ): + raise SystemExit(f"Missing symlink {dest}") + print("Symlink configuration file is valid!") diff --git a/tests/test_sanity_check.py b/tests/test_sanity_check.py index 2baf1904..bf446706 100644 --- a/tests/test_sanity_check.py +++ b/tests/test_sanity_check.py @@ -1,5 +1,6 @@ import pytest +from komodo.lint_symlink_config import lint_symlink_config from komodo.symlink.sanity_check import assert_root_nodes @@ -37,3 +38,22 @@ def test_assert_root_nodes_error_message_incorrectly_added_roots(): match=r"Incorrectly added root\(s\): \['testing'\]", ): assert_root_nodes(link_dict) + + +def test_symlink_config_detect_missing_intermediate_link(): + link_dict = { + "links": { + "stable": "2012.01", + "2012.01": "2012.01.04-py38", + "testing": "2012.03", + "2012.03": "2012.03.rc4-py38", + "deprecated": "testing", + "testing-py311": "2024.05-py311", + }, + "root_links": ["deprecated", "stable", "testing-py311"], + } + with pytest.raises( + SystemExit, + match=r"Missing symlink 2024.05-py311", + ): + lint_symlink_config(link_dict)