Skip to content

Commit

Permalink
fix(#276): enable parses_none_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Dec 4, 2024
1 parent da675ab commit 7d92859
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
61 changes: 31 additions & 30 deletions sr-data/src/sr_data/steps/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,38 @@ def workflow_info(content):
for r in runs:
oss.append(r)
if not isinstance(runs, list) and runs.startswith("$"):
matrix = jdetails.get("strategy").get("matrix")
if matrix is not None:
if isinstance(matrix, str):
oss.append(runs)
else:
keys = [
key.strip() for key in
runs.strip().replace("${{", "").replace("}}", "")
.split(".")[1:]
]
if len(keys) == 1:
if matrix.get(keys[0]):
for matrixed in matrix.get(keys[0]):
if isinstance(matrixed, list):
for r in matrixed:
oss.append(r)
else:
oss.append(matrixed)
elif len(keys) > 1:
for system in dot_values(keys, matrix):
oss.append(system)
elif matrix.get("include"):
for include in matrix.get("include"):
oss.append(
include.get(
runs.strip()
.replace("${{", "")
.replace("}}", "")
.split(".")[1].strip()
if jdetails.get("strategy"):
matrix = jdetails.get("strategy").get("matrix")
if matrix is not None:
if isinstance(matrix, str):
oss.append(runs)
else:
keys = [
key.strip() for key in
runs.strip().replace("${{", "").replace("}}", "")
.split(".")[1:]
]
if len(keys) == 1:
if matrix.get(keys[0]):
for matrixed in matrix.get(keys[0]):
if isinstance(matrixed, list):
for r in matrixed:
oss.append(r)
else:
oss.append(matrixed)
elif len(keys) > 1:
for system in dot_values(keys, matrix):
oss.append(system)
elif matrix.get("include"):
for include in matrix.get("include"):
oss.append(
include.get(
runs.strip()
.replace("${{", "")
.replace("}}", "")
.split(".")[1].strip()
)
)
)
elif not isinstance(runs, list):
oss.append(runs)
elif isinstance(runs, dict):
Expand Down
4 changes: 3 additions & 1 deletion sr-data/src/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,11 @@ def test_parses_on_as_string(self):
f"Steps count in workflow: '{info}' does not match with expected"
)

@pytest.mark.fast
def test_parses_none_matrix(self):
info = workflow_info(
"""
on: push
name: test
jobs:
build:
Expand All @@ -356,7 +358,7 @@ def test_parses_none_matrix(self):
)
self.assertEqual(
info["w_oss"],
["ubuntu-latest"],
[],
f"Workflow OSs: '{info}' does not match with expected"
)
self.assertEqual(
Expand Down

0 comments on commit 7d92859

Please sign in to comment.