Skip to content

Commit e1dd3ef

Browse files
jaworekPiotr Trocki
andauthored
chore(ci): E2E setup (#716)
* chore: setup maestro test action * chore: test * chore: test 2 * chore: add example test * chore: test 3 * chore: test 4 * fix: app id * chore: save apk build artifact * chore: update path * chore: update path * chore: install apk on emulator * chore: remove incorrect value * chore: update path * chore: enable maestro tests * chore: add second test * chore: check if app is installed * chore: run maestro * chore: run single test * chore: customise emulator options * chore: update config * chore: update config * chore: update config * chore: use virtual display * chore: don't install emulator * chore: disable virtual screen * chore: change options * add maestro script * add yarn bootstrap no pods * bump node version * migrate example test * add ios test * fix ios bundle name * merge two pipelines * change executor * fix ios * remove unused file --------- Co-authored-by: Piotr Trocki <[email protected]>
1 parent 16173bd commit e1dd3ef

File tree

10 files changed

+136
-129
lines changed

10 files changed

+136
-129
lines changed
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Install dependencies
2-
description: "Installs and caches the dependencies"
3-
2+
description: 'Installs and caches the dependencies'
3+
44
runs:
5-
using: "composite"
5+
using: 'composite'
66
steps:
77
- name: Install dependencies
88
shell: bash
@@ -28,18 +28,3 @@ runs:
2828
shell: bash
2929
run: yarn install --frozen-lockfile
3030
working-directory: example
31-
32-
- name: Cache fabric example node modules
33-
id: cache-fabricexample-npm
34-
uses: actions/cache@v3
35-
env:
36-
cache-name: cached-fabric-npm-deps
37-
with:
38-
path: fabricexample/node_modules
39-
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}
40-
41-
- name: Install required fabric example dependencies on yarn.lock change
42-
if: steps.cache-fabricexample-npm.outputs.cache-hit != 'true'
43-
shell: bash
44-
run: yarn install --frozen-lockfile
45-
working-directory: fabricexample

.github/workflows/android.yml

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ on:
88
- '.github/workflows/android.yml'
99
- 'android/**'
1010
- 'example/android/**'
11-
- 'fabricexample/android/**'
1211
push:
1312
branches:
1413
- master
1514

16-
17-
concurrency:
15+
concurrency:
1816
group: ${{ github.ref }}-android
1917
cancel-in-progress: true
2018

2119
jobs:
2220
android-build:
23-
runs-on: ubuntu-latest
21+
runs-on: macos-latest
2422
steps:
2523
- uses: actions/checkout@v3
2624
- uses: ./.github/actions/install-dependencies
@@ -42,51 +40,36 @@ jobs:
4240

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

4845
- uses: actions/setup-java@v3
4946
with:
50-
distribution: "zulu"
51-
java-version: "11"
52-
53-
- name: Build Android
54-
run: ./gradlew assembleDebug
55-
working-directory: example/android
56-
57-
android-build-fabric:
58-
runs-on: ubuntu-latest
59-
needs: android-build
60-
steps:
61-
- uses: actions/checkout@v3
62-
- uses: ./.github/actions/install-dependencies
47+
distribution: 'zulu'
48+
java-version: '11'
6349

64-
- name: Pull dependencies
50+
- name: Gradle cache
6551
uses: actions/cache@v3
6652
with:
67-
path: ./node_modules
68-
key: ${{ hashFiles('./package.json') }}
53+
path: |
54+
~/.gradle/caches
55+
~/.gradle/wrapper
56+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
6957

70-
- name: Cache fabric example node modules
71-
id: cache-fabricexample-npm
72-
uses: actions/cache@v3
73-
env:
74-
cache-name: cached-fabric-npm-deps
75-
with:
76-
path: fabricexample/node_modules
77-
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}
78-
79-
- name: Install required fabric example dependencies on yarn.lock change
80-
if: steps.cache-fabricexample-npm.outputs.cache-hit != 'true'
81-
shell: bash
82-
run: yarn install --frozen-lockfile
83-
working-directory: fabricexample
58+
- name: Install Maestro CLI
59+
run: export MAESTRO_VERSION=1.21.3; curl -Ls "https://get.maestro.mobile.dev" | bash
8460

85-
- uses: actions/setup-java@v3
86-
with:
87-
distribution: "zulu"
88-
java-version: "11"
61+
- name: Add Maestro to path
62+
run: echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
8963

90-
- name: Build Android (Fabric)
91-
run: ./gradlew assembleDebug -PreactNativeArchitectures=arm64-v8a
92-
working-directory: fabricexample/android
64+
- name: Run Android Emulator and app
65+
uses: reactivecircus/android-emulator-runner@v2
66+
with:
67+
api-level: 29
68+
arch: x86_64
69+
target: google_apis
70+
force-avd-creation: false
71+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
72+
disable-animations: true
73+
script: |
74+
yarn run-example-android
75+
yarn test:e2e:android

.github/workflows/ios.yml

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ on:
88
- '.github/workflows/ios.yml'
99
- 'ios/**'
1010
- 'example/ios/**'
11-
- 'fabricexample/ios/**'
12-
push:
13-
branches:
11+
push:
12+
branches:
1413
- master
1514

1615
concurrency:
@@ -57,51 +56,19 @@ jobs:
5756
run: NO_FLIPPER=1 pod install
5857
working-directory: example/ios
5958

60-
- name: Build iOS
61-
run: xcodebuild -scheme PagerViewExample -workspace PagerViewExample.xcworkspace -sdk iphonesimulator -configuration Debug COMPILER_INDEX_STORE_ENABLE=NO
62-
working-directory: example/ios
63-
64-
ios-build-fabric:
65-
needs: ios-build
66-
runs-on: macos-latest
67-
steps:
68-
- uses: actions/checkout@v3
69-
- uses: ./.github/actions/install-dependencies
59+
- name: Install Maestro CLI
60+
run: |
61+
curl -Ls "https://get.maestro.mobile.dev" | bash
62+
brew tap facebook/fb
63+
brew install facebook/fb/idb-companion
7064
71-
- name: Pull dependencies
72-
uses: actions/cache@v3
73-
with:
74-
path: ./node_modules
75-
key: ${{ hashFiles('./package.json') }}
65+
- name: Add Maestro to path
66+
run: echo "${HOME}/.maestro/bin" >> $GITHUB_PATH
7667

77-
- name: Cache fabric example node modules
78-
id: cache-fabricexample-npm
79-
uses: actions/cache@v3
80-
env:
81-
cache-name: cached-fabric-npm-deps
82-
with:
83-
path: fabricexample/node_modules
84-
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}
85-
86-
- name: Install required fabric example dependencies on yarn.lock change
87-
if: steps.cache-fabricexample-npm.outputs.cache-hit != 'true'
88-
shell: bash
89-
run: yarn install --frozen-lockfile
90-
working-directory: fabricexample
91-
92-
- name: Cache FabricExample Pods
93-
id: cache-pods-fabric
94-
uses: actions/cache@v3
95-
env:
96-
cache-name: cached-ios-pods-deps-fabric
97-
with:
98-
path: fabricexample/ios/Pods
99-
key: ${{ hashFiles('./fabricexample/ios/Podfile.lock') }}
100-
101-
- name: Install FabricExample Pods
102-
run: NO_FLIPPER=1 pod install
103-
working-directory: fabricexample/ios
68+
- name: Build iOS App
69+
run: |
70+
yarn run-example-ios
10471
105-
- name: Build iOS (Fabric)
106-
run: xcodebuild -scheme FabricExample -workspace FabricExample.xcworkspace -sdk iphonesimulator -configuration Debug COMPILER_INDEX_STORE_ENABLE=NO
107-
working-directory: fabricexample/ios
72+
- name: Run tests
73+
run: |
74+
yarn test:e2e:ios

.github/workflows/main.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ on:
88
branches:
99
- master
1010

11-
concurrency:
11+
concurrency:
1212
group: ${{ github.ref }}-js
1313
cancel-in-progress: true
1414

1515
jobs:
16-
install-dependencies:
16+
install-dependencies:
1717
name: Install dependencies
1818
runs-on: ubuntu-latest
19-
steps:
19+
steps:
2020
- name: Checkout repository
2121
uses: actions/checkout@v3
22-
- name: Install dependencies
22+
- name: Install dependencies
2323
uses: ./.github/actions/install-dependencies
2424

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

48-
- name: Pull fabric example node modules
49-
id: cache-fabricexample-npm
50-
uses: actions/cache@v3
51-
env:
52-
cache-name: cached-fabric-npm-deps
53-
with:
54-
path: fabricexample/node_modules
55-
key: ${{ hashFiles('./fabricexample/yarn.lock') }}-${{ hashFiles('./yarn.lock') }}
56-
5748
- name: Lint files
5849
run: yarn lint
5950

6051
- name: Typecheck files
6152
run: yarn typescript
6253

6354
- name: Build package
64-
run: yarn prepare
55+
run: yarn prepare

example/ios/PagerViewExample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@
449449
"-lc++",
450450
"$(inherited)",
451451
);
452-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
452+
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
453453
PRODUCT_NAME = "$(TARGET_NAME)";
454454
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagerViewExample.app/PagerViewExample";
455455
};
@@ -473,7 +473,7 @@
473473
"-lc++",
474474
"$(inherited)",
475475
);
476-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
476+
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
477477
PRODUCT_NAME = "$(TARGET_NAME)";
478478
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagerViewExample.app/PagerViewExample";
479479
};
@@ -497,7 +497,7 @@
497497
"-ObjC",
498498
"-lc++",
499499
);
500-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
500+
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
501501
PRODUCT_NAME = PagerViewExample;
502502
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
503503
SWIFT_VERSION = 5.0;
@@ -522,7 +522,7 @@
522522
"-ObjC",
523523
"-lc++",
524524
);
525-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
525+
PRODUCT_BUNDLE_IDENTIFIER = com.pagerviewexample;
526526
PRODUCT_NAME = PagerViewExample;
527527
SWIFT_VERSION = 5.0;
528528
VERSIONING_SYSTEM = "apple-generic";
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
appId: ${APP_ID}
2+
---
3+
- launchApp
4+
- assertVisible: 'PagerView Example'
5+
- tapOn: 'Basic Example'
6+
- assertVisible: 'Basic Example'
7+
- tapOn: 'Last'
8+
- assertVisible: 'page number 9'
9+
- assertVisible: 'Page 10 / 10 '
10+
- assertVisible: 'Prev'
11+
- tapOn: 'Prev'
12+
- repeat:
13+
times: 8
14+
commands:
15+
- tapOn: 'Prev'
16+
- assertVisible: 'page number 0'
17+
- assertVisible: 'Page 1 / 10 '
18+
- tapOn: 'Prev'
19+
- assertVisible: 'page number 0'
20+
- assertVisible: 'Page 1 / 10 '

maestro-tests/test2.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
appId: ${APP_ID}
2+
---
3+
- launchApp

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
"example": "yarn --cwd example",
3232
"bootstrap": "yarn example && yarn && yarn example pods",
3333
"fabricexample": "yarn --cwd fabricexample",
34-
"bootstrap-fabric": "yarn fabricexample && yarn && yarn fabricexample pods"
34+
"bootstrap-fabric": "yarn fabricexample && yarn && yarn fabricexample pods",
35+
"bootstrap-no-pods": "yarn example && yarn",
36+
"test:e2e:android": "bash ./scripts/run-maestro-tests.sh android",
37+
"run-example-android": "cd example;react-native run-android --variant=release",
38+
"run-example-ios": "cd example;react-native run-ios --configuration Release --simulator \"iPhone 13 (15.2)\"",
39+
"test:e2e:ios": "bash ./scripts/run-maestro-tests.sh ios"
3540
},
3641
"keywords": [
3742
"react-native",

scripts/run-maestro-tests.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
trap 'exit' INT
4+
5+
PLATFORM=${1:-}
6+
7+
# Validate passed platform
8+
case $PLATFORM in
9+
ios | android )
10+
;;
11+
12+
*)
13+
echo "Error! You must pass either 'android' or 'ios'"
14+
echo ""
15+
exit 1
16+
;;
17+
esac
18+
19+
if [ "$PLATFORM" == "ios" ]; then
20+
APPID="com.pagerviewexample"
21+
allTestFiles=$(ls maestro-tests/*.yaml maestro-tests/basic_example/*.yaml)
22+
else
23+
APPID="com.pagerviewexample"
24+
allTestFiles=$(ls maestro-tests/*.yaml maestro-tests/basic_example/*.yaml)
25+
fi
26+
27+
failedTests=()
28+
for file in $allTestFiles
29+
do
30+
if ! maestro test "$file" -e APP_ID="$APPID";
31+
then
32+
echo "Test ${file} failed. Retrying in 30 seconds..."
33+
sleep 30
34+
if ! maestro test "$file" -e APP_ID="$APPID";
35+
then
36+
echo "Test ${file} failed again. Retrying for the last time in 120 seconds..."
37+
sleep 120
38+
if ! maestro test "$file" -e APP_ID="$APPID";
39+
then
40+
failedTests+=("$file")
41+
fi
42+
fi
43+
fi
44+
done
45+
46+
if [ ${#failedTests[@]} -eq 0 ]; then
47+
exit 0
48+
else
49+
echo "These tests failed:"
50+
printf '%s\n' "${failedTests[@]}"
51+
exit 1
52+
fi

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
"skipLibCheck": true,
2525
"strict": true,
2626
"target": "esnext"
27-
}
27+
},
28+
"exclude": ["fabricexample"]
2829
}

0 commit comments

Comments
 (0)