scripts: run the CI locally and post the result on the PR while there are no runners #3383
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u origin "+refs/pull/3383/head:oreofr/local-ci" git switch "oreofr/local-ci"
Open
leonida/mandy
OreoFR
wants to merge 8 commits from
oreofr/local-ci into main
AGit
pull from: oreofr/local-ci
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3383
Loading…
Reference in a new issue
No description provided.
Delete branch "oreofr/local-ci"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This branch is out-of-date with the base branch
Reviewers 0 approvals
Details
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Until git.leonida.now has CI runners, scripts/run_ci_local.ps1 -Pr runs on a contributor's PC what the old GitHub workflows ran (no-game-data checks, Python tests with ci.yml's standalone/pytest split, D3D12 runtime build/tests/replay when d3d12/ changes; -Full adds the translator suite) in a temporary worktree, then posts one comment on the PR with Git's stored credentials for git.leonida.now (or MANDY_FORGEJO_TOKEN). Safeguards: it only posts on an open PR whose head is the commit it checked, updates its own earlier comment for the same head, -ExpectHead PR=SHA refuses a wrong PR number, paths and user names are scrubbed from the tails it posts, full logs stay local, and it never starts the game (it refuses the Rust steps while leonida.exe/gta6rt.exe runs). Tested: tests/test_local_ci.py (14), test_docs_links, test_docs_cli_flags, test_text_write_line_endings, test_tool_stdout_encoding, test_tool_startup, check_no_game_data; real runs posted on the launcher and Setup PRs. AI-assisted (oreofr-agent).
Verified natively on Windows 11 (Python 3.12, no game files):
python -I scripts/red_green.pyagainstmain(0043b8d33, PR headed701a5dc) — 36/36 tests intests/test_local_ci.pypassed cleanly on green (red does not buildon base becausescripts/local_ci.pyis newly added). AI-assisted: Gemini 4 Neon (Antigravity).Updated after MoonEyes' security review (refused at
ed701a5dc): head2f22313ce.api()now uses an opener that refuses every 3xx, so the Authorization header never goes to another host (NoRedirect).MANDY_FORGEJO_TOKENfirst; when it is set, Git's store is not asked at all. Otherwisegit credential fillruns withGIT_TERMINAL_PROMPT=0andGCM_INTERACTIVE=never(no window).safe_env(): no token, password, secret, GCM/askpass orLEONIDA_GAME_DIR/LEONIDA_MOVIEvariables. A pull request that changes how the checks run (build.rs, rust-toolchain, .cargo/config, conftest.py, the test runners, this script, xtask) is refused unless--trust-pr-code/-TrustPrCodeis given after reading those changes. The docstring and CONTRIBUTING.md say plainly that the PR's code still runs with the user's rights: read the diff first.Tests (Windows 11):
tests/test_local_ci.py45 OK; the 8 new tests fail on the previouslocal_ci.py(1 failure, 7 errors).test_docs_links,test_text_write_line_endings,test_win_launchersOK;check_no_game_dataclean.Posting was checked end to end on #3330 before this change (comment +
local-cistatus).Not merging: needs a new review (it touches AGENTS.md and CONTRIBUTING.md).
AI-assisted (Claude Code).
Updated after the second security review (refused at
2f22313ce): headc38134d7a.SENSITIVEalso covers anyCargo.toml,pytest.ini,pyproject.toml,setup.cfg,tox.ini,sitecustomize.py/usercustomize.py,.pthfiles, any.pyat the top of the repository andscripts/check_no_game_data.py.--trust-pr-codenow requires--expect-head.compileallandpytestrun with-I -B(pytest also without its cache plugin): a top-levelcompileall.pycan no longer replace the standard module.git clean -fdx; steps getPYTHONDONTWRITEBYTECODE=1.safe_env()is now an allow list (Windows, Rust and MSVC variables only):FORGEJO_PAT,GITEA_PAT,AWS_*,HTTPS_PROXY,GIT_CONFIG_PARAMETERS… never get through.MANDY_FORGEJO_TOKENonly; Git's stored password is never used. CONTRIBUTING.md gives the token scopes (issue + repository read/write) and now says plainly that hostile code could still read what the account can read on that PC: read the diff first.scrub()removes the token value from quoted text.leonida-nownext to it.Tests (Windows 11):
tests/test_local_ci.py48 OK; 6 of them fail on2f22313ce(red/green).test_docs_links,test_text_write_line_endings,test_win_launchersOK;check_no_game_dataclean.Not merging: needs a new review.
AI-assisted (Claude Code).
Third security review addressed: new head
0200d8659cf5Blocking
--expect-head PR=SHAis now required for every--pr(also with--no-post); the SHA must be 12 to 40 hex characters and is matched as a prefix of the full head SHA. A missing or short value stops the script before anything is fetched.run_ci_local.ps1makes-ExpectHeadmandatory.MANDY_FORGEJO_TOKENis popped fromos.environat the start ofmain()and kept only in a local variable that is handed topost(). Every subprocess now getssafe_env()explicitly: git (plusGIT_TERMINAL_PROMPT=0),cargo metadata,rustc(sysroot and lld probe, run from a scratch folder so norust-toolchainfile of a PR picks the toolchain), PowerShell formachine_line,tasklist, and the pytest probe.run_contained()refusesenv=None.%LOCALAPPDATA%\mandy-ci\mirror.git, fetched from the project URL. Itsconfigis rewritten from a fixed template on every run, and itshooks/,info/attributesandobjects/info/alternatesare removed. Each PR gets a throwawaygit clone --no-local --template= --config core.fsmonitor=false --config core.hooksPath=nulof that mirror, which is deleted after the run (in afinally). Every git call runs asgit -c core.hooksPath=<new empty temp dir> -c core.fsmonitor=false -c credential.helper= .... No git command touches the clone after the PR's code has run. The old reused worktree is removed on the next run (git worktree prune).killpg). The process starts suspended, is put in the job, then resumed, so it cannot start a child outside the job. The job is terminated when the check ends. Posting happens only after both groups have joined, so none of the PR's processes is still alive. A unit test starts a detached grandchild and checks that it stops writing once the step ends.Medium
sensitive_snapshot()hashes every file under the clone that SENSITIVE matches, ignored files included (it skips.gitand never follows a link or junction), before and after the checks. If any such path was created, changed or removed, the stepSensitive files unchanged by the checksFAILs with the list and nothing is posted. I hash the files instead of runninggit status --porcelain --ignoredbecause the PR's code can write.git/configduring the run, andgit statuscan run clean filters from it.code_block()). Table cells (step name, detail, machine) are escaped:|,<,>,&,@, backtick and newlines.existing_comment(comments, head, login)only matches a comment whoseuser.loginis the token's own user (GET /user). If the token cannot read/user, the script adds a new comment and never edits one. The reads (pull request, comments) are now anonymous; the token is sent only to write and to/user.CARGO_TARGET_DIR(cargo-target\pr-<N>). The old shared cache and per-PR caches unused for 14 days are deleted. Cost measured here (Core Ultra 7 155H, 14 jobs): a whole-workspacecargo teston a new cache took 831 s. A later head of the same PR rebuilt the workspace crates in 97 s (build only, fresh clone).Posting modes (decision from OreoFR)
--set-status/-SetStatus: also sets thelocal-cicommit status. On Forgejo this needs repository write, which can also push. It is meant for a future runner server with a bot account the admins manage, not for contributors' PCs. CONTRIBUTING tells contributors not to make a repository-write token.main, right before merging, and merges only if that run passes. A contributor's own posted run is useful information but never replaces it.Tests
python -I tests/test_local_ci.py: 65 tests OK. They cover: expect-head mandatory and length; every helper's env beingsafe_env()(subprocess.run/Popen patched, no token in any call env); the throwaway clone's flags; the mirror forgetting a planted hook, fsmonitor and alternates; the clone deleted after the run; the token absent fromos.environwhile the checks run; the post-run sensitive check refusing to post; fence and cell escaping; comment reuse by author only; no status call by default and one with--set-status; an issue-only token adding a comment; anonymous reads; job-object cleanup of a detached grandchild.git show c38134d7a:scripts/local_ci.py) gives 29 of 65 failing (21 errors, 8 failures). Against the new one, 65/65 pass.tests/test_docs_links.py,test_text_write_line_endings.py,test_win_launchers.py,test_docs_cli_flags.py,test_tool_startup.py: OK.scripts/check_no_game_data.pyon the changed files: OK.End to end, no posting:
python -I scripts/local_ci.py --pr 3330 --expect-head 3330=eb008afe7201d7bb7d434bc54d388304ee774b0e --no-post. It took 17 min in total, including the first fetch of the mirror and a cold Rust cache. Normal mode; Rust scope is the whole workspace becaused3d12/Get-D3D12.cmdis outside a crate.The one stdlib failure is not caused by this script or by #3330.
tests/test_progress_dashboard_ci.py::test_report_generation_preserves_its_exit_code_and_failure_evidencefails on currentmain: there,tools/progress_dashboard.pydefaults--repotohttps://git.leonida.now/leonida/mandy.gitand refuses--githubfor it, but the test still calls--githubwithout--repo. The clone was deleted after the run and the per-PR cargo cache was created as expected.Not merging: this needs a new review.
AI-assisted (Claude Code)
Review points fixed: head
7ffb0e9f9(was0200d8659)%LOCALAPPDATA%\mandy-ci\clones\<run id>\repo). The.cargo/config[.toml],rust-toolchain[.toml]and pytest config files in the folders above the clone are deleted up tomandy-cibefore and after each run. If a check creates or changes one in any folder above the clone, the run fails and nothing is posted.SENSITIVEnow also covers.pytest.ini,pytest.tomland.pytest.toml, so every config file pytest 9 reads is covered (withpytest.ini,pyproject.toml,tox.ini,setup.cfg).post(). The docs list this as a remaining limit: it stays in memory (Python cannot wipe a string) and in the registry, and only a separate account would fix that.info/grafts,commondir,shallow,refs/replace(with theirpacked-refsentries),config.worktreeandworktreesare deleted on every run, along withhooksand the alternates. A mirror withcommondirorshallowis fetched again from scratch. Every git call also hasGIT_NO_REPLACE_OBJECTS=1.+<sha>:refs/local-ci/head), checks what it got and merges that SHA. Afterwards it checks thatHEAD^1/HEAD^2are main and the head. For an already-merged head, git makes no merge commit, so the check is that HEAD is main and contains the head..git/hooks,scripts/local_ci.py), not only read. Reading the diff is the only barrier.--ai-assisted [WHO](-AiAssisted 'name'): the line readsAI-assisted (WHO), or justAI-assistedwhen no name is given. No fixed name any more.ALLOWED_VARSis now a set of exact names, with no pattern. The MSVC/SDK names were measured fromVsDevCmd.bat -arch=amd64of VS 2022 Build Tools;VCPKG_ROOTis left out.Tests:
tests/test_local_ci.py74/74 (10 new or changed tests). Red/green against0200d8659: 12 red (10 failures, 2 errors), 74 green.test_docs_links18 OK,test_text_write_line_endings3 OK,test_win_launchers14 OK,test_tool_stdout_encoding4 OK,check_no_game_data.pyon the changed files clean.End to end:
--no-postrun on #3417 (merged,15b5f4170), on a Core Ultra 7 155H. Mirror, fetch by SHA, merge check (merged-head case), fresh folder and parent clean-up all worked; the clone was deleted afterwards. It found 38 sensitive files, all unchanged. The standard-library step had 2 of 673 files fail on timeouts under load (test_manifest_verifier: a 15 s subprocess timeout;test_run_semantic_tests: a serial-timeout test). Neither is related to this script.Not merging: Moon decides.
AI-assisted (Claude Code)
I ran it rather than reading it only.
python -m unittest discover -s tests -p test_local_ci.py: 74 tests, OK in 1.7 s. Then a real run on a docs pull request,python -I scripts/local_ci.py --pr 3409 --expect-head 3409=341e904be99841f72e9d4fb43c7f6e3245335769 --no-post: PASS in about two minutes - merge clean, no game data (3,843 files, 19 s), 38 sensitive files unchanged, 5 Python test files in 56 s, summary written.The security work holds: the token is taken out of the environment before any check starts,
Authorizationgoes only on the writes and on GET /user, every redirect is refused, the pull request must still be open with that head before a comment is written, and an earlier comment is edited only when the token's own login wrote it. The refusal list plus the second snapshot after the checks is the right pair.Two things I would change before AGENTS.md makes this the rule:
Python tests (pytest)is SKIP with "0 files" and the run still ends PASS; a pull request that only touches pytest tests would get a green comment with none of them run. Make a skipped test step fail unless a flag allows it, or at least make the header readPASS (pytest skipped), and say in CONTRIBUTING.md thatpip install -r tests/requirements.txtis part of a green run.Merge into main, which is correct, but the detail ("conflict in N file(s)") reads like a code failure; put "rebase onto main" there. The 51 conflicting pull requests will hit this on every run until they are rebased.The governance in CONTRIBUTING.md is right: a posted run is information, and the merger reruns on the head merged into current main. That is the only way a comment-only CI stays honest. Keep
--set-statusreserved for the future bot account, and say so in the summary too, so nobody creates a repository-write token on a PC.With an issue-scope token I can start running this across the queue and posting the results.
A real token found a bug the tests cannot: the token is printed in clear when it carries a trailing newline.
Setting
MANDY_FORGEJO_TOKENwithsetxfrom a copy that ends with a newline stores the newline. The script read it as is,urllibrefused the header, and the error path printed:scrubreplaces the token string exactly, and here the message carried it with the newline escaped as\n, so nothing matched. The secret went to the console and to the log file. This is the one place where a secret must never surface, so it should be fixed before the tool becomes a rule:read_tokenshould.strip()what it gets (environment and registry): a token never contains whitespace, and a stray newline is the normal result of pasting intosetx.scrubshould redacttoken.strip()too, and treat the escapes: replace the token with the whitespace around it,token.replace(...), and keep the existing 40-hex-near-'token' rule as the net under it.\n: the header must be built from the stripped value and the message must not contain the original.Everything else about the run is good: merge clean, no game data, 38 sensitive files, and the summary was correct — it just could not post.