Skip to content

Commit a5895a9

Browse files
authored
Merge pull request adafruit#11325 from MakerClassCZ/ci-matrix-chunks
ci: split a port with more than 256 boards into several matrix jobs
2 parents e6bf001 + ab4a6bf commit a5895a9

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,4 @@ jobs:
231231
with:
232232
boards: ${{ toJSON(fromJSON(needs.scheduler.outputs.ports)[matrix.port]) }}
233233
cp-version: ${{ needs.scheduler.outputs.cp-version }}
234-
port: ${{ matrix.port }}
234+
port: ${{ fromJSON(needs.scheduler.outputs.ports).split_ports[matrix.port] || matrix.port }}

tools/ci_set_matrix.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import re
2525
import os
26+
import math
2627
import sys
2728
import json
2829
import pathlib
@@ -68,6 +69,8 @@
6869
r"(?:-stubs|\.(?:md|MD|mk|rst|RST)|/Makefile)$"
6970
)
7071

72+
GITHUB_MATRIX_LIMIT = 256
73+
7174
PATTERN_WINDOWS = {
7275
".github/",
7376
"extmod/",
@@ -267,8 +270,24 @@ def get_settings(board):
267270
port_to_boards_to_build.setdefault(port, []).append(board)
268271
print(" ", board)
269272

273+
# build-boards.yml runs one matrix per port and GitHub allows 256 jobs per matrix.
274+
# Split a bigger port into alphabetical runs of equal size, listed like ports;
275+
# "split_ports" maps a part back to the real port name, which build.yml passes on, so
276+
# the toolchain setup in build-boards.yml stays unchanged.
277+
split_ports = {}
278+
for port, boards in list(port_to_boards_to_build.items()):
279+
parts = math.ceil(len(boards) / GITHUB_MATRIX_LIMIT)
280+
if parts > 1:
281+
del port_to_boards_to_build[port]
282+
size = math.ceil(len(boards) / parts)
283+
for index, start in enumerate(range(0, len(boards), size), start=1):
284+
name = f"{port}-{index}"
285+
port_to_boards_to_build[name] = boards[start : start + size]
286+
split_ports[name] = port
287+
270288
if port_to_boards_to_build:
271289
port_to_boards_to_build["ports"] = sorted(list(port_to_boards_to_build.keys()))
290+
port_to_boards_to_build["split_ports"] = split_ports
272291

273292
# Set the step outputs
274293
set_output("ports", json.dumps(port_to_boards_to_build))

0 commit comments

Comments
 (0)