From 801c4d90990cf4bab8b7f3cb43c05433d045bebc Mon Sep 17 00:00:00 2001 From: Rafid Bin Mostofa Date: Fri, 23 Feb 2024 18:39:11 +0600 Subject: [PATCH] chore: fix archive version while logging (#144) Archive version was being changed to 23.1 instead 23.10 for values with trailing zeroes. This commit fixes the bug. https://github.com/canonical/chisel-releases/actions/runs/8014505888/job/21893215155?pr=143 --- .github/scripts/install_slices/install_slices.py | 7 ++++--- .../install_slices/test_install_slices.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/scripts/install_slices/install_slices.py b/.github/scripts/install_slices/install_slices.py index fe645e4b8..d3b88d730 100755 --- a/.github/scripts/install_slices/install_slices.py +++ b/.github/scripts/install_slices/install_slices.py @@ -128,9 +128,10 @@ def parse_archive(release: str) -> Archive: sys.exit(1) # load the yaml data into Archive archive_data = data["archives"]["ubuntu"] - archive = Archive( - str(archive_data["version"]), archive_data["components"], archive_data["suites"] - ) + version = archive_data["version"] + if isinstance(version, float): + version = f"{version:.2f}" + archive = Archive(str(version), archive_data["components"], archive_data["suites"]) return archive diff --git a/.github/scripts/install_slices/test_install_slices.py b/.github/scripts/install_slices/test_install_slices.py index 1447f45bd..49e48cf5f 100644 --- a/.github/scripts/install_slices/test_install_slices.py +++ b/.github/scripts/install_slices/test_install_slices.py @@ -116,6 +116,22 @@ def test_parse_archive(self): # test parsing remote release archive = parse_archive("ubuntu-22.04") self.assertEqual(archive, DEFAULT_ARCHIVE) + # test parsing archive version properly + chisel_yaml = DEFAULT_CHISEL_YAML.replace("22.04", "23.10") + chisel_yaml = chisel_yaml.replace("jammy", "mantic") + with tempfile.TemporaryDirectory() as tmpfs: + filepath = os.path.join(tmpfs, "chisel.yaml") + with open(filepath, "w", encoding="utf-8") as file: + file.write(chisel_yaml) + archive = parse_archive(tmpfs) + self.assertEqual( + archive, + Archive( + version="23.10", + components=["main", "universe"], + suites=["mantic", "mantic-security", "mantic-updates"], + ), + ) def test_full_slice_name(self): """