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