-
Notifications
You must be signed in to change notification settings - Fork 36
194 lines (165 loc) · 5.9 KB
/
android_main.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
name: OpenDocument-Reader-Android
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/android_main.yml'
branches:
- main
pull_request:
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/android_main.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: install ninja
run: sudo apt-get install -y ninja-build
- name: setup java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- name: setup python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: install pip and conan
run: python -m pip install --upgrade pip conan
- name: conan remote
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan
- name: conan login
run: conan user --remote odr --password ${{ secrets.ARTIFACTORY }} admin
- name: tweak conan profile for build machine
run: |
echo "" >> conanprofile_build.txt
echo "[settings]" >> conanprofile_build.txt
echo "compiler=clang" >> conanprofile_build.txt
echo "compiler.libcxx=libstdc++11" >> conanprofile_build.txt
echo "" >> conanprofile_build.txt
- name: gradle
run: ./gradlew assembleDebug lintProDebug lintLiteDebug --stacktrace
- name: upload binaries to conan repo
run: conan upload "*" --remote odr --confirm --all --no-overwrite all
- name: upload apks
uses: actions/upload-artifact@v3
with:
name: APKs
path: app/build/outputs/apk/**/*.apk
if-no-files-found: error
- name: upload lint results
uses: actions/upload-artifact@v3
with:
name: lint-report
path: app/build/reports/lint-results-*.html
if-no-files-found: error
test:
runs-on: macos-11
strategy:
fail-fast: false
# Make sure the matrix here and in cache_AVD_images.yml is the same
matrix:
include:
# Oldest x86_64
- arch: x86_64
api-level: 23
- arch: x86_64
api-level: 29
# API-30+ tests are failing because play services init something something
- arch: x86
api-level: 30
# API-32+ tests are failing because storage permissions something something
- arch: x86_64
api-level: 32
steps:
- name: checkout
uses: actions/checkout@v3
- name: java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- name: install brew
run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
- name: fix ninja install
run: rm '/usr/local/bin/2to3'
- name: install ninja
run: brew install ninja
# https://stackoverflow.com/a/57758679/198996
- name: install bundler
run: gem install bundler:1.17.3
- name: install fastlane
run: bundle install
- name: install pip
run: python3 -m ensurepip
- name: install conan
run: pip3 install --upgrade conan
- name: conan remote
run: conan remote add --index 0 odr https://artifactory.opendocument.app/artifactory/api/conan/conan
- name: conan login
run: conan user --remote odr --password ${{ secrets.ARTIFACTORY }} admin
- name: tweak conan profile for build machine
run: |
echo "" >> conanprofile_build.txt
echo "[settings]" >> conanprofile_build.txt
echo "compiler=clang" >> conanprofile_build.txt
echo "compiler.libcxx=libc++" >> conanprofile_build.txt
echo "" >> conanprofile_build.txt
- name: Android Virtual Device (AVD) cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.arch }}-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch }}
target: google_apis
sdcard-path-or-size: 1G
disk-size: 8G
script: echo "Generated AVD snapshot for caching."
- 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: google_apis
sdcard-path-or-size: 1G
disk-size: 8G
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/
bundle exec fastlane tests || 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 app/build/reports/androidTests/connected testResults/
mv app/build/outputs/androidTest-results testResults/
test ! -f sorry_but_tests_are_failing
- name: upload binaries to conan repo
run: conan upload "*" --remote odr --confirm --all --no-overwrite all
- name: upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: testResults-${{ matrix.api-level }}-${{ matrix.arch }}
path: testResults
if-no-files-found: error