Skip to content

Commit 22126a5

Browse files
committed
Implement matrix sharding
1 parent e985fa1 commit 22126a5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ci-matrix.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
CI_TARGETS_YAML = "ci-targets.yaml"
1717
CI_RUNNERS_YAML = "ci-runners.yaml"
1818
CI_EXTRA_SKIP_LABELS = ["documentation"]
19+
CI_MATRIX_SIZE_LIMIT = 256 # The maximum size of a matrix in GitHub Actions
1920

2021

2122
def meets_conditional_version(version: str, min_version: str) -> bool:
@@ -246,14 +247,19 @@ def main() -> None:
246247
if runner_config.get("free")
247248
}
248249

249-
matrix = {
250-
"include": generate_matrix_entries(
251-
config,
252-
runners,
253-
args.platform,
254-
labels,
255-
)
256-
}
250+
entries = generate_matrix_entries(
251+
config,
252+
runners,
253+
args.platform,
254+
labels,
255+
)
256+
257+
matrix = {}
258+
shards = len(entries) // CI_MATRIX_SIZE_LIMIT
259+
for shard in shards:
260+
matrix[str(shard)] = entries[
261+
shard * CI_MATRIX_SIZE_LIMIT : (shard + 1) * CI_MATRIX_SIZE_LIMIT
262+
]
257263

258264
print(json.dumps(matrix))
259265

0 commit comments

Comments
 (0)