Skip to content

Commit

Permalink
Rename --coords to --matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
hnformentin committed Feb 28, 2023
1 parent c24d4ea commit 70e42bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions komodo/release_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def _check_consistency_in_versions(
)


def transpile_releases(matrix_file: str, output_folder: str, coords: dict) -> None:
def transpile_releases(matrix_file: str, output_folder: str, matrix: dict) -> None:
"""Transpile a matrix file possibly containing different os and framework
versions (e.g. rhel6 and rhel7, py3.6 and py3.8).
Write one dimension file for each element in the matrix
(e.g. rhel7 and py3.8, rhel6 and py3.6)"""
rhel_versions = coords["rhel"]
python_versions = coords["py"]
rhel_versions = matrix["rhel"]
python_versions = matrix["py"]

release_base = os.path.splitext(os.path.basename(matrix_file))[0]
release_folder = os.path.dirname(matrix_file)
Expand All @@ -133,7 +133,7 @@ def combine(args):


def transpile(args):
transpile_releases(args.matrix_file, args.output_folder, args.coords)
transpile_releases(args.matrix_file, args.output_folder, args.matrix)


def main():
Expand Down Expand Up @@ -206,11 +206,11 @@ def main():
help="Folder to output new release files",
)
transpile_parser.add_argument(
"--coords",
help="Coordinates of the matrix to be transpiled.",
"--matrix",
help="Matrix to be transpiled.",
type=yaml.safe_load,
required=False,
default="{rhel: ['7'], py: ['3.8']}",
default="{'rhel': ['7'], 'py': ['3.8']}",
)
args = parser.parse_args()
args.func(args)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_release_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@ def test_build_release_matrix(tmpdir):


@pytest.mark.parametrize(
"coords",
"matrix",
[({"py": ["3.8"], "rhel": ["7"]}), ({"py": ["3.8", "3.10"], "rhel": ["7", "8"]})],
)
def test_transpile_add_argument(tmpdir, coords):
def test_transpile_add_argument(tmpdir, matrix):
release_file = os.path.join(_get_test_root(), "data", "test_release_matrix.yml")
release_base = os.path.basename(release_file).strip(".yml")
with tmpdir.as_cwd():
transpile_releases(release_file, os.getcwd(), coords)
rhel_ver_str = f"rhel{coords['rhel'][0]}"
py_ver_str = f"py{coords['py'][0].replace('.', '')}"
transpile_releases(release_file, os.getcwd(), matrix)
rhel_ver_str = f"rhel{matrix['rhel'][0]}"
py_ver_str = f"py{matrix['py'][0].replace('.', '')}"

assert os.path.isfile(
"{}-{}-{}.yml".format(release_base, py_ver_str, rhel_ver_str)
)


@pytest.mark.parametrize(
"coords",
"matrix",
[
({"py": ["3.8"], "rhel": ["7"]}),
({"py": ["3.7"], "rhel": ["7"]}),
({"py": ["3.6"], "rhel": ["5"]}),
],
)
def test_validate_versions_in_args_with_release_file(coords):
def test_validate_versions_in_args_with_release_file(matrix):
release_file = os.path.join(_get_test_root(), "data", "test_release_matrix.yml")
try:
transpile_releases(release_file, os.getcwd(), coords)
transpile_releases(release_file, os.getcwd(), matrix)
except KeyError as exception_info:
assert "not found in package" in str(exception_info)

Expand Down

0 comments on commit 70e42bd

Please sign in to comment.