Skip to content

Commit 86f7bdd

Browse files
committed
ci: gh workflows for native ci
1 parent d1758e5 commit 86f7bdd

File tree

4 files changed

+254
-101
lines changed

4 files changed

+254
-101
lines changed

.github/workflows/build-apk.yml

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

.github/workflows/ci.yml

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

.github/workflows/native-ci.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
name: Native Build and Test
2+
on:
3+
pull_request:
4+
types: [opened, reopened ]
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
install-dep:
10+
runs-on: macos-latest
11+
name: Install dependencies
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Ruby
15+
uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: 2.7
18+
bundler-cache: true
19+
- name: Setup node 16
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '16'
23+
24+
- uses: actions/cache@v2
25+
name: Cache outter node_modules
26+
id: cache-outter-node-modules
27+
with:
28+
path: node_modules
29+
key: ${{ runner.os }}-outterNodeModules-${{ hashFiles('package.json') }}
30+
restore-keys: |
31+
${{ runner.os }}-outterNodeModules-
32+
33+
- name: Install Outter dependencies
34+
if: steps.cache-outter-node-modules.outputs.cache-hit != 'true'
35+
run: |
36+
ls
37+
pwd
38+
echo ${{ github.workspace }}
39+
npm install
40+
41+
- uses: actions/cache@v2
42+
name: Cache node_modules
43+
id: cache-node-modules
44+
with:
45+
path: example/node_modules
46+
key: ${{ runner.os }}-nodeModules-${{ hashFiles('example/package.json') }}
47+
restore-keys: |
48+
${{ runner.os }}-nodeModules-
49+
50+
- name: Install dependencies
51+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
52+
run: |
53+
ls
54+
pwd
55+
echo ${{ github.workspace }}
56+
cd example
57+
npm install
58+
59+
android-build:
60+
runs-on: macos-latest
61+
name: Android Build
62+
needs: install-dep
63+
steps:
64+
- name: Set up JDK
65+
uses: actions/setup-java@v3
66+
with:
67+
distribution: 'zulu'
68+
java-version: 11
69+
70+
- uses: actions/cache@v2
71+
id: cache-gradle
72+
name: Cache Gradle dependencies
73+
with:
74+
path: |
75+
~/.gradle/caches
76+
~/.gradle/wrapper
77+
key: ${{ runner.os }}-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('android/src/**/*.kt') }}
78+
restore-keys: |
79+
${{ runner.os }}-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}-
80+
81+
- name: Install Gradle dependencies
82+
if: steps.cache-gradle.outputs.cache-hit != 'true'
83+
run: |
84+
ls
85+
pwd
86+
echo ${{ github.workspace }}
87+
cd example/android
88+
./gradlew build --stacktrace
89+
90+
- name: Run unit tests
91+
run: |
92+
cd example/android
93+
./gradlew test --stacktrace
94+
95+
- name: Build APK
96+
run: |
97+
npm run prepack
98+
cd example/android
99+
./gradlew assembleRelease
100+
mv app/build/outputs/apk/release/app-release.apk app-release-${{ github.sha }}.apk
101+
ls
102+
pwd
103+
echo ${{ github.workspace }}
104+
105+
- name: Upload APK
106+
uses: actions/upload-artifact@v3
107+
with:
108+
name: app-release-${{ github.sha }}.apk
109+
path: ${{ github.workspace }}/example/android/app-release-${{ github.sha }}.apk
110+
111+
android-test:
112+
runs-on: macos-latest
113+
needs: android-build
114+
strategy:
115+
matrix:
116+
api-level: [24, 25, 29, 30, 31]
117+
target: [default]
118+
119+
steps:
120+
- name: Checkout the code
121+
uses: actions/checkout@v4
122+
123+
- name: Setup node 16
124+
uses: actions/setup-node@v3
125+
with:
126+
node-version: '16'
127+
128+
- uses: actions/cache@v3
129+
name: Cache node_modules
130+
with:
131+
path: ${{ github.workspace }}/example/node_modules
132+
key: ${{ runner.os }}-nodeModules-${{ hashFiles('example/package.json') }}
133+
restore-keys: |
134+
${{ runner.os }}-nodeModules-
135+
136+
- uses: actions/cache@v3
137+
name: Cache outter node_modules
138+
with:
139+
path: node_modules
140+
key: ${{ runner.os }}-outterNodeModules-${{ hashFiles('package.json') }}
141+
restore-keys: |
142+
${{ runner.os }}-outterNodeModules-
143+
144+
- uses: actions/cache@v3
145+
name: Cache Gradle dependencies
146+
with:
147+
path: |
148+
~/.gradle/caches
149+
~/.gradle/wrapper
150+
key: ${{ runner.os }}-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('android/src/**/*.kt') }}
151+
restore-keys: |
152+
${{ runner.os }}-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}-
153+
154+
- name: Set up JDK
155+
uses: actions/setup-java@v3
156+
with:
157+
distribution: 'zulu'
158+
java-version: 11
159+
160+
- name: Instrumentation Tests
161+
uses: reactivecircus/android-emulator-runner@v2
162+
with:
163+
api-level: ${{ matrix.api-level }}
164+
target: ${{ matrix.target }}
165+
arch: x86_64
166+
profile: Nexus 6
167+
script: |
168+
ls
169+
pwd
170+
echo ${{ github.workspace }}
171+
cd example/android
172+
adb logcat -c # clear logs
173+
touch app/emulator.log # create log file
174+
chmod 777 app/emulator.log # allow writing to log file
175+
adb logcat >> app/emulator.log & # pipe all logcat messages into log file as a background process
176+
./gradlew connectedCheck --stacktrace # here run your tests
177+
178+
- name: Upload Reports
179+
uses: actions/upload-artifact@v2
180+
with:
181+
name: Test-Reports
182+
path: ${{ github.workspace }}/example/android/app/build/reports
183+
if: always()
184+
185+
ios-build-test:
186+
runs-on: macos-latest
187+
needs: install-dep
188+
strategy:
189+
matrix:
190+
cocoapods: ['1.10.1', '1.11.0', '1.14.3']
191+
steps:
192+
- uses: actions/checkout@v4
193+
- name: Set up Ruby
194+
uses: ruby/setup-ruby@v1
195+
with:
196+
ruby-version: 2.7
197+
bundler-cache: true
198+
- name: Install Cocoapods
199+
run: gem install cocoapods -v ${{ matrix.cocoapods }}
200+
- name: Setup node 16
201+
uses: actions/setup-node@v3
202+
with:
203+
node-version: '16'
204+
205+
- uses: actions/cache@v3
206+
name: Cache node_modules
207+
with:
208+
path: ${{ github.workspace }}/example/node_modules
209+
key: ${{ runner.os }}-nodeModules-${{ hashFiles('example/package.json') }}
210+
restore-keys: |
211+
${{ runner.os }}-nodeModules-
212+
- uses: actions/cache@v3
213+
name: Cache outter node_modules
214+
with:
215+
path: node_modules
216+
key: ${{ runner.os }}-outterNodeModules-${{ hashFiles('package.json') }}
217+
restore-keys: |
218+
${{ runner.os }}-outterNodeModules-
219+
220+
- name: Cache Pods
221+
id: cache-pods
222+
uses: actions/cache@v3
223+
with:
224+
path: ${{ github.workspace }}/example/ios/Pods
225+
key: ${{ runner.os }}-pods-${{ matrix.cocoapods }}-${{ hashFiles('**/Podfile.lock') }}
226+
restore-keys: |
227+
${{ runner.os }}-pods-${{ matrix.cocoapods }}-
228+
229+
- name: Install Pods
230+
if: steps.cache-pods.outputs.cache-hit != 'true'
231+
run: |
232+
ls
233+
pwd
234+
echo ${{ github.workspace }}
235+
cd example/ios
236+
pod cache clean --all
237+
pod install
238+
239+
- name: Install xcpretty
240+
run: gem install xcpretty
241+
242+
- name: Build
243+
run: |
244+
cd ${{ github.workspace }}/example/ios
245+
xcodebuild -workspace ImageMarkerExample.xcworkspace -scheme ImageMarkerExample -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12' | xcpretty
246+
- name: Test
247+
run: |
248+
cd ${{ github.workspace }}/example/ios
249+
xcodebuild -workspace ImageMarkerExample.xcworkspace -scheme ImageMarkerExample -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12' test | xcpretty

example/android/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ buildscript {
1313
repositories {
1414
google()
1515
mavenCentral()
16+
jcenter()
17+
maven { url 'https://dl.google.com/dl/android/maven2' }
18+
maven { url "https://repository.jboss.org/maven2" }
19+
maven { url 'https://maven.google.com' }
20+
maven { url 'https://maven.fabric.io/public' }
1621
}
1722
dependencies {
1823
classpath('com.android.tools.build:gradle:7.4.2')

0 commit comments

Comments
 (0)