Skip to content

E2e env actions #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open

E2e env actions #85

wants to merge 78 commits into from

Conversation

jake-perkins
Copy link
Contributor

@jake-perkins jake-perkins commented Jul 9, 2025

🚀 Introduce Reusable E2E Environment Setup GitHub Action

📂 What’s new

This PR introduces a reusable composite GitHub Action at .github/actions/setup-e2e-env designed to standardize and streamline the setup of E2E test environments across iOS and Android platforms.


✅ Features

🧰 Common Tooling Setup

  • Node.js (node-version input)
  • Yarn (yarn-version via Corepack)
  • Detox CLI
  • Foundry (via foundryup)
  • Caching support for:
    • node_modules (Yarn)
    • Ruby gems (vendor/bundle)
    • CocoaPods (Pods/)

🍎 iOS Platform Support (platform: ios)

  • Ruby environment setup (ruby-version)
  • Bundler installation (bundler-version) and gem resolution via bundle install
  • Xcode version selection (xcode-version)
  • CocoaPods installation using bundle exec pod install
  • Optional simulator booting (setup-simulator)
    • Simulator device name via ios-simulator-device
  • applesimutils installation via Homebrew

🤖 Android Platform Support (platform: android)

  • Java JDK setup (jdk-version and jdk-distribution)
  • Android SDK setup:
    • platform-tools, build-tools, emulator, system images
    • License acceptance and update
  • Android NDK installation (ndk-version)
  • Emulator dependencies installed via apt
  • PATH extended with:
    • Android tools (platform-tools, emulator, cmdline-tools)
    • NDK toolchains (LLVM)

🧪 Testing

Verified on:

  • macos-14 and macos-14-large runners
  • iOS simulator boot and CocoaPods integration
  • Android emulator and NDK setup

Example usage:


📥 Inputs

Name Description
platform Target platform: ios or android (required)
node-version Node.js version (default: 20.18.0)
yarn-version Yarn version to activate with Corepack (default: 1.22.22)
setup-simulator Whether to boot a simulator/emulator (default: false)
ios-device iOS simulator device name (default: "iPhone 15")
bundler-version Bundler version for iOS Ruby setup (default: 2.5.8)
cache-prefix Prefix for cache keys (default: e2e)
ruby-version Ruby version to install (default: 3.1)
xcode-version Xcode version to select (default: 16.2)
jdk-version Java version for Android (default: 17)
jdk-distribution JDK distribution (default: temurin)
ndk-version Android NDK version to install (default: 26.1.10909125)
foundry-version Foundry version to install (default: v1.2.3)
android-device AVD device profile (default "pixel")
android-api-level Android API level to use (default: 34)
android-abi System architecture ABI for the Android system image ( default: x86_64)

📌 Notes

  • iOS-only inputs are ignored when platform: android and vice versa.
  • Simulator booting logic is guarded with safety checks and state awareness.
  • NDK toolchains are added to PATH for CLI-based native tools like clang or ndk-build.
  • Memory usage for Node.js is increased via NODE_OPTIONS=--max-old-space-size=4096.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Not Platform-Agnostic

The NDK toolchain path in the Add NDK related toolchains to PATH step is hardcoded to linux-x86_64. This prevents the action from correctly locating the NDK toolchain on non-Linux x86_64 runners, such as macOS (which requires darwin-x86_64) or ARM-based Linux systems.

Locations (1)
Fix in Cursor Fix in Web

setup-simulator:
description: 'Whether to setup simulator/emulator'
required: false
default: 'false'
Copy link

Choose a reason for hiding this comment

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

Bug: Simulator Setup Incomplete, YAML Parsing Issues

The setup-simulator input is defined but its functionality to boot simulators/emulators is not implemented; the action only prepares the environment (creates Android AVD, lists iOS devices) without starting them. Additionally, several description fields in the inputs section lack YAML quotes, potentially causing parsing errors.

Locations (1)
Fix in Cursor Fix in Web

required: true
secret-name:
description: 'The name of the secret in AWS Secrets Manager'
required: true
Copy link

Choose a reason for hiding this comment

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

Bug: Required Input Ignored in Action

The secret-name input is declared as required but is entirely ignored by the action. Instead, the AWS secret name is determined by hardcoded logic based on the environment input, leading to user confusion and a misleading required input.

Locations (1)
Fix in Cursor Fix in Web

For self hosted nodes we can decoupling some steps.
aws-role-to-assume: ${{ inputs.keystore-role-to-assume }}
aws-region: 'us-east-2'
platform: 'ios'
environment: ${{ inputs.environment }}
Copy link

Choose a reason for hiding this comment

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

Bug: Keystore Configuration Ignores Required Secret Name

The configure-keystore action's secret-name input is marked as required but is not provided by its caller (setup-e2e-env), leading to a workflow failure. Additionally, the configure-keystore action ignores this input, dynamically determining the secret name from the environment input instead.

Additional Locations (1)
Fix in Cursor Fix in Web

## IOS Setup ##
- name: Configure iOS Signing Certificates
if: ${{ inputs.platform == 'ios' && inputs.configure-keystores == 'true' }}
uses: MetaMask/github-tools/.github/actions/configure-keystore@e2e-env-actions
Copy link

Choose a reason for hiding this comment

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

Bug: Local Action Reference Error

The setup-e2e-env action incorrectly references an external MetaMask/github-tools/.github/actions/configure-keystore@e2e-env-actions (lines 144, 233). This change introduces a local configure-keystore action, which should be used instead, as the external reference is likely invalid.

Additional Locations (1)
Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Issue Across Platforms

The Android NDK toolchain path is hardcoded to linux-x86_64, making the setup incompatible with non-Linux runners, such as macOS, where the path should be darwin-x86_64.

Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Not Platform-Agnostic

The NDK toolchain path in the 'Add NDK related toolchains to PATH' step is hardcoded to linux-x86_64. This prevents the action from correctly setting up the NDK on non-Linux runners (e.g., macOS, Windows), as the prebuilt directory varies by host platform (e.g., darwin-x86_64 for macOS, windows-x86_64 for Windows). The path should dynamically adapt to the runner.os.

Fix in Cursor Fix in Web

run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
echo "$NDK_TOOLCHAIN" >> "$GITHUB_PATH"
echo "$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}" >> "$GITHUB_PATH"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Path and SDK Environment Mismatch

The NDK toolchain path hardcodes linux-x86_64, which will cause Android builds to fail on macOS runners where darwin-x86_64 is required. The path should dynamically determine the correct operating system and architecture. Additionally, there is inconsistent use of ANDROID_SDK_ROOT and ANDROID_HOME throughout the Android setup, which can lead to path resolution issues.

Fix in Cursor Fix in Web

required: true
secret-name:
description: 'The name of the secret in AWS Secrets Manager'
required: true
Copy link

Choose a reason for hiding this comment

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

Bug: Unused Required Input Causes Misleading Configuration

The secret-name input is defined as required but is never used by the action. Instead, the secret name is dynamically determined from the environment input via a hardcoded mapping. This makes the secret-name input misleading and forces callers to provide an unnecessary value.

Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Path Issue on macOS Builds

The NDK toolchain path is hardcoded to linux-x86_64, which causes Android builds to fail on non-Linux platforms like macOS, where the path should dynamically resolve to darwin-x86_64.

Fix in Cursor Fix in Web

SECRET_NAME="metamask-mobile-main-signing-certificates"
;;
*)
echo "❌ Unknown environment: ${{ inputs.environment }}"
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Error Message for Unknown Targets

The error message for unknown targets incorrectly references inputs.environment instead of the defined inputs.target, resulting in an empty value being displayed in the error output.

Fix in Cursor Fix in Web

## IOS Setup ##
- name: Configure iOS Signing Certificates
if: ${{ inputs.platform == 'ios' && inputs.configure-keystores == 'true' }}
uses: MetaMask/github-tools/.github/actions/configure-keystore@e2e-env-actions
Copy link

Choose a reason for hiding this comment

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

Bug: Action References External Path Incorrectly

The setup-e2e-env action incorrectly references the configure-keystore action using an external path (MetaMask/github-tools/.github/actions/configure-keystore@e2e-env-actions). Since configure-keystore is defined locally within this repository, it should be referenced via a relative path (e.g., ../configure-keystore). This issue occurs in multiple instances.

Additional Locations (1)
Fix in Cursor Fix in Web

## Launch AVD

- name: Set ANDROID_AVD_HOME for downstream steps
if: ${{ inputs.platform == 'android'}}
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Issue on macOS

The NDK toolchain path is hardcoded to linux-x86_64, preventing the action from working on macOS runners where darwin-x86_64 is required. Additionally, there is inconsistent spacing in if conditions, specifically missing a space before the closing braces }} for Android-related steps.

Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Hardcoded for Linux

The NDK toolchain path is hardcoded to linux-x86_64, which causes failures on other operating systems and architectures, such as macOS (where it should be darwin-x86_64) or ARM64 systems.

Fix in Cursor Fix in Web

SECRET_NAME="metamask-mobile-main-signing-certificates"
;;
*)
echo "❌ Unknown environment: ${{ inputs.environment }}"
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Error Message Variable Reference

The Determine signing secret name step's error message incorrectly references ${{ inputs.environment }} instead of ${{ inputs.target }}. This causes the error message to display an empty value when an unknown target is provided, rather than the actual invalid input.

Fix in Cursor Fix in Web

SECRET_NAME="metamask-mobile-main-signing-certificates"
;;
*)
echo "❌ Unknown environment: ${{ inputs.environment }}"
Copy link

Choose a reason for hiding this comment

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

Bug: Invalid Target Error Message Bug

The error message for unknown targets incorrectly references inputs.environment instead of inputs.target. This causes an empty value to be displayed in the error message when an invalid target is provided.

Fix in Cursor Fix in Web

- name: Select Xcode version
if: ${{ inputs.platform == 'ios' }}
run: sudo xcode-select -s /Applications/Xcode_${{ inputs.xcode-version }}.app/Contents/Developer
shell: bash
Copy link

Choose a reason for hiding this comment

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

Bug: Redundant Xcode Version Selection in CI

The setup-e2e-env action contains duplicate Xcode version selection steps for iOS. The first step (line 144) uses an incomplete path and lacks the shell: bash directive, while the second step (line 196) uses the correct path and includes the shell directive. The second step overrides the first, rendering the initial selection redundant.

Fix in Cursor Fix in Web

if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
echo "$NDK_TOOLCHAIN" >> "$GITHUB_PATH"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Incorrect on Non-Linux Runners

The NDK toolchain path is hardcoded to linux-x86_64 in the Android setup step. This causes an incorrect path to be added to GITHUB_PATH on non-Linux x86_64 runners (e.g., macOS, where darwin-x86_64 is expected, or ARM64 runners), leading to NDK toolchain setup failures.

Fix in Cursor Fix in Web

"platforms;android-${{ inputs.android-api-level }}" \
"build-tools;34.0.0" \
"emulator" \
"system-images;android-${{ inputs.android-api-level }};google_apis;${{ inputs.android-abi }}" \
Copy link

Choose a reason for hiding this comment

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

Bug: Shell Syntax Error with Trailing Backslash

A trailing backslash after the system-images package in the sdkmanager --install command causes a shell syntax error. The backslash indicates line continuation, but no content follows on the next line.

Fix in Cursor Fix in Web

SECRET_NAME="metamask-mobile-main-signing-certificates"
;;
*)
echo "❌ Unknown environment: ${{ inputs.environment }}"
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Target Reference in Error Message

The error message for an unknown target in the Determine signing secret name step incorrectly references inputs.environment instead of the defined inputs.target. This causes the error message to display an empty value.

Fix in Cursor Fix in Web

# path: ios/Pods
# key: ${{ inputs.cache-prefix }}-pods-${{ inputs.platform }}-${{ runner.os }}-${{ hashFiles('ios/Podfile.lock') }}
# restore-keys: |
# ${{ inputs.cache-prefix }}-pods-${{ inputs.platform }}-${{ runner.os }}-
Copy link

Choose a reason for hiding this comment

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

Bug: Redundant Xcode Selection Steps

The setup-e2e-env action contains two "Select Xcode version" steps for iOS. The first step (lines 142-145) uses an incorrect path (/Applications/Xcode_X.X.app), which is immediately overridden by the second step (lines 195-198) that uses the correct path (/Applications/Xcode_X.X.app/Contents/Developer), making the first step redundant. Additionally, there is commented-out code for Xcode selection and CocoaPods cache restoration, indicating leftover development/debugging code.

Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Not Arch-Independent

The NDK toolchain path is hardcoded to linux-x86_64. This prevents Android E2E setup from finding the NDK toolchain on macOS runners, where the path should dynamically resolve to darwin-x86_64 or darwin-arm64 based on the runner's architecture.

Fix in Cursor Fix in Web

NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
echo "$NDK_TOOLCHAIN" >> "$GITHUB_PATH"
echo "$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}" >> "$GITHUB_PATH"
shell: bash
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Path Hardcoded for Linux Only

The NDK toolchain path is hardcoded to linux-x86_64 (line 321), which is incorrect for non-Linux runners (e.g., macOS requires darwin-x86_64). This step lacks a runner.os == 'Linux' guard, causing NDK tools to not be found on other platforms.

Fix in Cursor Fix in Web

- name: Select Xcode version
if: ${{ inputs.platform == 'ios' }}
run: sudo xcode-select -s /Applications/Xcode_${{ inputs.xcode-version }}.app/Contents/Developer
shell: bash
Copy link

Choose a reason for hiding this comment

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

Bug: iOS Xcode Selection Fails on GitHub Runners

The setup-e2e-env action includes duplicate Xcode version selection steps for iOS. A step conditional for self-hosted runners and another unconditional step for all iOS platforms lead to self-hosted runners executing xcode-select twice. Additionally, the unconditional step attempts to select Xcode using a path that may not exist on GitHub-hosted runners, potentially causing build failures. This indicates an incorrect implementation of intended distinct Xcode paths for self-hosted versus GitHub-hosted environments.

Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Incorrect on macOS

The NDK toolchain path is hardcoded to linux-x86_64 in the Add NDK related toolchains to PATH step. This causes Android setup to fail on macOS runners, as the correct path for macOS is darwin-x86_64. The path should be determined dynamically based on runner.os.

Fix in Cursor Fix in Web

# path: ios/Pods
# key: ${{ inputs.cache-prefix }}-pods-${{ inputs.platform }}-${{ runner.os }}-${{ hashFiles('ios/Podfile.lock') }}
# restore-keys: |
# ${{ inputs.cache-prefix }}-pods-${{ inputs.platform }}-${{ runner.os }}-
Copy link

Choose a reason for hiding this comment

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

Bug: Action File Cleanup Needed

The action.yml contains stray commented-out debug/development code for Xcode version selection and CocoaPods cache restoration. Additionally, the if conditional expression if: ${{ inputs.platform == 'ios'}} is missing a space before the closing }}.

Fix in Cursor Fix in Web

run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
echo "$NDK_TOOLCHAIN" >> "$GITHUB_PATH"
echo "$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}" >> "$GITHUB_PATH"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Path Issues Across Platforms

The Android NDK toolchain path is hardcoded to linux-x86_64, which is incorrect for macOS runners where darwin-x86_64 is required. This path also inconsistently uses $ANDROID_SDK_ROOT instead of $ANDROID_HOME, which is used by other Android setup steps, potentially leading to incorrect NDK paths.

Fix in Cursor Fix in Web

- name: Add NDK related toolchains to PATH
if: ${{ inputs.platform == 'android' }}
run: |
NDK_TOOLCHAIN="$ANDROID_SDK_ROOT/ndk/${{ inputs.ndk-version }}/toolchains/llvm/prebuilt/linux-x86_64/bin"
Copy link

Choose a reason for hiding this comment

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

Bug: NDK Toolchain Path Incorrect on macOS

The NDK toolchain path is hardcoded to linux-x86_64. This is incorrect for macOS runners, where the path should be darwin-x86_64, causing the NDK toolchain to not be found in PATH.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants