Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 111 additions & 16 deletions .github/actions/setup-e2e-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inputs:
ruby-version:
description: Ruby version to use (only for iOS)
required: false
default: '3.1'
default: '3.2'
xcode-version:
description: Xcode version to select (e.g., 16.3)
required: false
Expand Down Expand Up @@ -89,6 +89,19 @@ runs:
- run: echo "Setup E2E Environment started"
shell: bash

# Set user path for Bitrise vagrant user
- name: Set user paths for Bitrise runner
run: |
echo "USER_HOME=/Users/vagrant" >> "$GITHUB_ENV"
echo "HOME=/Users/vagrant" >> "$GITHUB_ENV"
echo "RUNNER_TOOL_CACHE=/Users/vagrant/hostedtoolcache" >> "$GITHUB_ENV"
echo "RUNNER_TEMP=/Users/vagrant/tmp" >> "$GITHUB_ENV"
# Create the directories if they don't exist
mkdir -p /Users/vagrant/hostedtoolcache
mkdir -p /Users/vagrant/tmp
echo "Using hardcoded vagrant user path: /Users/vagrant"
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: Cross-Platform Path Issue Affects AVD and Foundry

Hardcoding USER_HOME to /Users/vagrant, a macOS-specific path, unconditionally replaces the dynamic $HOME variable. This causes Android AVD setup and Foundry installation to fail on Linux runners, used for Android E2E tests, because the path does not exist on Linux.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Bitrise Runner Paths Fail on Linux

The "Set user paths for Bitrise runner" step runs unconditionally, hardcoding macOS-specific paths (/Users/vagrant). This causes failures on Linux runners used for Android builds because these paths don't exist, leading to mkdir command failures and breaking subsequent steps that rely on these paths, like AVD setup.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Bitrise Runner Paths Fail on Non-macOS

The "Set user paths for Bitrise runner" step runs unconditionally, setting environment variables and creating directories with hardcoded /Users/vagrant paths. This macOS-specific setup causes failures on non-macOS runners (e.g., Linux for Android builds) and other macOS environments where these paths are invalid.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

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

Bug: Bitrise Runner Paths Fail on Linux

The "Set user paths for Bitrise runner" step unconditionally sets HOME and USER_HOME to macOS-specific paths (/Users/vagrant) and creates related directories. This causes failures on Linux runners (used for Android builds) where these paths don't exist, impacting tools and downstream setup steps.

Fix in Cursor Fix in Web


## Android Setup (early for fail-fast) ##

# Set Android environment variables (self-hosted runner has SDK pre-installed)
Expand Down Expand Up @@ -146,8 +159,8 @@ runs:
if: ${{ inputs.platform == 'android'}}
shell: bash
run: |
echo "ANDROID_AVD_HOME=$HOME/.android/avd" >> "$GITHUB_ENV"
mkdir -p "$HOME/.android/avd"
echo "ANDROID_AVD_HOME=$USER_HOME/.android/avd" >> "$GITHUB_ENV"
mkdir -p "$USER_HOME/.android/avd"

- name: Create Android Virtual Device (AVD)
if: ${{ inputs.platform == 'android'}}
Expand Down Expand Up @@ -223,7 +236,7 @@ runs:
run: |
echo "Installing Foundry via foundryup..."

export FOUNDRY_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/.foundry"
export FOUNDRY_DIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/.foundry"
export FOUNDRY_BIN="$FOUNDRY_DIR/bin"

mkdir -p "$FOUNDRY_BIN"
Expand All @@ -238,19 +251,77 @@ runs:
## IOS Setup ##

## Ruby Setup & Cache Management
- name: Setup Ruby
- name: Setup Ruby (use system Ruby for vagrant user)
if: ${{ inputs.platform == 'ios' }}
uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651
with:
ruby-version: ${{ inputs.ruby-version }}

# Install Bundler first
- name: Install bundler
if: ${{ inputs.platform == 'ios' }}
run: gem install bundler -v ${{ inputs.bundler-version }}
working-directory: ios
run: |
# Use system Ruby instead of ruby/setup-ruby action to avoid permission issues
echo "Using system Ruby for vagrant user"

# Check if rbenv is being used and set Ruby version
if command -v rbenv &> /dev/null; then
echo "rbenv detected, checking available Ruby versions"
rbenv versions

# Map requested version to available version on Bitrise stack
REQUESTED_VERSION="${{ inputs.ruby-version }}"

# Check if .ruby-version file exists and has a full version
if [ -f ".ruby-version" ]; then
EXISTING_VERSION=$(cat .ruby-version | tr -d '\n' | tr -d ' ')
echo "Found .ruby-version file with version: $EXISTING_VERSION"

# Check if the version from .ruby-version is available
if rbenv versions --bare | grep -q "^${EXISTING_VERSION}$"; then
RUBY_VERSION="$EXISTING_VERSION"
echo "Using Ruby version from .ruby-version: $RUBY_VERSION"
else
echo "Ruby $EXISTING_VERSION from .ruby-version is not installed"
echo "Available versions:"
rbenv versions
# Fall back to mapping logic below
fi
fi

# If RUBY_VERSION not set, map requested version to available
if [ -z "$RUBY_VERSION" ]; then
if [ "$REQUESTED_VERSION" = "3.1" ]; then
RUBY_VERSION="3.2.9"
echo "Mapping 3.1 -> 3.2.9 (3.1.x not available)"
elif [ "$REQUESTED_VERSION" = "3.2" ]; then
RUBY_VERSION="3.2.9"
echo "Using available Ruby 3.2.9"
elif [ "$REQUESTED_VERSION" = "3.3" ]; then
RUBY_VERSION="3.3.9"
echo "Using available Ruby 3.3.9"
elif [ "$REQUESTED_VERSION" = "3.4" ]; then
RUBY_VERSION="3.4.5"
echo "Using available Ruby 3.4.5"
else
RUBY_VERSION="$REQUESTED_VERSION"
fi
fi
Copy link

Choose a reason for hiding this comment

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

Bug: Ruby Version Override Without Warning

The Ruby setup step silently substitutes the requested ruby-version 3.1 with 3.2. This occurs without warning or explicit user control, violating the input contract and potentially causing unexpected behavior or compatibility issues for workflows expecting Ruby 3.1.

Fix in Cursor Fix in Web


echo "Setting Ruby version to: $RUBY_VERSION"

# Update .ruby-version file to ensure consistency
if [ -f ".ruby-version" ]; then
echo "Backing up and updating .ruby-version file"
cp .ruby-version .ruby-version.backup
echo "$RUBY_VERSION" > .ruby-version
fi
rbenv global "$RUBY_VERSION"
# Reload rbenv
eval "$(rbenv init -)"
fi

ruby --version
gem --version
# Install bundler globally
gem install bundler -v ${{ inputs.bundler-version }}
Copy link

Choose a reason for hiding this comment

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

Bug: GitHub Actions Shell Initialization Issue

The eval "$(rbenv init -)" command in the Ruby setup step only initializes rbenv for its current shell. Since GitHub Actions steps run in separate shells, subsequent steps relying on rbenv (like bundle install or pod install) won't have the correct Ruby environment configured, causing them to fail.

Fix in Cursor Fix in Web

shell: bash

# Install Bundler first (now handled in Ruby setup step above)

# Restore cached Ruby gems
- name: Restore Bundler cache
if: ${{ inputs.platform == 'ios' }}
Expand Down Expand Up @@ -278,7 +349,6 @@ runs:
- name: Generate binstubs for CocoaPods
if: ${{ inputs.platform == 'ios' }}
run: bundle binstubs cocoapods --force --path=vendor/bundle/bin

working-directory: ios
shell: bash

Expand Down Expand Up @@ -308,7 +378,32 @@ runs:
# Select Xcode version
- name: Select Xcode version
if: ${{ inputs.platform == 'ios' }}
run: sudo xcode-select -s /Applications/Xcode_${{ inputs.xcode-version }}.app
run: |
# Check available Xcode versions
echo "Available Xcode versions:"
ls -la /Applications/ | grep -i xcode || echo "No Xcode apps found in /Applications/"

# Try to find the correct Xcode path
REQUESTED_VERSION="${{ inputs.xcode-version }}"
if [ -d "/Applications/Xcode_${REQUESTED_VERSION}.app" ]; then
XCODE_PATH="/Applications/Xcode_${REQUESTED_VERSION}.app"
elif [ -d "/Applications/Xcode.app" ]; then
XCODE_PATH="/Applications/Xcode.app"
echo "Using default Xcode.app since Xcode_${REQUESTED_VERSION}.app not found"
else
# Find any available Xcode version
XCODE_PATH=$(find /Applications -name "Xcode*.app" -type d | head -1)
if [ -n "$XCODE_PATH" ]; then
echo "Using available Xcode: $XCODE_PATH"
else
echo "No Xcode installation found"
exit 1
fi
fi

echo "Setting Xcode path to: $XCODE_PATH"
sudo xcode-select -s "$XCODE_PATH"
xcode-select -p
shell: bash

# Restore CocoaPods cache
Expand Down
Loading