Repository navigation
Refuse fork jobs on the Mac's self-hosted runners and run several instances per repository - #258
Merged
Merged
Conversation
…m awake and out of Spotlight
…ANWRIGHT_TEST_JOBS
…and the work directory move
… cores for test jobs
Owner
Author
|
@cubic-dev-ai review this PR |
@inkatze cubic can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 40,041 of the 40,000 allowed lines of code this month. Reviews resume on 2 December 2026 (in 19 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews. To help optimise your usage, you can tune cubic to get the most out of your usage limits:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
PR-Agent run 43574867063.1 on 480fc88: success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Merge before #250: both touch scripts/runner-start-test.sh; #250 syncs onto main after this lands.
What
The Mac's self-hosted runners now refuse any job that is not the repository's own code, stay awake, and run several instances per repository with a per-instance environment.
runner-job-started-hook.shrefuses unlessGITHUB_REP 8000 OSITORYis the runner's own repository and the event ispush, orpull_requestwhose head repository (read with/usr/bin/jq) is that same repository. The play installs one copy per runner instance beside a.repofile naming its repository, writesACTIONS_RUNNER_HOOK_JOB_STARTEDinto the runner's.env, and fails if it cannot (it also stops early when/usr/bin/jqis missing). No gate is scheduled before the hook is in place.osx_runner_instances(planwright: 4). An instance's directory and name follow the live runners (offload-mac-ci,-2, ...); both labelsmac-fleetandoffload-mac-ciare registered. Chosen: adopt existing registrations (a directory with.runneris never re-registered), not deregister and re-register, so no offline duplicates appear on GitHub and no removal tokens are needed. The stopgap's hand-set@rebootlines are removed by the play (cron's own name matching cannot adopt them) and replaced by the gate's.config.shrewrites.pathand may rewrite.env, so the hook line, the per-instanceNPM_CONFIG_PREFIX(~/.npm-global-<n>),PLANWRIGHT_TEST_JOBS(half the cores, at least 1) and the.pathprefix (the npm prefix'sbinand a pinned node'sbin) are written after registration and before any gate starts. When any of them changed, the runner's idle listener is stopped so its gate starts a fresh one; a listener serving a job finishes first (--once).runner-start.shstarts each gate under/usr/bin/caffeinate -i, for the gate's whole life. Yielding to the Mac's owner is unchanged: niced runs, and the listener stops while the Mac is in use.PATH, rather than writing the account's global mise config, so that config stays untouched and the pin sits beside the runners it serves.--work _work.noindex; an existing instance's_workmoves to_work.noindexbehind a_worksymlink (runner-workdir.sh), skipped while a job runs and caught up by the next play run.Tests:
scripts/runner-hook-test.sh(new, wired into CI) covers push, same-repository pull request, fork pull request, other events, and a missing or unreadable payload or repository file.scripts/runner-start-test.shpins caffeinate, the work-directory move, the idle-listener refresh, the instance and label wiring, the per-instance npm prefix, the core split and the task order.Operator steps (admin)
After this merges. Checked 2026-11-14:
ssh macreaches the fleet account (zsh), whose~/dev/dotfilesis a cleanmaincheckout withansible-playbook,miseandjqon itsPATH, and this repository'sghlogin has admin.Rerun the playbook on the Mac (no sudo; runs as the fleet account):
ssh mac 'cd ~/dev/dotfiles && git pull --ff-only origin main && ./scripts/playbook.sh'Set the fork-approval policy (currently
first_time_contributors):Then check the hook once, as
docs/offload-host.mddescribes: a pull request from a branch passes with the hook in its log, and the hook refuses when run by hand with a fork's event file.Step records
Steps at
pre-implementation(run000001)Ended on
7aaac4bb5830.Steps at
pre-ci(run000001)Ended on
845622b93597.Steps at
convergence(run000001)Ended on
480fc88f6657.Steps at
pre-pr(run000001)Ended on
480fc88f6657.Steps at
post-pr(run000002)Ended on
480fc88f6657.Post-PR: cubic was triggered first (
@cubic-dev-ai review this PR, 2026-11-14T08:15:17Z, head 480fc88). Its reply was a quota refusal: "cubic can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 40,041 of the 40,000 allowed lines of code this month. Reviews resume on 2 December 2026." PR-Agent's review is therefore this PR's bot review; its run on this head (run 43574867063.1) succeeded and its drain (/bot-review --nested --reviewer pr_agent) found nothing to reply to or resolve.Summary by cubic
Makes the Mac's self-hosted runners fail closed against fork jobs, run several instances per repository, and stay awake so idle sleep no longer drops them offline.
/usr/bin/jqis missing.PATH, andPLANWRIGHT_TEST_JOBSset to half the Mac's cores.caffeinate -ifor their whole life; yielding to the Mac's owner is unchanged._work.noindexso Spotlight stops indexing checkouts..envand.pathare written after registration and before gates; a changed runner's idle listener is restarted so it reads the new environment.After merge (operator)
pkill -f 'actions-runners/inkatze-planwright.*Runner.Listener'as the fleet account), then rerun the playbook on the Mac.gh api -X PUT repos/inkatze/dotfiles/actions/permissions/fork-pr-contributor-approval -f approval_policy=all_external_contributors(needs admin).Written for commit 480fc88. Summary will update on new commits.