Skip to content

Commit

Permalink
Implement matrix sharding
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Jan 10, 2025
1 parent e985fa1 commit d22af60
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ci-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CI_TARGETS_YAML = "ci-targets.yaml"
CI_RUNNERS_YAML = "ci-runners.yaml"
CI_EXTRA_SKIP_LABELS = ["documentation"]
CI_MATRIX_SIZE_LIMIT = 256 # The maximum size of a matrix in GitHub Actions


def meets_conditional_version(version: str, min_version: str) -> bool:
Expand Down Expand Up @@ -246,14 +247,19 @@ def main() -> None:
if runner_config.get("free")
}

matrix = {
"include": generate_matrix_entries(
config,
runners,
args.platform,
labels,
)
}
entries = generate_matrix_entries(
config,
runners,
args.platform,
labels,
)

matrix = {}
shards = len(entries) // CI_MATRIX_SIZE_LIMIT
for shard in len(shards):
matrix[str(shard)] = entries[
shard * CI_MATRIX_SIZE_LIMIT : (shard + 1) * CI_MATRIX_SIZE_LIMIT
]

print(json.dumps(matrix))

Expand Down

0 comments on commit d22af60

Please sign in to comment.