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

chore: setup maestro ci #716

Merged
merged 36 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a3b106b
chore: setup maestro test action
jaworek Apr 5, 2023
7b0b8ed
chore: test
jaworek Apr 5, 2023
0d66607
chore: test 2
jaworek Apr 5, 2023
6668b11
chore: add example test
jaworek Apr 5, 2023
c4b8164
chore: test 3
jaworek Apr 5, 2023
2d09ab0
chore: test 4
jaworek Apr 5, 2023
eff2436
fix: app id
jaworek Apr 5, 2023
6e8318a
chore: save apk build artifact
jaworek Apr 6, 2023
f189990
chore: update path
jaworek Apr 6, 2023
7c77afd
chore: update path
jaworek Apr 6, 2023
329dd31
chore: install apk on emulator
jaworek Apr 6, 2023
64f70b5
chore: remove incorrect value
jaworek Apr 6, 2023
f287349
chore: update path
jaworek Apr 6, 2023
ba2fb7c
chore: enable maestro tests
jaworek Apr 6, 2023
549f542
chore: add second test
jaworek Apr 6, 2023
9b618c9
chore: check if app is installed
jaworek Apr 6, 2023
6034ff7
chore: run maestro
jaworek Apr 6, 2023
2874e6f
chore: run single test
jaworek Apr 6, 2023
1be4310
chore: customise emulator options
jaworek Apr 7, 2023
7df6d40
chore: update config
jaworek Apr 7, 2023
026bd98
chore: update config
jaworek Apr 7, 2023
dbb505d
chore: update config
jaworek Apr 7, 2023
9a7155d
chore: use virtual display
jaworek Apr 7, 2023
1c1ec0f
chore: don't install emulator
jaworek Apr 7, 2023
25b6135
chore: disable virtual screen
jaworek Apr 12, 2023
be65d73
chore: change options
jaworek Apr 12, 2023
6c256fb
add maestro script
Apr 21, 2023
fe339ee
add yarn bootstrap no pods
Apr 21, 2023
a806660
bump node version
Apr 21, 2023
1177717
migrate example test
Apr 21, 2023
e0063a3
add ios test
Apr 21, 2023
219555f
fix ios bundle name
Apr 21, 2023
6e41214
merge two pipelines
May 12, 2023
411b62a
change executor
May 12, 2023
3a0365b
fix ios
May 12, 2023
5699716
remove unused file
May 12, 2023
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
21 changes: 3 additions & 18 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Install dependencies
description: "Installs and caches the dependencies"
description: 'Installs and caches the dependencies'

runs:
using: "composite"
using: 'composite'
steps:
- name: Install dependencies
shell: bash
Expand All @@ -28,18 +28,3 @@ runs:
shell: bash
run: yarn install --frozen-lockfile
working-directory: example

- name: Cache fabric example node modules
id: cache-fabricexample-npm
uses: actions/cache@v3
env:
cache-name: cached-fabric-npm-deps
with:
path: fabricexample/node_modules
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}

- name: Install required fabric example dependencies on yarn.lock change
if: steps.cache-fabricexample-npm.outputs.cache-hit != 'true'
shell: bash
run: yarn install --frozen-lockfile
working-directory: fabricexample
69 changes: 26 additions & 43 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ on:
- '.github/workflows/android.yml'
- 'android/**'
- 'example/android/**'
- 'fabricexample/android/**'
push:
branches:
- master


concurrency:
concurrency:
group: ${{ github.ref }}-android
cancel-in-progress: true

jobs:
android-build:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
Expand All @@ -42,51 +40,36 @@ jobs:

- name: Install required example dependencies on yarn.lock change
if: steps.cache-example-npm.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
working-directory: example
run: yarn bootstrap-no-pods --frozen-lockfile

- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"

- name: Build Android
run: ./gradlew assembleDebug
working-directory: example/android

android-build-fabric:
runs-on: ubuntu-latest
needs: android-build
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
distribution: 'zulu'
java-version: '11'

- name: Pull dependencies
- name: Gradle cache
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ hashFiles('./package.json') }}
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}

- name: Cache fabric example node modules
id: cache-fabricexample-npm
uses: actions/cache@v3
env:
cache-name: cached-fabric-npm-deps
with:
path: fabricexample/node_modules
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}

- name: Install required fabric example dependencies on yarn.lock change
if: steps.cache-fabricexample-npm.outputs.cache-hit != 'true'
shell: bash
run: yarn install --frozen-lockfile
working-directory: fabricexample
- name: Install Maestro CLI
run: export MAESTRO_VERSION=1.21.3; curl -Ls "https://get.maestro.mobile.dev" | bash

- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
- name: Add Maestro to path
run: echo "${HOME}/.maestro/bin" >> $GITHUB_PATH

- name: Build Android (Fabric)
run: ./gradlew assembleDebug -PreactNativeArchitectures=arm64-v8a
working-directory: fabricexample/android
- name: Run Android Emulator and app
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
target: google_apis
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
yarn run-example-android
yarn test:e2e:android
63 changes: 15 additions & 48 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ on:
- '.github/workflows/ios.yml'
- 'ios/**'
- 'example/ios/**'
- 'fabricexample/ios/**'
push:
branches:
push:
branches:
- master

concurrency:
Expand Down Expand Up @@ -57,51 +56,19 @@ jobs:
run: NO_FLIPPER=1 pod install
working-directory: example/ios

- name: Build iOS
run: xcodebuild -scheme PagerViewExample -workspace PagerViewExample.xcworkspace -sdk iphonesimulator -configuration Debug COMPILER_INDEX_STORE_ENABLE=NO
working-directory: example/ios

ios-build-fabric:
needs: ios-build
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-dependencies
- name: Install Maestro CLI
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
brew tap facebook/fb
brew install facebook/fb/idb-companion

- name: Pull dependencies
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ hashFiles('./package.json') }}
- name: Add Maestro to path
run: echo "${HOME}/.maestro/bin" >> $GITHUB_PATH

- name: Cache fabric example node modules
id: cache-fabricexample-npm
uses: actions/cache@v3
env:
cache-name: cached-fabric-npm-deps
with:
path: fabricexample/node_modules
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}

- name: Install required fabric example dependencies on yarn.lock change
if: steps.cache-fabricexample-npm.outputs.cache-hit != 'true'
shell: bash
run: yarn install --frozen-lockfile
working-directory: fabricexample

- name: Cache FabricExample Pods
id: cache-pods-fabric
uses: actions/cache@v3
env:
cache-name: cached-ios-pods-deps-fabric
with:
path: fabricexample/ios/Pods
key: ${{ hashFiles('./fabricexample/ios/Podfile.lock') }}

- name: Install FabricExample Pods
run: NO_FLIPPER=1 pod install
working-directory: fabricexample/ios
- name: Build iOS App
run: |
yarn run-example-ios

- name: Build iOS (Fabric)
run: xcodebuild -scheme FabricExample -workspace FabricExample.xcworkspace -sdk iphonesimulator -configuration Debug COMPILER_INDEX_STORE_ENABLE=NO
working-directory: fabricexample/ios
- name: Run tests
run: |
yarn test:e2e:ios
19 changes: 5 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ on:
branches:
- master

concurrency:
concurrency:
group: ${{ github.ref }}-js
cancel-in-progress: true

jobs:
install-dependencies:
install-dependencies:
name: Install dependencies
runs-on: ubuntu-latest
steps:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
- name: Install dependencies
uses: ./.github/actions/install-dependencies

verify-package-source:
Expand All @@ -45,20 +45,11 @@ jobs:
path: example/node_modules
key: ${{ hashFiles('./example/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}

- name: Pull fabric example node modules
id: cache-fabricexample-npm
uses: actions/cache@v3
env:
cache-name: cached-fabric-npm-deps
with:
path: fabricexample/node_modules
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}

- name: Lint files
run: yarn lint

- name: Typecheck files
run: yarn typescript

- name: Build package
run: yarn prepare
run: yarn prepare
8 changes: 4 additions & 4 deletions example/ios/PagerViewExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
"-lc++",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagerViewExample.app/PagerViewExample";
};
Expand All @@ -473,7 +473,7 @@
"-lc++",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagerViewExample.app/PagerViewExample";
};
Expand All @@ -497,7 +497,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
PRODUCT_NAME = PagerViewExample;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -522,7 +522,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
PRODUCT_NAME = PagerViewExample;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
20 changes: 20 additions & 0 deletions maestro-tests/basic_example/tc14_pager_basic_example.yaml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
appId: ${APP_ID}
---
- launchApp
- assertVisible: 'PagerView Example'
- tapOn: 'Basic Example'
- assertVisible: 'Basic Example'
- tapOn: 'Last'
- assertVisible: 'page number 9'
- assertVisible: 'Page 10 / 10 '
- assertVisible: 'Prev'
- tapOn: 'Prev'
- repeat:
times: 8
commands:
- tapOn: 'Prev'
- assertVisible: 'page number 0'
- assertVisible: 'Page 1 / 10 '
- tapOn: 'Prev'
- assertVisible: 'page number 0'
- assertVisible: 'Page 1 / 10 '
3 changes: 3 additions & 0 deletions maestro-tests/test2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appId: ${APP_ID}
---
- launchApp
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
"example": "yarn --cwd example",
"bootstrap": "yarn example && yarn && yarn example pods",
"fabricexample": "yarn --cwd fabricexample",
"bootstrap-fabric": "yarn fabricexample && yarn && yarn fabricexample pods"
"bootstrap-fabric": "yarn fabricexample && yarn && yarn fabricexample pods",
"bootstrap-no-pods": "yarn example && yarn",
"test:e2e:android": "bash ./scripts/run-maestro-tests.sh android",
"run-example-android": "cd example;react-native run-android --variant=release",
"run-example-ios": "cd example;react-native run-ios --configuration Release --simulator \"iPhone 13 (15.2)\"",
"test:e2e:ios": "bash ./scripts/run-maestro-tests.sh ios"
},
"keywords": [
"react-native",
Expand Down
52 changes: 52 additions & 0 deletions scripts/run-maestro-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

trap 'exit' INT

PLATFORM=${1:-}

# Validate passed platform
case $PLATFORM in
ios | android )
;;

*)
echo "Error! You must pass either 'android' or 'ios'"
echo ""
exit 1
;;
esac

if [ "$PLATFORM" == "ios" ]; then
APPID="com.pagerviewexample"
allTestFiles=$(ls maestro-tests/*.yaml maestro-tests/basic_example/*.yaml)
else
APPID="com.pagerviewexample"
allTestFiles=$(ls maestro-tests/*.yaml maestro-tests/basic_example/*.yaml)
fi

failedTests=()
for file in $allTestFiles
do
if ! maestro test "$file" -e APP_ID="$APPID";
then
echo "Test ${file} failed. Retrying in 30 seconds..."
sleep 30
if ! maestro test "$file" -e APP_ID="$APPID";
then
echo "Test ${file} failed again. Retrying for the last time in 120 seconds..."
sleep 120
if ! maestro test "$file" -e APP_ID="$APPID";
then
failedTests+=("$file")
fi
fi
fi
done

if [ ${#failedTests[@]} -eq 0 ]; then
exit 0
else
echo "These tests failed:"
printf '%s\n' "${failedTests[@]}"
exit 1
fi
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"skipLibCheck": true,
"strict": true,
"target": "esnext"
}
},
"exclude": ["fabricexample"]
}