Skip to content

Commit 5276dc3

Browse files
committed
ci: mcpp 0.0.96 + selective member testing + sandbox index refresh
- All mcpp pins -> 0.0.96; drop the windows 0.0.94 pin-back (mcpp#230 fixed in 0.0.96). - Replace host nasm with one 'mcpp index update' before the workspace run: 0.0.96's release archive vendors an index snapshot cut before xim-pkgindex#398 fixed the nasm descriptor, and the bootstrap is offline-first (mcpp#232). Drop once a release vendors a newer snapshot. - Selective member testing: PRs map changed files -> affected workspace members and run 'mcpp test -p <member>' per member instead of the full 'mcpp test --workspace'. Full run stays for non-PR events, changes to this workflow (carries the version pins), shared test scripts, or non-member mcpp.toml edits; new-package PRs (members list append) select only the added member.
1 parent 4c873d8 commit 5276dc3

1 file changed

Lines changed: 79 additions & 2 deletions

File tree

.github/workflows/validate.yml

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ jobs:
174174
env:
175175
MCPP_EFFECTIVE: ${{ matrix.mcpp_version }}
176176
steps:
177+
# Full history: the member-selection step below diffs against the PR
178+
# base to decide which workspace members to test.
177179
- uses: actions/checkout@v4
180+
with:
181+
fetch-depth: 0
178182
- name: Restore mcpp registry cache
179183
uses: actions/cache@v4
180184
with:
@@ -226,14 +230,87 @@ jobs:
226230
shell: bash
227231
run: '"$MCPP" index update'
228232

229-
- name: mcpp test --workspace
233+
# ── Selective member testing ──────────────────────────────────────
234+
# `mcpp test --workspace` builds every member (opencv, ffmpeg, …) and
235+
# dominates CI wall-clock, while a PR almost always touches one
236+
# package. Map changed files → affected members and test only those:
237+
# pkgs/<x>/<lib>.lua → members whose mcpp.toml references <lib>
238+
# tests/examples/<m>/** → member <m>
239+
# Run the FULL workspace when the change can affect everything:
240+
# non-PR events (push to main, the nightly cron, dispatch), this
241+
# workflow file (it carries the mcpp version pins, so a version bump
242+
# always re-validates every package), the workspace manifest, or
243+
# shared test scripts. Docs-only changes select nothing.
244+
# Note: bash 3.2 on macOS runners — no associative arrays here.
245+
- name: Select affected workspace members
246+
shell: bash
247+
run: |
248+
full() { echo "MEMBERS=__ALL__" >> "$GITHUB_ENV"; echo "full run: $1"; exit 0; }
249+
[ "${{ github.event_name }}" = "pull_request" ] || full "event=${{ github.event_name }}"
250+
base="origin/${{ github.base_ref }}"
251+
changed=$(git diff --name-only "$base"...HEAD)
252+
printf 'changed files vs %s:\n%s\n' "$base" "$changed"
253+
sel=""
254+
add() { case " $sel " in *" $1 "*) ;; *) sel="$sel $1" ;; esac; }
255+
while IFS= read -r f; do
256+
[ -n "$f" ] || continue
257+
case "$f" in
258+
.github/workflows/validate.yml|tests/*.sh|tools/*) full "$f" ;;
259+
mcpp.toml)
260+
# Workspace manifest. Every new-package PR appends to the
261+
# members list, so that alone must NOT force a full run:
262+
# select the added members; anything else in this file
263+
# (indices, settings) affects everyone → full.
264+
if ! diff -q <(git show "$base:mcpp.toml" | grep -v 'tests/examples/') \
265+
<(grep -v 'tests/examples/' mcpp.toml) >/dev/null; then
266+
full "mcpp.toml non-member change"
267+
fi
268+
for p in $(comm -13 <(git show "$base:mcpp.toml" | grep -o 'tests/examples/[A-Za-z0-9._-]*' | sort -u) \
269+
<(grep -o 'tests/examples/[A-Za-z0-9._-]*' mcpp.toml | sort -u)); do
270+
add "${p#tests/examples/}"
271+
done ;;
272+
tests/examples/*)
273+
m=${f#tests/examples/}; m=${m%%/*}
274+
# A deleted/renamed member dir implies a mcpp.toml edit,
275+
# which already forces a full run above.
276+
[ -d "tests/examples/$m" ] && add "$m" ;;
277+
pkgs/*.lua|pkgs/*/*.lua)
278+
lib=$(basename "$f" .lua); lib=${lib#compat.}
279+
hit=0
280+
for mt in tests/examples/*/mcpp.toml; do
281+
if grep -q "$lib" "$mt"; then add "$(basename "$(dirname "$mt")")"; hit=1; fi
282+
done
283+
[ "$hit" = 1 ] || echo "note: no workspace member exercises $f" ;;
284+
*.md|docs/*|.agents/*|.github/*) : ;;
285+
*) full "unclassified change: $f" ;;
286+
esac
287+
done <<EOF
288+
$changed
289+
EOF
290+
sel=${sel# }
291+
echo "MEMBERS=$sel" >> "$GITHUB_ENV"
292+
echo "selected members: ${sel:-<none>}"
293+
294+
- name: mcpp test (workspace or affected members)
230295
shell: bash
231296
env:
232297
MCPP_INDEX_MIRROR: GLOBAL
233298
run: |
234299
"$MCPP" --version
235300
# No `timeout` wrapper: absent on macOS runners; job-level timeout-minutes bounds it.
236-
"$MCPP" test --workspace
301+
if [ "$MEMBERS" = "__ALL__" ]; then
302+
"$MCPP" test --workspace
303+
elif [ -z "$MEMBERS" ]; then
304+
echo "No workspace member affected by this change — nothing to test."
305+
else
306+
rc=0
307+
for m in $MEMBERS; do
308+
echo "::group::mcpp test -p $m"
309+
"$MCPP" test -p "$m" || rc=1
310+
echo "::endgroup::"
311+
done
312+
exit $rc
313+
fi
237314
- name: tinyhttps module package smoke
238315
shell: bash
239316
env:

0 commit comments

Comments
 (0)