-
-
Notifications
You must be signed in to change notification settings - Fork 2
214 lines (188 loc) · 7.08 KB
/
unprivilegedBuild.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# MIT License
#
# Copyright (c) 2021 - 2022 ViliusSutkus89.com
#
# https://github.com/ViliusSutkus89/Sample_Android_Library-MavenCentral-Instrumented_Tests
# .github/workflows/unprivilegedBuild.yml - v2.2.0
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: unprivilegedBuild
on:
workflow_dispatch:
push:
branches-ignore: [ master, main ]
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/unprivilegedBuild.yml'
pull_request:
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/unprivilegedBuild.yml'
permissions:
actions: none
checks: none
contents: none
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
jobs:
buildLibrary:
if: "!contains(github.event.head_commit.message, '[SkipCI]') && !contains(github.event.head_commit.message, '[AppOnly]')"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- uses: android-actions/setup-android@v2
- run: ./gradlew publishToMavenLocal lintRelease
- uses: actions/upload-artifact@v3
with:
name: library-lint-report
path: lib/build/reports/lint-results-release.html
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: maven-local
path: ~/.m2
if-no-files-found: error
runInstrumentedTests:
needs: buildLibrary
# Only macos VMs are available with exposed CPU extensions to run hardware accelerated emulator
runs-on: macos-11
strategy:
fail-fast: false
matrix:
include:
# Oldest API supported by NDK
- arch: x86
api-level: 16
api-type-target: default
# Oldest x86_64 image
- arch: x86_64
api-level: 21
api-type-target: default
# Latest x86 image
- arch: x86
api-level: 30
api-type-target: google_apis
# Latest image
- arch: x86_64
api-level: 32
api-type-target: google_apis
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- uses: android-actions/setup-android@v2
- uses: actions/download-artifact@v3
with:
name: maven-local
path: ~/.m2
- name: Prepare library to run instrumented tests on staging library
run: ./ci-scripts/prepareLibraryTestsForStagingRepository lib --output=build/lib-staging --repository=mavenLocal
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch }}
target: ${{ matrix.api-type-target }}
sdcard-path-or-size: 1G
disk-size: 8G
working-directory: build/lib-staging
script: |
mkdir -p testResults/screenshots
adb logcat > testResults/logcat.txt &
adb shell screencap /data/local/tmp/beforeTests.png
adb pull /data/local/tmp/beforeTests.png testResults/screenshots/
./gradlew connectedCheck || touch sorry_but_tests_are_failing
adb pull /sdcard/Pictures/screenshots testResults/ || true
adb shell screencap /data/local/tmp/afterTests.png
adb pull /data/local/tmp/afterTests.png testResults/screenshots/
mv lib/build/reports/androidTests/connected testResults/
mv lib/build/outputs/androidTest-results testResults/
test ! -f sorry_but_tests_are_failing
- uses: actions/upload-artifact@v3
if: always()
with:
name: testResults-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.api-type-target }}
path: build/lib-staging/testResults
if-no-files-found: error
buildSampleAppAgainstUnreleasedLibrary:
needs: buildLibrary
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- uses: android-actions/setup-android@v2
- uses: actions/download-artifact@v3
with:
name: maven-local
path: ~/.m2
- name: Prepare sample app for staging repository
run: ./ci-scripts/prepareSampleAppForStagingRepository sampleapp app --output=build/sampleapp-staging --repository=mavenLocal
- name: Build and lint sample app from staging library
run: ./gradlew build lintRelease
working-directory: build/sampleapp-staging
- uses: actions/upload-artifact@v3
with:
name: APKs
path: build/sampleapp-staging/app/build/outputs/apk/**/*.apk
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: sampleapp-lint-report
path: build/sampleapp-staging/app/build/reports/lint-results-release.html
if-no-files-found: error
buildSampleAppAgainstReleasedLibrary:
if: "!contains(github.event.head_commit.message, '[SkipCI]') && contains(github.event.head_commit.message, '[AppOnly]')"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- uses: android-actions/setup-android@v2
- run: ./gradlew build lintRelease
working-directory: sampleapp
- uses: actions/upload-artifact@v3
with:
name: APKs
path: sampleapp/app/build/outputs/apk/**/*.apk
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: sampleapp-lint-report
path: mv sampleapp/app/build/reports/lint-results-release.html
if-no-files-found: error