feat: add --android-flavor option for build commands#543
Conversation
- Add androidFlavor to BuildRequestOptions and BuildOptionsPayload schemas - Add CAPGO_ANDROID_FLAVOR to env var loading and NON_CREDENTIAL_KEYS - Wire --android-flavor through CLI args → credentials → splitPayload - Add option to build request, credentials save, and credentials update commands - Inform user during credentials save when defaulting without a flavor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds an optional Android product flavor and a playstore-upload toggle to CLI, schema, credential storage, environment loading, and build request payloads; wires a new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (user)
participant Env as Runtime Env
participant CredStore as Local Credential Store
participant Merge as Merge Logic
participant Builder as Remote Build API
CLI->>Merge: provide flags (--android-flavor, --no-playstore-upload, other creds)
Env->>Merge: provide `CAPGO_ANDROID_FLAVOR` (if set)
CredStore->>Merge: provide saved credentials (including CAPGO_ANDROID_FLAVOR)
Merge->>Merge: determine precedence (CLI > Env > Saved), trim flavor, remove PLAY_CONFIG_JSON if no-playstore-upload
Merge->>Builder: send BuildOptionsPayload (includes androidFlavor) and merged credentials
Builder-->>CLI: build queued/response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2056c6368b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| else { | ||
| log.info('Android flavor not specified (defaulting to Release build without flavor)') | ||
| } |
There was a problem hiding this comment.
Unset CAPGO_ANDROID_FLAVOR when save omits flavor
When --android-flavor is not provided, this branch only logs a default message and does not clear CAPGO_ANDROID_FLAVOR; because saved credentials are merged (updateSavedCredentials keeps existing keys), re-running build credentials save --platform android ... after previously setting a flavor will silently retain the old flavor and future builds still use it. This is especially confusing because the CLI tells the user it is defaulting to a build without flavor.
Useful? React with 👍 / 👎.
Use z.string().trim().min(1) on both buildRequestOptionsSchema and buildOptionsPayloadSchema so whitespace-only values are treated as missing instead of passing through as an empty flavor name.
Add ℹ️ default message for --build-mode matching the pattern of all other default-value messages in the build request flow. Also fix misleading Android flavor default message that conflated flavor with build type.
…tted updateSavedCredentials uses a shallow merge, so re-running `build credentials save --platform android` without --android-flavor silently preserves the previously saved flavor. This is confusing because the CLI tells the user "no product flavor will be used" while the old flavor persists in saved credentials and gets used on the next build. Call removeSavedCredentialKeys after save to explicitly remove the stale flavor key. The update command intentionally preserves existing values since it's designed for partial updates.
There was a problem hiding this comment.
Pull request overview
Adds support for specifying an Android Gradle product flavor for Capgo Cloud builds, propagating it through CLI flags, env vars, saved credentials, and the build request payload.
Changes:
- Add
androidFlavorto build request/options schemas and build options payload. - Add
--android-flavortobuild requestandbuild credentials save/updateCLI commands. - Thread
CAPGO_ANDROID_FLAVORthrough env loading, credentials merging, and payload splitting.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/schemas/build.ts | Extends request/options payload schemas to include androidFlavor. |
| src/index.ts | Adds --android-flavor CLI option to relevant build/credentials commands. |
| src/build/request.ts | Includes CAPGO_ANDROID_FLAVOR in non-secret key splitting and build options payload; wires CLI option into merged creds. |
| src/build/credentials.ts | Loads CAPGO_ANDROID_FLAVOR from environment variables. |
| src/build/credentials-command.ts | Saves/updates CAPGO_ANDROID_FLAVOR in local credentials storage and logs the choice. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| 'CAPGO_ANDROID_APP_DIR', | ||
| 'CAPGO_ANDROID_PROJECT_DIR', | ||
| 'ANDROID_PROJECT_DIR', | ||
| 'CAPGO_ANDROID_FLAVOR', | ||
| ]) |
ToriChanIntegration
left a comment
There was a problem hiding this comment.
Code Review — feat: add --android-flavor option for build commands
Clean, well-scoped PR. The pipeline wiring is correct and consistent with how other non-secret keys are handled. One test fix is required before merge.
🔴 Failing test — test/test-payload-split.mjs
❌ FAILED: NON_CREDENTIAL_KEYS covers all non-secret fields
Error: Expected 14 non-credential keys, got 15
CAPGO_ANDROID_FLAVOR was added to NON_CREDENTIAL_KEYS but test/test-payload-split.mjs still has the hardcoded list of 14 keys. Fix:
const expectedKeys = [
'CAPGO_IOS_SCHEME',
'CAPGO_IOS_TARGET',
'CAPGO_IOS_DISTRIBUTION',
'BUILD_OUTPUT_UPLOAD_ENABLED',
'BUILD_OUTPUT_RETENTION_SECONDS',
'SKIP_BUILD_NUMBER_BUMP',
'CAPGO_IOS_SOURCE_DIR',
'CAPGO_IOS_APP_DIR',
'CAPGO_IOS_PROJECT_DIR',
'IOS_PROJECT_DIR',
'CAPGO_ANDROID_SOURCE_DIR',
'CAPGO_ANDROID_APP_DIR',
'CAPGO_ANDROID_PROJECT_DIR',
'ANDROID_PROJECT_DIR',
+ 'CAPGO_ANDROID_FLAVOR',
]🟡 Minor — update doesn't clear saved flavor, save does
In saveCredentialsCommand, omitting --android-flavor actively removes any saved CAPGO_ANDROID_FLAVOR (good — prevents stale flavor carrying over). In updateCredentialsCommand, omitting it leaves any previously saved value in place. This is an intentional partial-update semantic, but it's worth a short code comment to prevent future confusion.
✅ What's done well
CAPGO_ANDROID_FLAVORcorrectly placed inNON_CREDENTIAL_KEYS— it's not sensitivesplitPayloadmaps it toandroidFlavorinbuildOptions— consistent with all other non-credential keys- Schema uses
z.string().trim().min(1).optional()in bothbuildRequestOptionsSchemaandbuildOptionsPayloadSchema— matches the builder PR - Env var loading (
loadCredentialsFromEnv) is consistent with the existing pattern --android-flavoroption added to all three relevant commands (build request,credentials save,credentials update)
CI
Run tests fails due to the test count issue above. SonarCloud Code Analysis failure — check if it's related to the test or a coverage threshold drop. All other checks pass.
This is a draft — marking request-changes so the test fix is tracked.
…ormalize value - Add options.androidFlavor to hasAndroidOptions so that `build credentials update --android-flavor <name>` auto-detects the android platform without requiring explicit --platform android. - Trim the flavor value before persisting in both save and update commands, rejecting whitespace-only values with a warning.
- Test 9: flavor is loaded from environment - Test 10: empty string is not loaded (truthiness guard) - Test 11: flavor follows CLI > Env > Saved merge precedence - Test 12: flavor is isolated to android platform credentials
loadCredentialsFromEnv() now trims the env var and ignores it when empty after trimming, consistent with the trim+min(1) validation applied in the save and update CLI paths. Added tests for whitespace-only and padded env values.
The NON_CREDENTIAL_KEYS set already contained CAPGO_ANDROID_FLAVOR but the test's expectedKeys list was missing it, causing a count mismatch (expected 14, got 15).
Save clears CAPGO_ANDROID_FLAVOR when --android-flavor is omitted (full replacement), while update intentionally leaves it untouched (partial update). Added a code comment to prevent future confusion.
ToriChanIntegration
left a comment
There was a problem hiding this comment.
Approved ✅
All issues from the previous review are resolved, and the PR is now substantially stronger.
Previous blocker — fixed:
test/test-payload-split.mjsupdated to expect 15NON_CREDENTIAL_KEYSwithCAPGO_ANDROID_FLAVORincluded
New additions since last review:
test/test-credentials.mjs: 6 new tests covering env loading, empty/whitespace rejection, trimming, merge precedence (CLI > Env > Saved), and platform isolation (flavor doesn't leak into iOS credentials) — thorough coverage- Whitespace-only
--android-flavorvalues are trimmed and ignored with a user-facing warning — consistent with how the builder PR handles it - Comment in
updateCredentialsCommandexplaining the intentional asymmetry vssaveCredentialsCommand— good defensive documentation
CI:
Run tests: passing ✅SonarCloudquality gate: passing ✅ (theSonarCloud Code Analysisjob failure is the GitHub Actions step exiting non-zero, not the gate — this is a known draft-PR quirk; the gate itself is green)- All other checks: passing ✅
Ready to merge once the draft is marked ready.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
❌ The last analysis has failed. |
Summary
--android-flavor <flavor>option tobuild request,build credentials save, andbuild credentials updatecommandsNON_CREDENTIAL_KEYS→splitPayload→buildOptions.androidFlavorcredentials save, inform the user when no flavor is specified (defaulting to Release without flavor)Companion builder PR: Cap-go/capgo_builder —
feat/android-flavor-supportUsage
Test plan
build request --android-flavor productionpasses flavor through to buildOptions payloadbuild credentials save --android-flavor productionpersists and shows confirmationbuild credentials savewithout flavor shows default info messageCAPGO_ANDROID_FLAVOR=productionenv var is picked up correctlySummary by CodeRabbit
New Features
Behavior Changes
Tests