Skip to content

Commit

Permalink
Removed unstable symlink capability (#499)
Browse files Browse the repository at this point in the history
* Removed unstable symlink capability
* Address pylint reported issues
  • Loading branch information
andreas-el committed Jun 3, 2024
1 parent a5b7534 commit 0c6e449
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 66 deletions.
2 changes: 1 addition & 1 deletion komodo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def _main(args: KomodoNamespace) -> None:
args: KomodoNamespace instance with configuration
"""
data = Data(extra_data_dirs=args.extra_data_dirs)

git_hashes = None
if args.download or (not args.build and not args.install):
git_hashes = download_packages(
args.pkgs.content,
Expand Down
1 change: 1 addition & 0 deletions komodo/release_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _pick_package_versions_for_release(
"""
release_dict = {}
for pkg_name, versions in packages.items():
version = None
try:
_check_version_exists_for_coordinates(versions, rhel_ver, py_ver)
except KeyError as err:
Expand Down
2 changes: 1 addition & 1 deletion komodo/symlink/suggester/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _parse_args():
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("release", help="e.g. 2019.12.rc0-py38")
parser.add_argument("mode", help="stable,testing,unstable")
parser.add_argument("mode", help="stable,testing")
parser.add_argument("joburl", help="link to the job that triggered this")
parser.add_argument("jobname", help="name of the job")
parser.add_argument(
Expand Down
6 changes: 1 addition & 5 deletions komodo/symlink/suggester/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ def update(self, release, mode):
link_exists = link in self.links
linked_release = self._get_concrete_release(link) if link_exists else None

if mode == "unstable":
if not linked_release or release.monthly_diff(linked_release) >= 0:
self.links[link] = repr(release)

elif mode == "testing":
if mode == "testing":
stable_link = f"stable-{release.py_ver()}"
stable = (
self._get_concrete_release(stable_link)
Expand Down
7 changes: 2 additions & 5 deletions tests/data/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
"root_folder" : "test_dir",
"root_links" : [
"bleeding",
"unstable",
"stable"
],
"links": {
"2012.01": "2012.01.12",
"unstable": "2012.01.rc1",
"testing": "2012.01",
"stable" : "testing",
"testing": "2012.01.rc1",
"stable" : "2012.01.12",
"bleeding": "testing"
}
}
10 changes: 1 addition & 9 deletions tests/data/links_full.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"root_links" : [
"bleeding-py2",
"bleeding",
"unstable-py2",
"unstable",
"testing-py2",
"testing",
"stable-py2",
Expand All @@ -16,13 +14,7 @@
"bleeding-py3" : "bleeding-py36",
"bleeding-py2" : "bleeding-py27",
"bleeding" : "bleeding-py3",

"unstable-py36" : "2020.01.a0-py36",
"unstable-py3" : "unstable-py36",
"unstable-py27" : "2020.01.a0-py27",
"unstable-py2" : "unstable-py27",
"unstable" : "unstable-py3",


"testing-py36" : "2020.01.a0-py36",
"testing-py3" : "testing-py36",
"testing-py27" : "2020.01.a0-py27",
Expand Down
36 changes: 15 additions & 21 deletions tests/test_link_io_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ def test_read_folder_structure(tmpdir):

os.symlink("2012.01.12", "2012.01")
os.symlink("2012.01", "stable")
os.symlink("2012.01", "testing")
os.symlink("2012.01.rc2", "unstable")
os.symlink("2012.01.rc2", "testing")

expected_result = {
"root_folder": tmpdir,
"root_links": ["stable", "unstable", "testing"],
"root_links": ["stable", "testing"],
"links": {
"2012.01": "2012.01.12",
"stable": "2012.01",
"testing": "2012.01",
"unstable": "2012.01.rc2",
"testing": "2012.01.rc2",
},
}

Expand All @@ -53,8 +51,7 @@ def test_create_symlinks(tmpdir):
"links": {
"2012.01": "2012.01.12",
"stable": "2012.01",
"testing": "2012.01",
"unstable": "2012.01.rc2",
"testing": "2012.01.rc2",
},
}

Expand All @@ -67,7 +64,7 @@ def test_create_symlinks(tmpdir):
assert os.path.islink("stable")
assert os.readlink("stable") == "2012.01"
assert os.path.realpath("stable") == os.path.realpath("2012.01.12")
assert os.path.realpath("unstable") == os.path.realpath("2012.01.rc2")
assert os.path.realpath("testing") == os.path.realpath("2012.01.rc2")


def test_create_symlink_stdout(tmpdir, capsys):
Expand Down Expand Up @@ -170,12 +167,11 @@ def test_link_integrity(tmpdir):

test_dict = {
"root_folder": tmpdir,
"root_links": ["stable", "unstable", "testing"],
"root_links": ["stable", "testing"],
"links": {
"2012.01": "2012.01.12",
"stable": "2012.01",
"testing": "2012.01",
"unstable": "2012.01.rc2",
"testing": "2012.01.rc2",
},
}

Expand All @@ -186,10 +182,10 @@ def test_link_integrity(tmpdir):
errors = verify_integrity(test_dict)
assert errors == ["bleeding_py3 does not exist"]

test_dict["links"]["2012.01.rc2"] = "unstable"
test_dict["links"]["2012.01.rc2"] = "testing"
errors = verify_integrity(test_dict)
assert "2012.01.rc2 is part of a cyclic symlink" in errors
assert "unstable is part of a cyclic symlink" in errors
assert "testing is part of a cyclic symlink" in errors


def test_root_folder_error(tmpdir):
Expand All @@ -198,12 +194,11 @@ def test_root_folder_error(tmpdir):

test_dict = {
"root_folder": os.path.join(str(tmpdir), "non_existing"),
"root_links": ["stable", "unstable", "testing"],
"root_links": ["stable", "testing"],
"links": {
"2012.01": "2012.01.12",
"stable": "2012.01",
"testing": "2012.01",
"unstable": "2012.01.rc2",
"testing": "2012.01.rc2",
},
}

Expand All @@ -223,12 +218,11 @@ def test_link_error(tmpdir):

test_dict = {
"root_folder": tmpdir,
"root_links": ["stable", "unstable", "testing"],
"root_links": ["stable", "testing"],
"links": {
"2012.01": "2012.01.12",
"stable": "2012.01",
"testing": "2012.01",
"unstable": "2012.01.rc2",
"testing": "2012.01.rc2",
},
}
with pytest.raises(ValueError) as value_error:
Expand All @@ -242,11 +236,11 @@ def test_root_link_error(tmpdir):

test_dict = {
"root_folder": tmpdir,
"root_links": ["stable", "unstable", "testing"],
"root_links": ["stable", "testing"],
"links": {
"2012.01": "2012.01.12",
"stable": "2012.01",
"unstable": "2012.01.rc2",
"testing": "2012.01.rc2",
},
}
with pytest.raises(ValueError) as value_error:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def test_assert_root_nodes_error_message_incorrectly_added_roots():
"links": {
"stable": "2012.01",
"testing": "2012.03",
"unstable": "testing",
"deprecated": "testing",
},
"root_links": ["unstable", "stable", "testing"],
"root_links": ["deprecated", "stable", "testing"],
}

with pytest.raises(
Expand Down
29 changes: 7 additions & 22 deletions tests/test_suggester.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def test_py_ver(release_id, expected):
@pytest.mark.parametrize(
("conf", "link", "concrete"),
[
# unstable happy path
# testing happy path
(
{
"links": {
"unstable-py27": "1349.01-py27",
"testing-py27": "1349.01-py27",
"1349.01-py27": "1349.02-py27",
"1349.02-py27": "1349.01.a0-py27",
},
},
"unstable-py27",
"testing-py27",
"1349.01.a0-py27",
),
],
Expand All @@ -82,33 +82,18 @@ def test_get_concrete_release(conf, link, concrete):
@pytest.mark.parametrize(
("json_in", "release_id", "mode", "changed", "json_out"),
[
# unstable happy path
# testing happy path
(
"""{"links": {
"unstable-py27": "1994.12.00.rc0-py27",
"testing-py27" : "1994.11.a0-py27",
"testing-py27": "1994.12.00.rc0-py27",
"1994.12-py27" : "1994.12.00.rc0-py27"}}""",
"1994.12.00.rc1-py27",
"unstable",
"testing",
"changed",
"""{
"links": {
"1994.12-py27": "1994.12.00.rc0-py27",
"testing-py27": "1994.11.a0-py27",
"unstable-py27": "1994.12.00.rc1-py27"
}
}
""",
),
# unstable should not be demoted
(
"""{"links": {"unstable-py27": "1998.12.00-py27"}}""",
"1997.01.00.rc1-py27",
"unstable",
"unchanged",
"""{
"links": {
"unstable-py27": "1998.12.00-py27"
"testing-py27": "1994.12.00.rc1-py27"
}
}
""",
Expand Down

0 comments on commit 0c6e449

Please sign in to comment.