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