ci: build newly added variants in the PR matrix (#11549)

* ci: build newly added variants in the PR matrix

A new board declares board_level = release, so it gets no CI build until
after merge. Build the first env of each platformio.ini added by a PR,
regardless of board_level.

Only added files qualify; adding an env to an existing config does not.

* ci: also detect added variants in merge_group runs

merge_group uses the same --level pr subset as pull_request, so a newly
added variant was skipped there. Derive the diff base from
github.event.merge_group.base_sha for those runs.

* ci: fail the matrix step when the variant diff errors

Process substitution hides the exit status, so a failed diff silently
yielded an empty list and dropped the new board from the matrix. Capture
into a variable so 'set -e' aborts the step instead.
This commit is contained in:
Thomas Göttgens
2026-08-20 14:42:28 +00:00
committed by GitHub
parent 0b906b4d15
commit 68bfe015e6
2 changed files with 48 additions and 1 deletions
+26 -1
View File
@@ -55,6 +55,9 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
# Needed to diff against the base branch for newly added variants.
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: 3.x
@@ -62,11 +65,33 @@ jobs:
- run: pip install -U platformio
- name: Generate matrix
id: jsonStep
env:
BASE_REF: ${{ github.base_ref }}
MERGE_GROUP_BASE_SHA: ${{ github.event.merge_group.base_sha }}
run: |
# A new board is 'release' and gets no CI until after merge, so force-build the
# first env of each ADDED variant config. A new env in an existing one does not count.
DIFF_BASE=""
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
git fetch --no-tags --depth=1 origin "$BASE_REF"
DIFF_BASE=$(git merge-base FETCH_HEAD HEAD)
elif [[ "$GITHUB_EVENT_NAME" == "merge_group" ]]; then
DIFF_BASE="$MERGE_GROUP_BASE_SHA"
fi
ADDED_ARGS=()
if [[ -n "$DIFF_BASE" ]]; then
# Assign rather than pipe: a failing diff must abort the step under 'set -e',
# not silently yield an empty list and drop the new board from the matrix.
ADDED_CONFIGS=$(git diff --name-only --diff-filter=A \
"$DIFF_BASE" HEAD -- 'variants/**/platformio.ini')
while IFS= read -r cfg; do
[[ -n "$cfg" ]] && ADDED_ARGS+=(--added-config "$cfg")
done <<<"$ADDED_CONFIGS"
fi
# PRs and (for now) merge_group builds use the narrowed --level pr board
# subset. Full-matrix builds run on push / schedule / workflow_dispatch.
if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "merge_group" ]]; then
TARGETS=$(./bin/generate_ci_matrix.py all --level pr)
TARGETS=$(./bin/generate_ci_matrix.py all --level pr "${ADDED_ARGS[@]}")
else
TARGETS=$(./bin/generate_ci_matrix.py all)
fi