Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Dec 4, 2024
2 parents b5e7e68 + 40b083a commit d4542a1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 25 deletions.
47 changes: 26 additions & 21 deletions sr-data/src/sr_data/steps/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,33 @@ def workflow_info(content):
if runs is not None and not isinstance(runs, dict):
if runs.startswith("$"):
matrix = jdetails.get("strategy").get("matrix")
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]):
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 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]):
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()
)
)
)
else:
oss.append(runs)
elif isinstance(runs, dict):
if runs.get("group"):
oss.append(runs.get("group"))
Expand Down
3 changes: 2 additions & 1 deletion sr-data/src/tests/resources/to-workflows.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ lanylow/honkai-dumper,main,
BillyDM/vitalium-verb,main,"build.yml"
polespinasa/bitcoin-grouphug,main,"ci.yml"
rohaquinlop/complexipy,main,"CI.yml"
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"
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"
LyonSyonII/run,main,"release.yml"
34 changes: 31 additions & 3 deletions sr-data/src/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def test_collects_workflows_for_all(self):
frame = pd.read_csv(path)
self.assertTrue(
all(col in frame.columns for col in
["workflows", "w_jobs", "w_oss", "w_steps", "w_has_releases"]),
["workflows", "w_jobs", "w_oss", "w_steps",
"w_has_releases"]),
f"Frame {frame.columns} doesn't have expected columns"
)

Expand All @@ -142,7 +143,7 @@ def test_counts_workflows_correctly(self):
result = frame["workflows"].tolist()
self.assertEqual(
result,
[4, 0, 2, 1, 1, 0, 2, 0, 0, 1, 1, 1, 10],
[4, 0, 2, 1, 1, 0, 2, 0, 0, 1, 1, 1, 10, 1],
"Workflows counts don't match with expected"
)

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


@pytest.mark.fast
def test_returns_false_when_no_release(self):
self.assertFalse(
Expand Down Expand Up @@ -254,3 +254,31 @@ def test_outputs_workflow_info_with_nested_expression(self):
4,
f"Steps count in workflow: '{info}' does not match with expected"
)

@pytest.mark.fast
def test_skips_matrix_as_text(self):
info = workflow_info(
"""
on: push
jobs:
plan:
strategy:
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
runs-on: ubuntu-latest
"""
)
self.assertEqual(
info["w_oss"],
["ubuntu-latest"],
f"Workflow OSs: '{info}' does not match with expected"
)
self.assertEqual(
info["w_jobs"],
1,
f"Jobs count in workflow: '{info}' does not match with expected"
)
self.assertEqual(
info["w_steps"],
0,
f"Steps count in workflow: '{info}' does not match with expected"
)

0 comments on commit d4542a1

Please sign in to comment.