Skip to content
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

fix: eas build failed after changing ruby versions #1428

Merged
merged 7 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 1 addition & 24 deletions .github/workflows/check-android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,12 @@ jobs:
- name: Setup repo
uses: actions/checkout@v4

- name: Clean Android Device
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- name: Setup node
uses: actions/[email protected]
with:
node-version: 20.x
cache: "yarn"

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
with:
Expand All @@ -49,10 +32,4 @@ jobs:
run: yarn install

- name: Build Android app
run: eas build --platform android --profile development --local --output ${{ github.workspace }}/app-release.apk

- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: app-release
path: ${{ github.workspace }}/app-release.apk
run: eas build --profile development --platform android --non-interactive
23 changes: 2 additions & 21 deletions .github/workflows/check-ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
build:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4
Expand All @@ -31,25 +31,6 @@ jobs:
- name: Install dependencies
run: |
yarn install
yarn cache clean

- name: Free up disk space
run: |
sudo rm -rf ~/Library/Developer/Xcode/DerivedData/*
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/*
sudo rm -rf ~/Library/Developer/CoreSimulator/Devices/*
sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*

- name: Build iOS app
run: eas build --profile ios-simulator --platform ios --local --non-interactive --output ${{ github.workspace }}/app-release.ipa

- name: Clean up Derived Data and Cache
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/expo/*

- name: Upload IPA artifact
uses: actions/upload-artifact@v4
with:
name: app-release
path: ${{ github.workspace }}/app-release.ipa
run: eas build --profile ios-simulator --platform ios --non-interactive
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.5
8 changes: 5 additions & 3 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
},
"node": "20.15.1",
"ios": {
"cocoapods": "1.16.2"
"cocoapods": "1.16.2",
"image": "macos-sonoma-14.6-xcode-16.1"
},
"android": {
"resourceClass": "medium"
"resourceClass": "large"
}
},
"production": {
Expand All @@ -29,7 +30,8 @@
"node": "20.15.1",
"ios": {
"resourceClass": "large",
"cocoapods": "1.16.2"
"cocoapods": "1.16.2",
"image": "macos-sonoma-14.6-xcode-16.1"
}
},
"production-android": {
Expand Down
7 changes: 5 additions & 2 deletions ios/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
source 'https://rubygems.org'

# Specify minimum bundler version for Ruby 3.3.x compatibility
gem 'bundler', '>= 2.4.0'
# Specify Ruby version for compatibility
ruby '~> 3.2.5' # If you are updating this, update the version in the .ruby-version file

# Specify bundler version that works with Ruby 3.3
gem 'bundler', '~> 2.5.16'

gem 'cocoapods'
gem 'cocoapods-pod-linkage'
Expand Down
7 changes: 5 additions & 2 deletions ios/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ PLATFORMS

DEPENDENCIES
activesupport (>= 6.1.7.3, < 7.1.0)
bundler (>= 2.4.0)
bundler (~> 2.5.16)
cocoapods
cocoapods-pod-linkage

RUBY VERSION
ruby 3.2.5p208

BUNDLED WITH
2.6.1
2.5.23
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"android:reverse": "adb reverse tcp:8081 tcp:8081 && adb reverse tcp:9875 tcp:9875",
"android:sendApk": "./scripts/android/sendApk.sh",
"build": "node scripts/build/build.js",
"clean": "./scripts/reactNativeCleanBuild.sh",
"commit": "git show --format=\"%h\" --no-patch",
"db": "ts-node scripts/migrations/db.ts",
"lint": "eslint --max-warnings 2500",
"lint:errors": "eslint --quiet",
"ios": "expo run:ios",
"ios:checkBuildDeps": "./scripts/ios/checkBuildDeps.sh",
"run:ios": "EXPO_ENV=dev expo run:ios",
"postinstall": "patch-package && node scripts/wasm.js && husky install && cross-os postinstall",
"start": "EXPO_ENV=dev expo start --scheme converse-dev",
Expand Down
77 changes: 77 additions & 0 deletions scripts/ios/checkBuildDeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

# ANSI color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
BOLD='\033[1m'

# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Function to print status
print_status() {
local name=$1
local version=$2
local path=$3
local status=$4

printf "${BOLD}%-12s${NC}" "$name"

if [ "$status" = "OK" ]; then
printf "${GREEN}✓${NC} "
else
printf "${RED}✗${NC} "
fi

printf "%-45s" "$version"
echo "$path"
}

echo -e "\n${BOLD}Checking iOS build dependencies...${NC}\n"

# Check Ruby
if command_exists ruby; then
RUBY_VERSION=$(ruby -v)
RUBY_PATH=$(which ruby)
print_status "RUBY" "$RUBY_VERSION" "$RUBY_PATH" "OK"
else
print_status "RUBY" "Not installed" "N/A" "ERROR"
fi

# Check Bundler
if command_exists bundle; then
BUNDLER_VERSION=$(bundle -v)
BUNDLER_PATH=$(which bundle)
print_status "BUNDLER" "$BUNDLER_VERSION" "$BUNDLER_PATH" "OK"
else
print_status "BUNDLER" "Not installed" "N/A" "ERROR"
fi

# Check CocoaPods
if command_exists pod; then
POD_VERSION=$(pod --version)
POD_PATH=$(which pod)
print_status "COCOAPODS" "v$POD_VERSION" "$POD_PATH" "OK"
else
print_status "COCOAPODS" "Not installed" "N/A" "ERROR"
fi

# Print Gem environment
echo -e "\n${BOLD}Ruby Gem Environment:${NC}"
echo "GEM HOME: $(gem env home)"
echo "GEM PATH: $(gem env gempath)"

# Check Gemfile configuration
if [ -f "ios/Gemfile" ]; then
echo -e "\n${BOLD}Gemfile Configuration:${NC}"
echo "Ruby Version: $(grep "ruby '" ios/Gemfile | cut -d"'" -f2)"
echo "Bundler Version: $(grep "bundler" ios/Gemfile | grep -v "#" | head -n1)"
else
echo -e "\n${RED}Warning: ios/Gemfile not found${NC}"
fi
Comment on lines +68 to +75
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add version compatibility validation

The script checks for the presence of Ruby and Bundler versions but doesn't validate if they match the required versions.

Add version validation:

 # Check Gemfile configuration
 if [ -f "ios/Gemfile" ]; then
     echo -e "\n${BOLD}Gemfile Configuration:${NC}"
-    echo "Ruby Version: $(grep "ruby '" ios/Gemfile | cut -d"'" -f2)"
-    echo "Bundler Version: $(grep "bundler" ios/Gemfile | grep -v "#" | head -n1)"
+    REQUIRED_RUBY_VERSION=$(grep "ruby '" ios/Gemfile | cut -d"'" -f2)
+    REQUIRED_BUNDLER_VERSION=$(grep "bundler" ios/Gemfile | grep -v "#" | head -n1 | grep -o "'.*'" | tr -d "'")
+    CURRENT_RUBY_VERSION=$(ruby -v | cut -d' ' -f2)
+    CURRENT_BUNDLER_VERSION=$(bundle -v | cut -d' ' -f3)
+    
+    echo "Required Ruby Version: $REQUIRED_RUBY_VERSION"
+    echo "Current Ruby Version: $CURRENT_RUBY_VERSION"
+    echo "Required Bundler Version: $REQUIRED_BUNDLER_VERSION"
+    echo "Current Bundler Version: $CURRENT_BUNDLER_VERSION"
+    
+    if [[ ! "$CURRENT_RUBY_VERSION" =~ ^$REQUIRED_RUBY_VERSION ]]; then
+        echo -e "${RED}Error: Ruby version mismatch${NC}"
+        exit 1
+    fi
+    
+    if [[ ! "$CURRENT_BUNDLER_VERSION" =~ ^$REQUIRED_BUNDLER_VERSION ]]; then
+        echo -e "${RED}Error: Bundler version mismatch${NC}"
+        exit 1
+    fi
 else
     echo -e "\n${RED}Warning: ios/Gemfile not found${NC}"
+    exit 1
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Check Gemfile configuration
if [ -f "ios/Gemfile" ]; then
echo -e "\n${BOLD}Gemfile Configuration:${NC}"
echo "Ruby Version: $(grep "ruby '" ios/Gemfile | cut -d"'" -f2)"
echo "Bundler Version: $(grep "bundler" ios/Gemfile | grep -v "#" | head -n1)"
else
echo -e "\n${RED}Warning: ios/Gemfile not found${NC}"
fi
# Check Gemfile configuration
if [ -f "ios/Gemfile" ]; then
echo -e "\n${BOLD}Gemfile Configuration:${NC}"
REQUIRED_RUBY_VERSION=$(grep "ruby '" ios/Gemfile | cut -d"'" -f2)
REQUIRED_BUNDLER_VERSION=$(grep "bundler" ios/Gemfile | grep -v "#" | head -n1 | grep -o "'.*'" | tr -d "'")
CURRENT_RUBY_VERSION=$(ruby -v | cut -d' ' -f2)
CURRENT_BUNDLER_VERSION=$(bundle -v | cut -d' ' -f3)
echo "Required Ruby Version: $REQUIRED_RUBY_VERSION"
echo "Current Ruby Version: $CURRENT_RUBY_VERSION"
echo "Required Bundler Version: $REQUIRED_BUNDLER_VERSION"
echo "Current Bundler Version: $CURRENT_BUNDLER_VERSION"
if [[ ! "$CURRENT_RUBY_VERSION" =~ ^$REQUIRED_RUBY_VERSION ]]; then
echo -e "${RED}Error: Ruby version mismatch${NC}"
exit 1
fi
if [[ ! "$CURRENT_BUNDLER_VERSION" =~ ^$REQUIRED_BUNDLER_VERSION ]]; then
echo -e "${RED}Error: Bundler version mismatch${NC}"
exit 1
fi
else
echo -e "\n${RED}Warning: ios/Gemfile not found${NC}"
exit 1
fi


echo -e "\nDone checking dependencies.\n"
44 changes: 44 additions & 0 deletions scripts/reactNativeCleanBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

###############################################################
# Quickly cleans and rebuilds a React Native project by moving
# build directories to Trash and reinstalling dependencies.
#
# Uses AppleScript for fast native Trash operations, similar
# to Cmd+Delete in Finder. This is much faster than rm -rf.
#
# Side Effects:
# - Moves node_modules, ios/build, ios/Pods to Trash
# - Runs yarn install
# - Runs pod install for iOS
# - Prints status messages to terminal
#
# Example:
# In terminal from project root:
# ./scripts/reactNativeCleanBuild.sh
#
# Output:
# Moving node_modules to trash...
# Moving ios/build to trash...
# Moving ios/Pods to trash...
# Running yarn install...
# Running pod install...
# Clean and rebuild complete!
###############################################################

echo "Moving node_modules to trash..."
osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/node_modules\""

echo "Moving ios/build to trash..."
osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/ios/build\""

echo "Moving ios/Pods to trash..."
osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/ios/Pods\""
Comment on lines +29 to +36
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling and platform checks

The script uses macOS-specific AppleScript commands without platform verification or error handling.

Consider this improved implementation:

+# Check if running on macOS
+if [[ "$OSTYPE" != "darwin"* ]]; then
+  echo "Error: This script requires macOS"
+  exit 1
+fi
+
+remove_if_exists() {
+  local path="$1"
+  if [ -e "$path" ]; then
+    echo "Moving $path to trash..."
+    if ! osascript -e "tell app \"Finder\" to delete POSIX file \"$path\""; then
+      echo "Error: Failed to move $path to trash"
+      exit 1
+    fi
+  fi
+}
+
-echo "Moving node_modules to trash..."
-osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/node_modules\""
-
-echo "Moving ios/build to trash..."
-osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/ios/build\""
-
-echo "Moving ios/Pods to trash..."
-osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/ios/Pods\""
+remove_if_exists "$PWD/node_modules"
+remove_if_exists "$PWD/ios/build"
+remove_if_exists "$PWD/ios/Pods"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "Moving node_modules to trash..."
osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/node_modules\""
echo "Moving ios/build to trash..."
osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/ios/build\""
echo "Moving ios/Pods to trash..."
osascript -e "tell app \"Finder\" to delete POSIX file \"$PWD/ios/Pods\""
# Check if running on macOS
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "Error: This script requires macOS"
exit 1
fi
remove_if_exists() {
local path="$1"
if [ -e "$path" ]; then
echo "Moving $path to trash..."
if ! osascript -e "tell app \"Finder\" to delete POSIX file \"$path\""; then
echo "Error: Failed to move $path to trash"
exit 1
fi
fi
}
remove_if_exists "$PWD/node_modules"
remove_if_exists "$PWD/ios/build"
remove_if_exists "$PWD/ios/Pods"


echo "Running yarn install..."
yarn install

echo "Running pod install..."
cd ios && pod install && cd ..
Comment on lines +38 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for dependency installation

The dependency installation commands lack error handling.

Apply this improvement:

 echo "Running yarn install..."
-yarn install
+if ! yarn install; then
+  echo "Error: yarn install failed"
+  exit 1
+fi
 
 echo "Running pod install..."
-cd ios && pod install && cd ..
+if ! (cd ios && pod install); then
+  echo "Error: pod install failed"
+  exit 1
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "Running yarn install..."
yarn install
echo "Running pod install..."
cd ios && pod install && cd ..
echo "Running yarn install..."
if ! yarn install; then
echo "Error: yarn install failed"
exit 1
fi
echo "Running pod install..."
if ! (cd ios && pod install); then
echo "Error: pod install failed"
exit 1
fi


echo "Clean and rebuild complete!"
Loading