Skip to content

Commit

Permalink
Validate intermediate links in symlink configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Jun 10, 2024
1 parent c1ca2e6 commit 24aa7d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions komodo/lint_symlink_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import json
import os
import re
import sys
from pathlib import Path
from typing import Mapping, Union
Expand All @@ -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!")


Expand Down
20 changes: 20 additions & 0 deletions tests/test_sanity_check.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from komodo.lint_symlink_config import lint_symlink_config
from komodo.symlink.sanity_check import assert_root_nodes


Expand Down Expand Up @@ -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)

0 comments on commit 24aa7d8

Please sign in to comment.