feat: allow every CLI option to be set via a GAME_CI_* env var - #262
Merged
Conversation
Each thin wrapper (unity-builder, unity-test-runner, unity-activate)
spawns this CLI as a host child process, which inherits the workflow
environment. Mapping GAME_CI_<SCREAMING_SNAKE_CASE> onto options means a
workflow `env:` block can reach any option the wrapper's action.yml has
no input for - so a new option here is usable from workflows the day it
ships, without a PR and release against every wrapper first.
A blanket .env() was previously avoided for a real reason: under
strict(true) it maps every process env var to an option name and then
rejects the invocation wholesale ("Unknown arguments: allusersprofile,
appdata, ..."). That objection is specific to the unprefixed form.
.env(prefix) only maps vars carrying the prefix, so unrelated
environment variables are never considered - verified against the real
parser configuration, not just a synthetic one.
Precedence is arg > GAME_CI_* env > option default, so a wrapper passing
an explicit flag still wins and the environment only fills what it left
unset. The unprefixed fallbacks that secret-bearing options set in their
own .option() default (UNITY_EMAIL etc.) are long-standing public
contract and are unchanged - this is a superset, not a replacement.
Tradeoff: GAME_CI_* is now a reserved namespace. A GAME_CI_ var matching
no option is a hard failure rather than being ignored, which surfaces
typos instead of silently dropping them.
Co-Authored-By: Claude Opus 5 <[email protected]>
|
Warning Review limit reachedNext included review available in 39 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
frostebite
added a commit
to game-ci/documentation
that referenced
this pull request
Sep 10, 2026
The "environment variables don't reach Unity" section previously offered customParameters as the only workaround. That is still the right answer for Unity command line arguments, but it cannot set an environment variable - which is exactly what Unity's own IL2CPP_ADDITIONAL_ARGS and similar toolchain knobs read. dockerEnv (game-ci/cli#261) closes that gap, so lead with it and keep customParameters as the argument-passing alternative, with a note on when each applies. Also documents the GAME_CI_* prefix (game-ci/cli#262): every CLI option is settable as an environment variable, which is how a workflow reaches options the action has no matching input for. Records the precedence (input > env > default) and the reserved-namespace tradeoff. Cross-reference anchors verified against the built HTML rather than assumed. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Why
Every new CLI option currently needs a matching input added to — and a release cut for — each thin wrapper (
unity-builder,unity-test-runner,unity-activate) before anyone can actually use it from a workflow.--dockerEnv(#261) is the most recent example: shipped in the CLI, unusable from a workflow until three more PRs land.That per-wrapper PR treadmill is the thing this removes.
Each wrapper spawns the CLI as a host child process, which inherits the workflow environment — the wrappers already rely on exactly this for credentials:
This generalises that already-working mechanism from credentials to every option.
What
.env("GAME_CI")— every option is also settable asGAME_CI_<SCREAMING_SNAKE_CASE>:No wrapper change needed — now or for any future option.
On the comment this replaces
src/cli.tscarried a deliberate note against using.env(). That note is correct, and I verified it rather than assuming — a blanket.env()really does fail understrict(true):But its objection is specific to the unprefixed form.
.env(prefix)only maps vars carrying the prefix, so unrelated vars are never considered. This isn't overturning that decision — it's the option the decision never considered.Verified against the real parser configuration (
strip-dashed,dot-notation: false, etc.), not just a synthetic reproduction.Precedence
explicit arg > GAME_CI_* env > option defaultA wrapper passing an explicit flag still wins; the environment only fills what it left unset. The unprefixed credential fallbacks (
UNITY_EMAILetc. inunity-options.ts) are long-standing public contract and are unchanged — this is a superset, not a replacement.Tradeoff
GAME_CI_*is now a reserved namespace: aGAME_CI_var matching no option is a hard failure rather than being ignored. That's deliberate — a typo'dGAME_CI_DOCKER_MEMORY_LIMTshould tell you, not silently do nothing.Tests
5 tests in
src/cli.test.ts(24 pass / 0 fail): prefix mapping, arg-beats-env precedence, non-prefixed vars ignored, unprefixedUNITY_EMAILstill working, and unknown-prefixed-var rejection.That last one is asserted out-of-process — strict failures route through
Cli.handleFailure, whichprocess.exit(1)s, so in-process it takes the test runner down with it.Full-suite check:
1234 pass / 246 failon this branch vs1230 pass / 246 failon untouchedmain— identical failure count, +4 from this PR's new tests. The 246 are pre-existing and unrelated.🤖 Generated with Claude Code