Skip to content

Commit 7d92859

Browse files
committed
fix(#276): enable parses_none_matrix
1 parent da675ab commit 7d92859

2 files changed

Lines changed: 34 additions & 31 deletions

File tree

sr-data/src/sr_data/steps/workflows.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,37 +90,38 @@ def workflow_info(content):
9090
for r in runs:
9191
oss.append(r)
9292
if not isinstance(runs, list) and runs.startswith("$"):
93-
matrix = jdetails.get("strategy").get("matrix")
94-
if matrix is not None:
95-
if isinstance(matrix, str):
96-
oss.append(runs)
97-
else:
98-
keys = [
99-
key.strip() for key in
100-
runs.strip().replace("${{", "").replace("}}", "")
101-
.split(".")[1:]
102-
]
103-
if len(keys) == 1:
104-
if matrix.get(keys[0]):
105-
for matrixed in matrix.get(keys[0]):
106-
if isinstance(matrixed, list):
107-
for r in matrixed:
108-
oss.append(r)
109-
else:
110-
oss.append(matrixed)
111-
elif len(keys) > 1:
112-
for system in dot_values(keys, matrix):
113-
oss.append(system)
114-
elif matrix.get("include"):
115-
for include in matrix.get("include"):
116-
oss.append(
117-
include.get(
118-
runs.strip()
119-
.replace("${{", "")
120-
.replace("}}", "")
121-
.split(".")[1].strip()
93+
if jdetails.get("strategy"):
94+
matrix = jdetails.get("strategy").get("matrix")
95+
if matrix is not None:
96+
if isinstance(matrix, str):
97+
oss.append(runs)
98+
else:
99+
keys = [
100+
key.strip() for key in
101+
runs.strip().replace("${{", "").replace("}}", "")
102+
.split(".")[1:]
103+
]
104+
if len(keys) == 1:
105+
if matrix.get(keys[0]):
106+
for matrixed in matrix.get(keys[0]):
107+
if isinstance(matrixed, list):
108+
for r in matrixed:
109+
oss.append(r)
110+
else:
111+
oss.append(matrixed)
112+
elif len(keys) > 1:
113+
for system in dot_values(keys, matrix):
114+
oss.append(system)
115+
elif matrix.get("include"):
116+
for include in matrix.get("include"):
117+
oss.append(
118+
include.get(
119+
runs.strip()
120+
.replace("${{", "")
121+
.replace("}}", "")
122+
.split(".")[1].strip()
123+
)
122124
)
123-
)
124125
elif not isinstance(runs, list):
125126
oss.append(runs)
126127
elif isinstance(runs, dict):

sr-data/src/tests/test_workflows.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,11 @@ def test_parses_on_as_string(self):
345345
f"Steps count in workflow: '{info}' does not match with expected"
346346
)
347347

348+
@pytest.mark.fast
348349
def test_parses_none_matrix(self):
349350
info = workflow_info(
350351
"""
352+
on: push
351353
name: test
352354
jobs:
353355
build:
@@ -356,7 +358,7 @@ def test_parses_none_matrix(self):
356358
)
357359
self.assertEqual(
358360
info["w_oss"],
359-
["ubuntu-latest"],
361+
[],
360362
f"Workflow OSs: '{info}' does not match with expected"
361363
)
362364
self.assertEqual(

0 commit comments

Comments
 (0)