Repository navigation
ci: apple-build-kunit: run only the touched KUnit suites until approval - #3675
RyanTheTide wants to merge 10 commits into
Conversation
The Apple KUnit matrix runs 16 suites for every push to every PR that touches any of its paths, so one push costs 16 runner jobs and the trusted queue on the shared runners is hours deep. A new plan job reads the PR's changed files through the API (no checkout) and picks the suites whose directories the PR changes. Shared code (include/, rust/, mm/, arm64 configs, Kconfig or Makefile, iommu, pci, power, drivers/soc/apple outside clpc, this workflow) and any unknown path select all suites; nvme, thunderbolt and Apple Wi-Fi are build-only (apple-build compiles them, no suite lives there); files outside this workflow's paths are ignored. The full matrix runs on pushes and dispatches, once the PR is approved (GitHub review decision or an approval at the head), and when the kunit-full label is added. API errors or a truncated file list select the full matrix. apple-build always runs. Labelled events start the workflow only for kunit-full; any other label gets its own concurrency group, so it never cancels a running check. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: FINISH at 2b721b5.
Blocker: The planner only observes approval when something else starts the workflow. The event list has no review event, so approving an already-green narrow run does not start full KUnit. The new code also does not make the full result a pre-merge gate. A PR armed for auto-merge can land on approval using the narrow result before anyone adds the label. Please wire a reliable full-run request and require its green result for the current head before arming or merging. Show the end-to-end case where a narrow pass followed by approval stays blocked until the full run passes, including a stale or cancelled full run.
Checked: Scope selection reads the API without executing PR code. Shared and uncertain paths select the full matrix, and rename handling includes both paths. The gap is the transition from a narrow result to merge eligibility.
Review: approving a PR started nothing, so a narrow pass stayed the last KUnit result, and nothing required the full matrix before merge. - The plan job sets the commit status "KUnit full matrix" to pending on the PR head for every same-repo run. A final job sets it to success only when a full-matrix run passed for that exact head; a narrow, cancelled or unfinished run leaves it pending, a failing suite sets failure. The readiness bot treats pending as not ready. - An approval of a same-repo PR (pull_request_review) dispatches this workflow from main with the PR number. GITHUB_TOKEN dispatches do start workflows. The dispatch run reads the PR's current head through the API, refuses forks and closed PRs, checks out refs/pull/N/merge, verifies its second parent against that head, runs all suites and records the status. - Fork PRs (the pull_request twin) always run the full matrix and get no gate. Dispatch concurrency groups are per PR, so two approvals do not cancel each other. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: FINISH at 3e15f101.
Blockers: The new status needs a corresponding required gate or explicit merge-train predicate. The workflow writes it but does not enforce it before arming. Please show the effective policy and cover fork PRs and PRs outside the workflow path filters, where this job does not publish the status.
The narrow PR run and dispatched full run have different concurrency groups and can finish in either order. A slow narrow run can write pending after a full pass for the same SHA, leaving the approved PR blocked without another dispatch. Make narrow runs preserve an existing full pass, or serialize ownership of the result. Add a test for full success followed by late narrow completion.
Checked: Approval now has an explicit dispatch path, and the full run verifies the checked-out merge ref against the planned head.
Review: the narrow PR run and the dispatched full run are in different concurrency groups and can finish in either order, so a slow narrow run could write pending over a full pass for the same head. Pending writes (the plan job's and the final job's) now read the head's statuses first and keep an existing "KUnit full matrix" success. Only a full run records failure; a narrow run's failing suite shows in its own check and leaves the status pending. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: FINISH at 550fe837.
Blockers: The current main rules do not require any status check, and the PR description confirms GitHub auto-merge does not wait for this status. Readiness labels and the train’s manual gate protect only the paths that consult them. Show that the affected PRs cannot be armed until a full pass exists at the current head, or make the status a required check with a covered path for forks and out-of-scope PRs.
The fake API test covers sequential completion. The GET and POST are separate operations across independent runs. A narrow writer can read pending, the full writer can post success, and the narrow writer can then post pending over it. Serialize status publication or give the terminal status a single writer. Include an interleaving test with full success between the narrow GET and POST.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Review: a read-then-write across independent runs can interleave, so a narrow run could read pending, a full run post success, and the narrow run then post pending over it. Full runs now own "KUnit full matrix": they write pending when they start (keeping an existing pass) and their outcome when they finish. A narrow run writes nothing at the end, and at the start only marks a head that has no status yet. Any status means a full run has started, and a full pass is always preceded by that run's own pending write, so a full pass cannot land between a narrow run's read and its write. Two full runs racing on one head can at worst leave pending until the later one reports (fails closed). Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
On "make the status a required check": I'm not doing that in this PR. linux A required Within the current policy, the gates that do run before a merge both block on the pending status: the readiness label and the merge train's gate. The status itself now has a single owner per head (fourth commit). |
There was a problem hiding this comment.
Verdict: FINISH at c1360daf.
Removing the narrow final writer closes the late-completion case. The narrow planner still reads an absent status and then posts pending in a separate operation. If paused between those calls, it can publish pending after the full planner and recorder write success. The terminal full writer can also publish pending after cancellation. Please put status writes under one serialization boundary or use a dedicated required full-result context that narrow and cancelled runs cannot overwrite. The owner decision on enforcing the pre-arm gate is still open.
From an independent review of the gate: - Only approvals by owners, members or collaborators dispatch the full matrix; anyone can submit an approving review on a public repository, which would have started self-hosted runs at will. - Review-triggered runs get a per-run concurrency group, so a later review cannot cancel an approval's run before it dispatches. - kunit-full label runs get their own group, so adding the label does not cancel the PR's in-flight run (a cancelled check reads as failing to the readiness bot). - Dispatched runs are named after the PR (run-name and job names), so their checks on main's tip are not mistaken for main's own KUnit. - Files outside the trigger paths now select all suites unless they are known to be unrelated (DT sources, Documentation, other workflows' tests and tools, .github), so shared code such as lib/, kernel/ or the KUnit tooling is not skipped. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
… the full run Decision on the gate: the full-matrix commit status, the approval dispatch and the recorder job are removed. linux has no required checks, so a status cannot gate merges by itself, and serializing its writers across runs needs more machinery than it is worth. Instead the merge train adds the kunit-full label with a maintainer token before merging a linux PR and waits for all 16 KUnit suites to pass at the head. kunit-full runs get their own concurrency group, so the label does not cancel the PR's in-flight run. Unapproved same-repo PRs still run only their suites; pushes, dispatches, fork PRs, pushes to approved PRs and API doubt run the full matrix. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: FINISH at 44654d59.
Removing the shared status writers resolves the status race. The train predicate still exits zero when no Apple check is present. That also occurs on an in-scope head before check creation or when the workflow did not start. Determine applicability from the files and trigger contract, then require positive full-run evidence for applicable heads. Wire that predicate into the actual pre-arm and landing path before tiering is enabled. Test in-scope with no checks, out-of-scope with no checks, and stale or cancelled runs.
The labeled event should force the full plan directly from its payload. Currently the planner re-reads the label through a bounded GraphQL list, so a label absent from that response can leave the requested full run narrow.
Review: the planner re-read the label through a bounded GraphQL list, so a kunit-full label missing from that response could leave the requested full run narrow. The label name now comes from the event payload, and a kunit-full label event runs every suite without asking the API. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
On the predicate and its wiring:
The label event now forces the full plan from its payload (latest commit). |
There was a problem hiding this comment.
Verdict: HOLD at 61cbf429
Blockers:
- Ordering dependency:
aurora-silicon/.github#20(wiring the full-KUnit applicability and positive-evidence gate intopr-flowbefore arming/merging) is still open. Merge and deploy.github#20before enabling tiering here, as noted in the PR discussion and prior review. - Hosted CI on
61cbf429(apple-build,host-tests,readiness, and the 16 KUnit suites) is still queued (pr-text / pr-textpassed).
Checked:
61cbf429passesLABELdirectly fromgithub.event.label.nameonlabeledevents and bypasses the bounded GraphQL label query whenLABEL == "kunit-full", forcing the full 16-suite matrix directly from the event payload.plan.pyTRIGGERSmatcheson.pull_request.paths1-to-1;Kconfig*,Makefile, shared trigger paths (include/,rust/,mm/,arch/arm64/configs/,drivers/iommu/,drivers/pci/controller/,drivers/power/, non-CLPCdrivers/soc/apple/,fs/splice.c,kernel/sys.c, this workflow), unknown non-UNRELATEDpaths, renameprevious_filenames, API errors, and>= 3000-file lists all fail closed to the full 16-suite matrix.concurrencyisolateskunit-full(-full) and unrelated label events (-<run_id>), andif:guards prevent unrelated labels from running jobs or cancelling in-flight PR checks;kunitskips cleanly whenneeds.plan.outputs.count == '0'(build-only paths).- All commits carry human
Signed-off-by:trailers and zero AI attribution.
Evidence
- Diff audited:
.github/workflows/apple-build-kunit.yml(+146/-26), head61cbf4295fbd. - Checked
aurora-silicon/.github#20live state:OPEN(8bdf39cc,mergedAt: null). - Non-blocking nit:
FILES=$(cat "$RUNNER_TEMP/files.txt")on line 179 passes the full file list through a single environment variable; on Linux x86_64 (MAX_ARG_STRLEN= 128 KiB), a very large PR (~2,000–3,000 files, below the 30-page truncation cap) could hitE2BIGinstead of falling back to the full matrix. Reading$RUNNER_TEMP/files.txtinsideplan.pydirectly avoids theenvpceiling. - Status checks at review time:
pr-text / pr-textpassed;apple-build,host-tests,readiness / readiness, and 16 KUnit suites queued (pull_requesttwin skipped as expected on same-repo PRs).
Review nit: the changed-file list went to the planner in one environment variable, which a PR with a few thousand files could push past the kernel's per-variable size limit (E2BIG) instead of falling back to the full matrix. The planner now reads it from the runner's temp file. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: HOLD at 008450ba.
The file-backed planner removes the environment-size limit and preserves the label-payload fix. Before enabling tiering, deploy the companion gate, which still needs to handle incomplete newer full attempts, and retain current hosted checks.
|
The ordering condition is met. The auto-merge gate from aurora-silicon/.github#20 (approved by the review App at |
There was a problem hiding this comment.
Verdict: MERGE at 008450ba after hosted validation.
Checked: The label payload selects the full matrix and the file-backed planner avoids the environment-size limit. I verified the active pr-flow checkout at 8cdd9ab calls the full-attempt predicate before arming and that the latest scheduled service run succeeded. The owner checked the existing arms for applicability. This clears my deployment-order hold. Keep this PR’s own build, host tests and full KUnit results as landing prerequisites.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
Resolve the conflict with #3680: the three runs-on lines of apple-build-kunit.yml (apple-build, plan, kunit) take main's routing, so main pushes ask for aurora-buildbox-main and same-repo PR runs keep aurora-buildbox. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: MERGE at 565e4482 after hosted validation.
Checked: The merge parents are the previously approved head and main at 42169a04. Against that base the PR changes only the Apple build and KUnit workflow. In that workflow the delta from the approved head is limited to the three runner selectors from #3680. PR-target jobs retain the PR buildbox label, while default-branch jobs use the main buildbox label. Full-label handling, planner output and matrix logic are unchanged. The companion pr-flow gate was already verified deployed.
Require the current-head build, host tests and full KUnit results before landing.
|
Local validation at
Revert: |
Main added the apple-sio KUnit suite to the static matrix. This branch replaces that matrix with the planner, so the suite goes into the planner's SUITES and TRIGGERS lists instead and the summary count becomes 17. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Merged main in (bb70174, normal merge commit, no force push). The only conflict was main's new apple-sio suite in the static matrix. This branch replaces that matrix with the planner, so apple-sio is now in the planner's SUITES (prefix drivers/dma/apple-sio) and in TRIGGERS, and the summary count reads 17. Checked locally: the planner gives the same 17 suites as main's list, a drivers/dma/apple-sio.c change picks only apple-sio, lib/ picks the full matrix and DT-only picks none. The workflow still parses as YAML. A code owner still needs to approve. |
Every push to a PR that touches the Apple KUnit paths runs all 16 suites. That's 17 runner jobs per push, so the trusted queue on the shared runners is many hours deep: 23 queued "Apple build and KUnit" runs at noon, at 17 jobs each.
This adds a
planjob ahead of the KUnit matrix. On same-repo PRs it reads the changed files through the API (pull-requests: read, no checkout, no PR code) and picks the suites to run:drivers/media/platform/apple/isp/selectsisp. Shared media files select all media suites.include/,rust/,mm/, arm64 configs, anyKconfig*orMakefile,drivers/iommu,drivers/pci/controller,drivers/power,drivers/soc/appleoutsideclpc*, this workflow) and any other path outside the known-unrelated list (lib/,kernel/,drivers/base, the KUnit tooling, ...).drivers/nvme/host,drivers/thunderbolt,drivers/net/wireless/apple.apple-buildcompiles them, and it still runs on every PR.Documentation/,MAINTAINERS,.github/(except this workflow), and other workflows' tests and tools. Those can't change these suites.The full matrix runs:
kunit-fulllabel;Before merge. The merge train adds
kunit-fullwith a maintainer token, so the label event starts the workflow; labels added with the bot'sGITHUB_TOKENdon't. It then waits until all 16 suites have passed at the PR head; the train has a script that checks exactly that.kunit-fullruns get their own concurrency group, so adding the label never cancels the PR's in-flight run. Other labels start nothing and cancel nothing.An earlier revision of this PR also published a commit status as a merge gate and dispatched a full run on approval. That was dropped after review: linux has no required checks, so a status can't gate merges by itself, and its writers can't be serialized across runs.
What it would pick on open PRs (same planner, run against their live file lists):
Tested: ran the plan job's script locally with the real API. Unapproved single-area PRs pick 1 suite (#3483, #3217, #1489); #2633 (shared path) picks 16; #2103 (approved) picks 16. A fork
pull_requestevent, apush, and a bad token (with a warning) all pick 16. The workflow parses as YAML, with jobsapple-build,plan, andkunit(needs: plan, matrix from the plan output, skipped when the plan picks nothing). No runtime change: CI only.Risk: two-way door (revert restores the full matrix on every push). Macs: none. Until approval or
kunit-full, a PR's KUnit checks cover only its own suites, so a cross-suite break shows up at the full run before merge instead of on the first push.