Skip to content

Commit c95f3a9

Browse files
authored
chore: Setup example app(Android) to run react-native-owl on GitHub Actions (#39)
* chore: (Android) Config - add option to specify buildType * Setup android job * Remove missed iOS step * Add tmate step * Nicer output from gradlew command * Attempt to install the sdks, create & boot the emulator * Switch to ubuntu-18.04 * Valid workflow * Correct simulator name * Retry * Run on macos because of HAXM * Retry * Add step to become root in adb (required to set time in emulator) * Reorder so that emulator has time to boot * chore: Remove adb root * chore: Fix tests * chore: Debug devices * chore: Set emulator's disk size * chore: Adb wait for device * chore: Timeout with bash * chore: Use timeout_minutes * chore: clean up * Update demo-app.yml * chore: Specify Pixel 2 for the emulator * chore: Revert command arg * chore: Use "Nexus 5X" to match "Pixel 2"'s config * chore: Clean Up * chore: Use existing github action to handle emulator launch * chore: Fix systax * chore: Add architecture * chore: Store screenshots if tests fail * chore: Back to custom config * chore: Attempt to give more RAM for the emulator * chore: Move memory arg * Update demo-app.yml * chore: Attempt to use google imag * chore: More memory * chore: More storage * chore: Rollback changes * chore: Wipe data * chore: Add example workflow to docs * chore: Update copy in the docs
1 parent eb3017a commit c95f3a9

5 files changed

Lines changed: 223 additions & 91 deletions

File tree

.github/workflows/demo-app.yml

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: yarn install --frozen-lockfile
3737
working-directory: ./example
3838

39-
- name: Install CocoaPods
39+
- name: Install CocoaPods Gem
4040
run: gem install cocoapods -v 1.11.0
4141

4242
- uses: actions/cache@v2
@@ -46,7 +46,7 @@ jobs:
4646
restore-keys: |
4747
${{ runner.os }}-pods-
4848
49-
- name: Install CocoaPods
49+
- name: Install Pods
5050
run: pod install
5151
working-directory: ./example/ios
5252

@@ -69,3 +69,74 @@ jobs:
6969
with:
7070
name: owl-results
7171
path: example/.owl
72+
73+
run-visual-regression-android:
74+
runs-on: macos-11
75+
if: ${{ false }}
76+
77+
steps:
78+
- uses: actions/checkout@v2
79+
80+
- name: Get yarn cache directory path
81+
id: yarn-cache-dir-path
82+
run: echo "::set-output name=dir::$(yarn cache dir)"
83+
84+
- uses: actions/cache@v2
85+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
86+
with:
87+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
88+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
89+
restore-keys: |
90+
${{ runner.os }}-yarn-
91+
92+
- name: Install Dependencies (Library)
93+
run: yarn install --frozen-lockfile
94+
working-directory: ./
95+
96+
- name: Compile the library
97+
run: yarn build
98+
working-directory: ./
99+
100+
- name: Install Dependencies (Example App)
101+
run: yarn install --frozen-lockfile
102+
working-directory: ./example
103+
104+
- uses: actions/cache@v2
105+
with:
106+
path: |
107+
~/.gradle/caches
108+
~/.gradle/wrapper
109+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
110+
restore-keys: |
111+
${{ runner.os }}-gradle-
112+
113+
- name: SKDs - download required images
114+
run: $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-30;default;x86_64"
115+
116+
- name: SDKs - accept licenses
117+
run: y | $ANDROID_HOME/tools/bin/sdkmanager --licenses
118+
119+
- name: Emulator - Create
120+
run: $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M
121+
122+
- name: Emulator - Boot
123+
run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd Pixel_API_30 -wipe-data -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &
124+
125+
- name: ADB Wait For Device
126+
run: adb wait-for-any-device
127+
timeout-minutes: 3
128+
129+
- name: Run Owl Build
130+
run: yarn owl:build:android
131+
working-directory: ./example
132+
133+
- name: Run Owl Test
134+
run: yarn owl:test:android
135+
working-directory: ./example
136+
137+
- name: Store screenshots as artifacts
138+
uses: actions/upload-artifact@v2
139+
if: failure()
140+
with:
141+
name: owl-screenshots
142+
path: example/.owl

docs/advanced/_category_.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/advanced/running-ci.md

Lines changed: 0 additions & 85 deletions
This file was deleted.

docs/ci/_category_.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Running on CI",
3+
"position": 4
4+
}

docs/ci/github-actions.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# GitHub Actions
6+
7+
:::info
8+
9+
With visual regression testing, it is all about **consistency**. Please make sure that you use the same simulator across environments. Use the same emulator configuration to generate the baseline images and for running the test suite on CI so that the library can compare the screenshots. The library will not be able to compare different sizes and resolutions of screenshots.
10+
11+
:::
12+
13+
### iOS
14+
15+
To run the tests on an iOS simulator, you will need to use a [macOS based runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources).
16+
17+
```yaml title=".github/workflows/visual-regression-ios.yml"
18+
name: Visual Regression - iOS
19+
20+
on: [pull_request]
21+
22+
jobs:
23+
run-visual-regression-ios:
24+
runs-on: macos-11
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Get Runner Information
30+
run: /usr/bin/xcodebuild -version
31+
32+
- name: Get yarn cache directory path
33+
id: yarn-cache-dir-path
34+
run: echo "::set-output name=dir::$(yarn cache dir)"
35+
36+
- uses: actions/cache@v2
37+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
38+
with:
39+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
40+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
41+
restore-keys: |
42+
${{ runner.os }}-yarn-
43+
44+
- name: Install Dependencies
45+
run: yarn install --frozen-lockfile
46+
47+
- name: Install CocoaPods
48+
run: gem install cocoapods -v 1.11.0
49+
50+
- uses: actions/cache@v2
51+
with:
52+
path: ./ios/Pods
53+
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
54+
restore-keys: |
55+
${{ runner.os }}-pods-
56+
57+
- name: Install CocoaPods
58+
run: pod install
59+
working-directory: ./ios
60+
61+
- uses: futureware-tech/simulator-action@v1
62+
with:
63+
model: 'iPhone 13 Pro'
64+
os_version: '>=15.0'
65+
66+
- name: Run Owl Build
67+
run: yarn owl:build:ios
68+
69+
- name: Run Owl Test
70+
run: yarn owl:test:ios
71+
72+
- name: Store screenshots and report as artifacts
73+
uses: actions/upload-artifact@v2
74+
if: failure()
75+
with:
76+
name: owl-results
77+
path: ./.owl
78+
```
79+
80+
### Android
81+
82+
```yaml title=".github/workflows/visual-regression-android.yml"
83+
name: Visual Regression - Android
84+
85+
on: [pull_request]
86+
87+
jobs:
88+
run-visual-regression-android:
89+
runs-on: macos-11
90+
91+
steps:
92+
- uses: actions/checkout@v2
93+
94+
- name: Get yarn cache directory path
95+
id: yarn-cache-dir-path
96+
run: echo "::set-output name=dir::$(yarn cache dir)"
97+
98+
- uses: actions/cache@v2
99+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
100+
with:
101+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
102+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
103+
restore-keys: |
104+
${{ runner.os }}-yarn-
105+
106+
- name: Install Dependencies
107+
run: yarn install --frozen-lockfile
108+
109+
- uses: actions/cache@v2
110+
with:
111+
path: |
112+
~/.gradle/caches
113+
~/.gradle/wrapper
114+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
115+
restore-keys: |
116+
${{ runner.os }}-gradle-
117+
118+
- name: SKDs - download required images
119+
run: $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-30;default;x86_64"
120+
121+
- name: SDKs - accept licenses
122+
run: y | $ANDROID_HOME/tools/bin/sdkmanager --licenses
123+
124+
- name: Emulator - Create
125+
run: $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_30 --device 'Nexus 5X' --package "system-images;android-30;default;x86_64" --sdcard 512M
126+
127+
- name: Emulator - Boot
128+
run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd Pixel_API_30 -wipe-data -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &
129+
130+
- name: ADB Wait For Device
131+
run: adb wait-for-any-device
132+
timeout-minutes: 3
133+
134+
- name: Run Owl Build
135+
run: yarn owl:build:android
136+
137+
- name: Run Owl Test
138+
run: yarn owl:test:android
139+
140+
- name: Store screenshots as artifacts
141+
uses: actions/upload-artifact@v2
142+
if: failure()
143+
with:
144+
name: owl-screenshots
145+
path: ./.owl
146+
```

0 commit comments

Comments
 (0)