Skip to content

[MOO-1785] Upgrade Detox to 20.x #235

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 7 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/actions/create-native-bundle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
mkdir -p ${{ inputs.platform }}/assets
cd Native-Mobile-Resources-main/deployment/native && \
/tmp/mxbuild/modeler/tools/node/linux-x64/node \
/tmp/mxbuild/modeler/tools/node/node_modules/react-native/local-cli/cli.js \
/tmp/mxbuild/modeler/tools/node/node_modules/react-native/cli.js \
bundle --verbose --platform ${{ inputs.platform }} --dev false \
--config "$PWD/metro.config.js" \
--bundle-output $GITHUB_WORKSPACE/${{ inputs.platform }}/index.${{ inputs.platform }}.bundle \
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/start-runtime/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ runs:
- name: "Install Python dependencies"
run: pip install pyaml httplib2
shell: bash
- name: "Setup Java 11"
- name: "Setup Java 21"
id: setup-java
uses: actions/setup-java@v3.10.0
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "11"
java-version: "21"
- name: "Extract deployment package"
run: |
mkdir project
Expand Down
23 changes: 12 additions & 11 deletions .github/scripts/mxbuild.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ FROM mcr.microsoft.com/dotnet/runtime:8.0
ARG MENDIX_VERSION

RUN \
echo "Installing Java 17..." && \
echo "Installing Java 21..." && \
apt-get -qq update && \
apt-get -qq install -y wget libgdiplus && \
wget -q https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk.tar.gz && \
wget -q https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz -O /tmp/openjdk.tar.gz || { echo "Failed to download Java 21"; exit 1; } && \
mkdir -p /usr/lib/jvm && \
tar xfz /tmp/openjdk.tar.gz --directory /usr/lib/jvm && \
mv /usr/lib/jvm/jdk-17.0.2 /usr/lib/jvm/java-17-openjdk && \
rm /tmp/openjdk.tar.gz
tar xfz /tmp/openjdk.tar.gz --directory /usr/lib/jvm || { echo "Failed to extract Java 21"; exit 1; } && \
ls /usr/lib/jvm && \
mv /usr/lib/jvm/jdk-21* /usr/lib/jvm/java-21-openjdk && \
rm /tmp/openjdk.tar.gz

RUN \
echo "Downloading mxbuild ${MENDIX_VERSION}..." && \
wget -q https://cdn.mendix.com/runtime/mxbuild-${MENDIX_VERSION}.tar.gz -O /tmp/mxbuild.tar.gz && \
wget -q https://cdn.mendix.com/runtime/mxbuild-${MENDIX_VERSION}.tar.gz -O /tmp/mxbuild.tar.gz || { echo "Failed to download mxbuild"; exit 1; } && \
mkdir /tmp/mxbuild && \
tar xfz /tmp/mxbuild.tar.gz --directory /tmp/mxbuild && \
rm /tmp/mxbuild.tar.gz
tar xfz /tmp/mxbuild.tar.gz --directory /tmp/mxbuild || { echo "Failed to extract mxbuild"; exit 1; } && \
rm /tmp/mxbuild.tar.gz

RUN \
apt-get -qq remove -y wget && \
apt-get clean
apt-get clean

RUN \
echo "#!/bin/bash -x" >/bin/mxbuild && \
echo "dotnet /tmp/mxbuild/modeler/mxbuild.dll --java-home=/usr/lib/jvm/java-17-openjdk --java-exe-path=/usr/lib/jvm/java-17-openjdk/bin/java \$@" >>/bin/mxbuild && \
chmod +x /bin/mxbuild
echo "dotnet /tmp/mxbuild/modeler/mxbuild.dll --java-home=/usr/lib/jvm/java-21-openjdk --java-exe-path=/usr/lib/jvm/java-21-openjdk/bin/java \$@" >>/bin/mxbuild && \
chmod +x /bin/mxbuild

RUN \
echo "#!/bin/bash -x" >/bin/mx && \
Expand Down
181 changes: 110 additions & 71 deletions .github/workflows/NativePipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "scope=--since --include '*-native'" >> $GITHUB_OUTPUT
else
echo "scope=--all--include '*-native'" >> $GITHUB_OUTPUT
echo "scope=--all --include '*-native'" >> $GITHUB_OUTPUT
fi
fi

Expand Down Expand Up @@ -124,15 +124,14 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Check out code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: "Check if docker image already exists"
run: |
docker manifest inspect ghcr.io/mendix/native-widgets/mxbuild:${{ needs.mendix-version.outputs.mendix_version }} || EXIT_CODE=$?
echo "IMAGE_MISSING=$EXIT_CODE" >> $GITHUB_ENV
- name: "Check out code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
if: ${{ env.IMAGE_MISSING != 0 }}
- name: "Build mxbuild image"
if: ${{ env.IMAGE_MISSING != 0 }}
# if: ${{ env.IMAGE_MISSING != 0 }}
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
file: ./.github/scripts/mxbuild.Dockerfile
Expand Down Expand Up @@ -303,23 +302,32 @@ jobs:
- name: "Install dependencies"
working-directory: native-template
run: npm i
- name: "Setup JDK 17"
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
- name: "Setup JDK"
uses: actions/setup-java@v4
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a good security practice to pin the version at a specific commit. We also use a job that checks for this and it's failing so please use a specific commit instead of a version number (you can write specific version name in a comment next to it).

This applies to all actions, not just this one :)

with:
java-version: 17
java-version: 21
distribution: temurin
cache: gradle
- name: "Build Android app"
working-directory: native-template/android
run: ./gradlew assembleAppstoreDebug assembleAppstoreDebugAndroidTest
run: |
./gradlew assembleAppstoreDebug assembleAppstoreDebugAndroidTest
if [ $? -ne 0 ]; then
echo "Build failed!"
exit 1
fi
- name: "List APK files"
run: |
echo "Listing APK files in the output directory:"
ls -R native-template/android/app/build/outputs/apk/
- name: "Archive Android app"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: android-app
path: native-template/android/app/build/outputs/apk/**/*.apk
ios-app:
needs: [ios-bundle]
runs-on: macos-12
runs-on: macos-13
steps:
- name: "Check out Native Template for Native Components Test Project"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
Expand All @@ -342,6 +350,14 @@ jobs:
node-version-file: native-template/.nvmrc
cache: npm
cache-dependency-path: native-template/package-lock.json
- name: "Cache iOS Build"
uses: actions/cache@v3
with:
path: native-template/ios/build
key: ${{ runner.os }}-ios-build-${{ hashFiles('native-template/ios/**/*.swift', 'native-template/ios/**/*.h', 'native-template/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-ios-build-

- name: "Copy files to the right location"
run: |
mv bundles/ios/index.ios.bundle native-template/ios/Bundle/index.ios.bundle
Expand All @@ -353,7 +369,7 @@ jobs:
run: npm i

- name: "Setup Pods cache"
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # v2
uses: actions/cache@v3
with:
path: native-template/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
Expand All @@ -370,39 +386,10 @@ jobs:
with:
name: ios-app
path: native-template/ios/build/Build/Products/**/*.app
android-avd:
runs-on: macos-12
steps:
- name: "Check out code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- name: "Setup AVD cache"
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # v2
id: avd-cache
with:
path: |
/Users/runner/.android/avd/*
/Users/runner/.android/adb*
/Users/runner/Library/Android/sdk/system-images/**/*
key: pixel_30_x86_64_default_3core_and_system_images
- name: "Create AVD and generate snapshot for caching"
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # v2.30.1
with:
api-level: 30
target: default
arch: x86_64
profile: pixel
cores: 3
ram-size: 4096M
heap-size: 512M
avd-name: NATIVE_pixel_30
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "AVD created"

android-tests:
needs: [scope, mendix-version, project, android-app, android-avd]
runs-on: macos-12
needs: [scope, mendix-version, project, android-app]
runs-on: ubuntu-22.04
steps:
- name: "Check out code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
Expand All @@ -419,6 +406,8 @@ jobs:
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: mda
- name: "List contents of working directory before downloading Android app"
run: ls -R
- name: "Start runtime"
uses: ./.github/actions/start-runtime
with:
Expand All @@ -429,38 +418,42 @@ jobs:
with:
name: android-app
path: android-app
- name: "List contents of android-app directory after download"
run: ls -R android-app
- name: "Move android apps to correct location"
run: |
mkdir -p detox/apps
find android-app -type f -iname "*.apk" -exec mv {} detox/apps/ \;
- name: "Setup AVD cache"
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # v2
id: avd-cache
with:
path: |
/Users/runner/.android/avd/*
/Users/runner/.android/adb*
/Users/runner/Library/Android/sdk/system-images/**/*
key: pixel_30_x86_64_default_3core_and_system_images
- name: "Check if APK files are present"
run: |
echo "Listing APK files in detox/apps directory:"
ls -R detox/apps
- name: "Install jest globally"
run: npm install -g jest
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: "Run tests"
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # v2.30.1
uses: reactivecircus/android-emulator-runner@v2.32.0
with:
api-level: 30
target: default
api-level: 34
target: google_apis
arch: x86_64
profile: pixel
cores: 3
ram-size: 4096M
heap-size: 512M
avd-name: NATIVE_pixel_30
avd-name: NATIVE_pixel_34
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb shell "rm -fr /data/local/tmp/detox"
adb shell "mkdir -p /data/local/tmp/detox"
adb push "/Users/runner/work/native-widgets/native-widgets/detox/apps/app-appstore-debug.apk" "/data/local/tmp/detox/Application.apk"
adb push "/Users/runner/work/native-widgets/native-widgets/detox/apps/app-appstore-debug-androidTest.apk" "/data/local/tmp/detox/Test.apk"
adb push "detox/apps/app-appstore-debug.apk" "/data/local/tmp/detox/Application.apk"
adb push "detox/apps/app-appstore-debug-androidTest.apk" "/data/local/tmp/detox/Test.apk"
adb shell pm install -r -g -t /data/local/tmp/detox/Application.apk 2>/dev/null
adb shell pm install -r -g -t /data/local/tmp/detox/Test.apk 2>/dev/null
yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test:e2e:android
Expand Down Expand Up @@ -489,7 +482,7 @@ jobs:
if-no-files-found: ignore
ios-tests:
needs: [scope, mendix-version, project, ios-app]
runs-on: macos-12
runs-on: macos-13
steps:
- name: "Check out code"
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
Expand All @@ -506,13 +499,19 @@ jobs:
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: mda
# Used when new xCode version of simulator should be created

- name: Update Xcode
run: sudo xcode-select --switch /Applications/Xcode_14.0.1.app
run: sudo xcode-select --switch /Applications/Xcode_14.2.app

- name: "Clean detox framework cache"
run: npx detox clean-framework-cache
- name: "Build detox framework cache"
run: npx detox build-framework-cache
- name: Install Detox Dependencies
run: |
brew tap wix/brew
brew install applesimutils

- name: "Start runtime"
uses: ./.github/actions/start-runtime
with:
Expand All @@ -523,23 +522,63 @@ jobs:
with:
name: ios-app
path: ios-app

- name: "Move iOS app to correct location"
run: |
mkdir -p detox/apps
find ios-app -type d -iname "*.app" -exec cp -R {} detox/apps/ \;
- name: Install Detox Dependencies
- name: "List contents of apps directory"
run: |
brew tap wix/brew
brew install applesimutils
- name: Check available runtimes
run: xcrun simctl list runtimes
- name: Check avialble device types
run: xcrun simctl list devicetypes
# - name: Create iOS 16.0 simulator for iPhone 14
# run: xcrun simctl create "iPhone 14" com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-0
echo "Listing contents of detox/apps directory:"
ls -R detox/apps
- name: "Install jest globally"
run: npm install -g jest
# - name: Check available runtimes
# run: xcrun simctl list runtimes
# - name: Check available device types
# run: xcrun simctl list devicetypes
- name: Create iOS 16.2 simulator for iPhone 14
run: xcrun simctl create "iPhone 14" com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-16-2
- name: List supported iOS devices
run: applesimutils --list
# - name: Boot Simulator
# run: xcrun simctl boot "iPhone 15"
# - name: Wait for Simulator to Boot
# run: |
# while ! xcrun simctl list | grep "Booted"; do
# echo "Waiting for simulator to boot..."
# sleep 5
# done
# - name: "Check if simulator is booted"
# run: |
# if ! xcrun simctl list | grep -q "Booted"; then
# echo "Simulator is not booted!"
# exit 1
# # fi
# - name: "List installed apps"
# run: xcrun simctl listapps "iPhone 15"

# - name: "Wait for app to be ready"
# run: sleep 10

# - name: "Terminate app if running"
# run: |
# if xcrun simctl list apps | grep -q "com.mendix.native.template"; then
# xcrun simctl terminate "iPhone 15" com.mendix.native.template || echo "No app to terminate"
# fi
# - name: "Check if iOS app exists"
# run: |
# BINARY_PATH="/Users/runner/work/native-widgets/native-widgets/detox/apps/NativeTemplate.app"
# if [ ! -d "$BINARY_PATH" ]; then
# echo "App not found at path: $BINARY_PATH"
# echo "Listing contents of the apps directory:"
# ls -R /Users/runner/work/native-widgets/native-widgets/detox/apps # List contents of the apps directory for debugging
# else
# echo "App found at path: $BINARY_PATH"
# fi
- name: "Run tests"
env:
DETOX_LOGLEVEL: trace
run: yarn workspaces foreach ${{ needs.scope.outputs.scope }} run test:e2e:ios
- name: "Archive runtime logs"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
Expand All @@ -563,4 +602,4 @@ jobs:
with:
name: ios-artifacts
path: packages/pluggableWidgets/**/artifacts/
if-no-files-found: ignore
if-no-files-found: ignore
Loading
Loading