Skip to content

Commit 89a454e

Browse files
committed
chore: implement iOS testing on BrowserStack
1 parent 73f37d6 commit 89a454e

File tree

2 files changed

+66
-16
lines changed

2 files changed

+66
-16
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010

1111
env:
1212
nodejs: "16.x"
13+
java_version: "17"
14+
gradle_version: "7.6.1"
1315
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
1416
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
1517

@@ -31,6 +33,8 @@ jobs:
3133

3234
build-ios:
3335
runs-on: macOS-latest
36+
outputs:
37+
run-tests: ${{ steps.should-run-tests.outputs.run_tests }}
3438
steps:
3539
- uses: actions/checkout@v1
3640
- name: Install Node.js ${{ env.nodejs }}
@@ -39,23 +43,44 @@ jobs:
3943
node-version: ${{ env.nodejs }}
4044
cache: npm
4145
cache-dependency-path: package-lock.json
46+
- id: should-run-tests
47+
run: |
48+
if [ -n "${BROWSERSTACK_USERNAME}" ]; then
49+
echo "run_tests=true" >> "$GITHUB_OUTPUT"
50+
else
51+
echo "run_tests=false" >> "$GITHUB_OUTPUT"
52+
fi
4253
- name: Install node modules
4354
run: npm ci
4455
- name: Update test cert for httpbin.org
4556
run: npm run update:cert
46-
# need to find a solution for signing iOS App so we can build for device target instead simulator
4757
- name: Build test app
48-
run: scripts/build-test-app.sh --ios --emulator
58+
run: scripts/build-test-app.sh --ios --device
4959
- name: Upload artifact to BrowserStack
50-
if: env.BROWSERSTACK_USERNAME != ''
60+
if: steps.should-run-tests.outputs.run_tests == 'true'
5161
run: scripts/upload-browserstack.sh --ios
52-
# need to have an App for device target
53-
# - name: Run e2e tests
54-
# if: env.BROWSERSTACK_USERNAME != ''
55-
# run: scripts/test-app.sh --ios --device
62+
63+
test-ios:
64+
needs: build-ios
65+
if: needs.build-ios.outputs.run-tests == 'true'
66+
runs-on: macOS-latest
67+
steps:
68+
- uses: actions/checkout@v1
69+
- name: Install Node.js ${{ env.nodejs }}
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: ${{ env.nodejs }}
73+
cache: npm
74+
cache-dependency-path: package-lock.json
75+
- name: Install node modules
76+
run: npm ci
77+
- name: Run e2e tests (iOS)
78+
run: scripts/test-app.sh --ios --device
5679

5780
build-android:
5881
runs-on: ubuntu-latest
82+
outputs:
83+
run-tests: ${{ steps.should-run-tests.outputs.run_tests }}
5984
steps:
6085
- uses: actions/checkout@v1
6186
- name: Install Node.js ${{ env.nodejs }}
@@ -64,23 +89,29 @@ jobs:
6489
node-version: ${{ env.nodejs }}
6590
cache: npm
6691
cache-dependency-path: package-lock.json
92+
- id: should-run-tests
93+
run: |
94+
if [ -n "${BROWSERSTACK_USERNAME}" ]; then
95+
echo "run_tests=true" >> "$GITHUB_OUTPUT"
96+
else
97+
echo "run_tests=false" >> "$GITHUB_OUTPUT"
98+
fi
6799
- name: Install node modules
68100
run: npm ci
69101
- name: Install JDK
70102
uses: actions/setup-java@v2
71103
with:
72104
distribution: "zulu"
73-
java-version: "17"
105+
java-version: ${{ env.java_version }}
74106
java-package: jdk
75107
- name: Ensure Android build-tools 33.0.2
76108
run: yes | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" "build-tools;33.0.2"
77-
- name: Install Gradle 7.6.1
109+
- name: Install Gradle ${{ env.gradle_version }}
78110
run: |
79111
set -euo pipefail
80-
GRADLE_VERSION=7.6.1
81-
curl -sSL "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" -o gradle.zip
112+
curl -sSL "https://services.gradle.org/distributions/gradle-${{ env.gradle_version }}-bin.zip" -o gradle.zip
82113
unzip -q gradle.zip -d "$HOME/gradle"
83-
echo "$HOME/gradle/gradle-${GRADLE_VERSION}/bin" >> "$GITHUB_PATH"
114+
echo "$HOME/gradle/gradle-${{ env.gradle_version }}/bin" >> "$GITHUB_PATH"
84115
rm gradle.zip
85116
- name: Update test cert for httpbin.org
86117
run: npm run update:cert
@@ -101,8 +132,22 @@ jobs:
101132
- name: Build test app
102133
run: scripts/build-test-app.sh --android --device
103134
- name: Upload artifact to BrowserStack
104-
if: env.BROWSERSTACK_USERNAME != ''
135+
if: steps.should-run-tests.outputs.run_tests == 'true'
105136
run: scripts/upload-browserstack.sh --android
106-
- name: Run e2e tests
107-
if: env.BROWSERSTACK_USERNAME != ''
137+
138+
test-android:
139+
needs: build-android
140+
if: needs.build-android.outputs.run-tests == 'true'
141+
runs-on: ubuntu-latest
142+
steps:
143+
- uses: actions/checkout@v1
144+
- name: Install Node.js ${{ env.nodejs }}
145+
uses: actions/setup-node@v4
146+
with:
147+
node-version: ${{ env.nodejs }}
148+
cache: npm
149+
cache-dependency-path: package-lock.json
150+
- name: Install node modules
151+
run: npm ci
152+
- name: Run e2e tests (Android)
108153
run: scripts/test-app.sh --android --device

scripts/build-test-app.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ rsync -ax --exclude node_modules --exclude scripts --exclude temp --exclude test
4444
cd $ROOT/temp
4545
$CDV prepare
4646
$CDV plugins add $WORKINGCOPY
47-
$CDV build $PLATFORM --$TARGET --buildConfig build.json
47+
if [ "$PLATFORM" = "ios" ] && [ "$TARGET" = "device" ]; then
48+
IOS_DEVICE_ARGS="CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO"
49+
$CDV build ios --device --buildConfig build.json -- $IOS_DEVICE_ARGS
50+
else
51+
$CDV build $PLATFORM --$TARGET --buildConfig build.json
52+
fi

0 commit comments

Comments
 (0)