Skip to content

Commit d4542a1

Browse files
committed
Merge branch '__rultor'
2 parents b5e7e68 + 40b083a commit d4542a1

3 files changed

Lines changed: 59 additions & 25 deletions

File tree

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,33 @@ def workflow_info(content):
8888
if runs is not None and not isinstance(runs, dict):
8989
if runs.startswith("$"):
9090
matrix = jdetails.get("strategy").get("matrix")
91-
keys = [
92-
key.strip() for key in
93-
runs.strip().replace("${{", "").replace("}}", "")
94-
.split(".")[1:]
95-
]
96-
if len(keys) == 1:
97-
if matrix.get(keys[0]):
98-
for matrixed in matrix.get(keys[0]):
99-
oss.append(matrixed)
100-
elif len(keys) > 1:
101-
for system in dot_values(keys, matrix):
102-
oss.append(system)
103-
elif matrix.get("include"):
104-
for include in matrix.get("include"):
105-
oss.append(
106-
include.get(
107-
runs.strip()
108-
.replace("${{", "")
109-
.replace("}}", "")
110-
.split(".")[1].strip()
91+
if isinstance(matrix, str):
92+
oss.append(runs)
93+
else:
94+
keys = [
95+
key.strip() for key in
96+
runs.strip().replace("${{", "").replace("}}", "")
97+
.split(".")[1:]
98+
]
99+
if len(keys) == 1:
100+
if matrix.get(keys[0]):
101+
for matrixed in matrix.get(keys[0]):
102+
oss.append(matrixed)
103+
elif len(keys) > 1:
104+
for system in dot_values(keys, matrix):
105+
oss.append(system)
106+
elif matrix.get("include"):
107+
for include in matrix.get("include"):
108+
oss.append(
109+
include.get(
110+
runs.strip()
111+
.replace("${{", "")
112+
.replace("}}", "")
113+
.split(".")[1].strip()
114+
)
111115
)
112-
)
116+
else:
117+
oss.append(runs)
113118
elif isinstance(runs, dict):
114119
if runs.get("group"):
115120
oss.append(runs.get("group"))

sr-data/src/tests/resources/to-workflows.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ lanylow/honkai-dumper,main,
1111
BillyDM/vitalium-verb,main,"build.yml"
1212
polespinasa/bitcoin-grouphug,main,"ci.yml"
1313
rohaquinlop/complexipy,main,"CI.yml"
14-
zkVerify/zkVerify,main,"CI-build-test-publish.yml,CI-build.yml,CI-cache-manager.yml,CI-coverage.yml,CI-lint-format.yml,CI-orchestrator.yml,CI-rustdoc.yml,CI-tag-orchestrator.yml,CI-test.yml,CI-zombienet-test.yml"
14+
zkVerify/zkVerify,main,"CI-build-test-publish.yml,CI-build.yml,CI-cache-manager.yml,CI-coverage.yml,CI-lint-format.yml,CI-orchestrator.yml,CI-rustdoc.yml,CI-tag-orchestrator.yml,CI-test.yml,CI-zombienet-test.yml"
15+
LyonSyonII/run,main,"release.yml"

sr-data/src/tests/test_workflows.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def test_collects_workflows_for_all(self):
123123
frame = pd.read_csv(path)
124124
self.assertTrue(
125125
all(col in frame.columns for col in
126-
["workflows", "w_jobs", "w_oss", "w_steps", "w_has_releases"]),
126+
["workflows", "w_jobs", "w_oss", "w_steps",
127+
"w_has_releases"]),
127128
f"Frame {frame.columns} doesn't have expected columns"
128129
)
129130

@@ -142,7 +143,7 @@ def test_counts_workflows_correctly(self):
142143
result = frame["workflows"].tolist()
143144
self.assertEqual(
144145
result,
145-
[4, 0, 2, 1, 1, 0, 2, 0, 0, 1, 1, 1, 10],
146+
[4, 0, 2, 1, 1, 0, 2, 0, 0, 1, 1, 1, 10, 1],
146147
"Workflows counts don't match with expected"
147148
)
148149

@@ -177,7 +178,6 @@ def test_returns_true_when_workflow_has_push_on_version(self):
177178
"Workflow should be used for releases, but it wasn't"
178179
)
179180

180-
181181
@pytest.mark.fast
182182
def test_returns_false_when_no_release(self):
183183
self.assertFalse(
@@ -254,3 +254,31 @@ def test_outputs_workflow_info_with_nested_expression(self):
254254
4,
255255
f"Steps count in workflow: '{info}' does not match with expected"
256256
)
257+
258+
@pytest.mark.fast
259+
def test_skips_matrix_as_text(self):
260+
info = workflow_info(
261+
"""
262+
on: push
263+
jobs:
264+
plan:
265+
strategy:
266+
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
267+
runs-on: ubuntu-latest
268+
"""
269+
)
270+
self.assertEqual(
271+
info["w_oss"],
272+
["ubuntu-latest"],
273+
f"Workflow OSs: '{info}' does not match with expected"
274+
)
275+
self.assertEqual(
276+
info["w_jobs"],
277+
1,
278+
f"Jobs count in workflow: '{info}' does not match with expected"
279+
)
280+
self.assertEqual(
281+
info["w_steps"],
282+
0,
283+
f"Steps count in workflow: '{info}' does not match with expected"
284+
)

0 commit comments

Comments
 (0)