Generate the list of boards to build dynamically #2263
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this PR, we used the
build-boards.yml
reusable workflow to list which boards were supposed to be built, and then invoked thebuild-one.yml
reusable workflow for each of them. Apart from the extra indirection of two reusable workflows, this meant every time a new app is added we had to remember add it to the workflow.This PR fixes that by merging the two reusable workflows into one, and generating the build matrix dynamically. There is now a job that runs before everything else, which clones the repo and runs the
build/gha-build-boards-matrix.py
script. The script scans the repository forapp.toml
s and generates the build matrix in JSON format. The build jobs then depend on the scheduler job, and set their build matrix to that job's output.To support building a subset of boards (during releases) the script optionally accepts a list of paths, and it will look for
app.toml
s only in them (for examplebuild/gha-build-boards-matrix.py app/sidecar app/gimlet
). You can play around with the script locally, it doesn't require any credentials nor dependencies (except for git and a recent Python).I validated that all jobs currently executed are still executed in the new setup, and while checking so discovered that we were instead missing jobs in the current setup (ignore the
,
->\t
changes that sometime show up, since that field was now automatically generated I opted to remove atr
invocation in the workflow by properly separating the fields):Output of
diff
The reason why I opted to write the matrix generator in a scripting language rather than Rust (as part of xtask) is the speed of the scheduler job. With the current setup, the job in total takes 4 seconds to run, while running xtask with a full cache would take around a minute. My hunch is that it's better to deal with a scripting language rather than making every CI run a minute slower. I chose Python as the scripting language mostly because it has a TOML parser in its standard library, and thus doesn't require any dependency.
This PR should be reviewed commit-by-commit (the first two commits just move files around, helping git notice renames).