Skip to content

Commit 871eec1

Browse files
committed
ci: gh workflows for native ci
1 parent d1758e5 commit 871eec1

File tree

4 files changed

+248
-101
lines changed

4 files changed

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