Skip to content

chore: point dev to builds.yml#27036

Merged
weitingsun merged 2 commits into
mainfrom
wsun/point-dev-env-to-builds.yml
Mar 10, 2026
Merged

chore: point dev to builds.yml#27036
weitingsun merged 2 commits into
mainfrom
wsun/point-dev-env-to-builds.yml

Conversation

@weitingsun
Copy link
Copy Markdown
Contributor

@weitingsun weitingsun commented Mar 5, 2026

Description

Start to use builds.yml locally.

If we have BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY set to true locally in .js.env then we will use the envs in Builds.yml and .js.env.

Here are the steps:

  1. Source .js.env (early, for the gate).
  2. If flag BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY is true: run loadBuildConfig → applies builds.yml (overwrites env).
  3. Source .js.env again → “Local builds: .js.env overrides builds.yml” — so .js.env wins over anything set by builds.yml.
  4. Legacy remap runs (Bitrise-style vars).

This way - when we retire BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY, all the local builds will use builds.yml and .js.env

Changelog

CHANGELOG entry: Added ability for dev build to use builds.yml as source of truth

Related issues

Fixes:

Manual testing steps

Feature: Build configuration for local builds
  As a local developer
  I want build configuration to load from .js.env or builds.yml depending on a flag
  So that I can use builds.yml when I opt in and .js.env always overrides when present

  Scenario: Local without flag uses .js.env only
    Given I am running the build script locally
    And .js.env exists
    And BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY is not set to "true"
    When I run the build script
    Then loadBuildConfig should not run
    And .js.env should be sourced
    And build env should come from .js.env

  Scenario: Local with flag true uses builds.yml then .js.env overrides
    Given I am running the build script locally
    And .js.env exists and sets BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY=true
    When I run the build script
    Then loadBuildConfig should run and load from builds.yml
    And .js.env should be sourced again after that
    And values from .js.env should override values from builds.yml

  Scenario Outline: .js.env overrides builds.yml for same variable
    Given I am running the build script locally with BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY=true
    And builds.yml sets <var> to "<builds_value>"
    And .js.env sets <var> to "<env_value>"
    When I run the build script
    Then the effective <var> should be "<env_value>"

    Examples:
      | var              | builds_value                         | env_value                               |
      | REWARDS_API_URL  | https://rewards.api.cx.metamask.io   | https://rewards.uat-api.cx.metamask.io |
      | MM_PORTFOLIO_URL | https://portfolio.api.cx.metamask.io | https://portfolio.dev-api.cx.metamask.io |

Screenshots/Recordings

Before

After

Using Pre build
Simulator Screenshot - iPhone 16 - 2026-03-05 at 12 55 12

Using local build (yarn start:ios)
Simulator Screenshot - iPhone 16 - 2026-03-05 at 15 08 27

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches the build pipeline and environment variable precedence, which can break local/CI builds if the gating or sourcing order is wrong. Runtime app changes are limited to extra debug info on the settings screen.

Overview
Build configuration changes: scripts/build.sh now conditionally loads builds.yml when BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY=true (for GitHub Actions and local opt-in), sources .js.env early to read the flag, then sources it again afterward so local values override builds.yml. Legacy Bitrise env remapping is kept for non-GHA runs, and missing *_DEV/_QA/_PROD secrets only hard-fail on the legacy path.

Debug visibility: The hidden environment info section in AppInformation now also displays REWARDS_API_URL and MM_PORTFOLIO_URL (or if unset).

Written by Cursor Bugbot for commit 54fe502. This will update automatically on new commits. Configure here.

@weitingsun weitingsun requested review from a team as code owners March 5, 2026 04:29
@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Mar 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions Bot added the size-S label Mar 5, 2026
Comment thread app/components/Views/Settings/AppInformation/index.js Outdated
Comment thread scripts/build.sh
@weitingsun weitingsun force-pushed the wsun/point-dev-env-to-builds.yml branch from e460c17 to 84ace64 Compare March 5, 2026 21:27
@tommasini tommasini changed the title chore: point dev to build.yml chore: point dev to builds.yml Mar 6, 2026
@@ -244,6 +244,12 @@ class AppInformation extends PureComponent {
<Text style={styles.branchInfo}>
{`Remote Feature Flag Distribution: ${getFeatureFlagAppDistribution()}`}
</Text>
<Text style={styles.branchInfo}>
{`Rewards API URL: ${process.env.REWARDS_API_URL ?? '—'}`}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DO we want to keep the api url at AppInformation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good for awhile to test - this is listed in Builds.yml so it should not be a secret

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to remove it though if you don't think it's needed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me!

Comment thread scripts/build.sh
remapEnvVariable() {
local old_var_name="$1"
local new_var_name="$2"
if [ -z "${!old_var_name}" ]; then
echo "Error: $old_var_name does not exist in the environment."
return 1
return 0
Copy link
Copy Markdown
Contributor

@tommasini tommasini Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 0 is a silent failure risk on Bitrise. If a secret is ever misconfigured there, the build will pass and ship broken instead of failing fast

The proper fix would have been to distinguish Bitrise from local, e.g. using a BITRISE_IO env var (which Bitrise sets automatically):

if [ -z "${GITHUB_ACTIONS:-}" ]; then
    if [ -n "${BITRISE_IO:-}" ]; then
        # On Bitrise: missing source var IS an error
        remapMainProdEnvVariables  # still uses return 1
    fi
    # local: skip remap entirely — .js.env already has canonical names
fi

Or maybe cleaner

# Only Bitrise needs legacy remap
if [ -z "${GITHUB_ACTIONS:-}" ] && [ "${BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY:-false}" != "true" ]; then
    # Bitrise: _DEV/_QA/_PROD vars MUST exist — keep return 1
    remapMainProdEnvVariables
    ...
fi

@weitingsun weitingsun requested a review from tommasini March 6, 2026 23:48
remove appinformation display

add back environment

remove

add spacing back

use BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY flag

address comment
@weitingsun weitingsun force-pushed the wsun/point-dev-env-to-builds.yml branch from fca7b53 to d7c572f Compare March 6, 2026 23:49
Comment thread scripts/build.sh
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 9, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are limited to:

  1. app/components/Views/Settings/AppInformation/index.js – a Settings informational screen (App Information view). This screen is not part of any critical user flow such as onboarding, account management, confirmations, swaps, multi-chain, Snaps, Card, Ramps, or Trending. It does not integrate with Engine controllers, transaction flows, network selection, or shared critical components like Browser, Confirmations, or AccountSelector.
  2. scripts/build.sh – a build script. This affects build/infrastructure but not runtime application logic. There are no changes to app/core/, controllers, Engine initialization, navigation, shared UI primitives, or E2E test infrastructure.

No available E2E tag specifically covers the App Information screen, and the modified areas do not overlap with flows validated by SmokeAccounts, SmokeConfirmations, SmokeWalletPlatform, or any other tag. Therefore, running Detox E2E suites is not required for safe validation of this PR.

Given the strictly informational UI scope and isolated build script change, the overall risk is low.

Performance Test Selection:
The changes do not affect rendering-heavy components, account lists, asset loading, onboarding, login, swaps, predictions, perps, or app launch/initialization logic. Therefore, no performance-sensitive areas are impacted and performance tests are not required.

View GitHub Actions results

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread scripts/build.sh
if ! loadBuildConfig "$METAMASK_BUILD_TYPE" "$METAMASK_ENVIRONMENT"; then
# Non-GHA: source .js.env early so BUILDS_ENABLED_WITH_GH_ACTIONS_TEMPORARY is set for the gate (local can opt in)
if [ -z "${GITHUB_ACTIONS:-}" ] && [ -e "$JS_ENV_FILE" ]; then
source "$JS_ENV_FILE"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-sourcing .js.env overwrites command-line build arguments

High Severity

The new source "$JS_ENV_FILE" calls at lines 1007 and 1024 unconditionally overwrite METAMASK_BUILD_TYPE and METAMASK_ENVIRONMENT, which were already correctly set from command-line arguments (MODE/ENVIRONMENT) at lines 34–35. Since .js.env.example exports both variables unconditionally (e.g., export METAMASK_BUILD_TYPE="main"), any developer passing a different build type or environment via CLI (e.g., ./scripts/build.sh ios flask production) will have those values silently replaced by .js.env defaults. This causes loadBuildConfig and the legacy remap to operate on the wrong build configuration.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fine for .js.env to override these values

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 9, 2026

@weitingsun weitingsun enabled auto-merge March 9, 2026 23:20
@weitingsun weitingsun added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 44f7fd2 Mar 10, 2026
65 checks passed
@weitingsun weitingsun deleted the wsun/point-dev-env-to-builds.yml branch March 10, 2026 00:08
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 10, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-S team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants