-
Notifications
You must be signed in to change notification settings - Fork 18
203 lines (177 loc) · 7.98 KB
/
android.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
name: Android CI
on:
push:
branches: [ main, next ]
paths-ignore: [ 'docs/**', 'fakewalletreact/**', 'js/**' ]
pull_request:
branches: [ main, next ]
paths-ignore: [ 'docs/**', 'fakewalletreact/**', 'js/**' ]
release:
types: [ published ]
env:
AVD_ANDROID_API_LEVEL: '35'
AVD_ANDROID_ARCH: 'x86_64'
AVD_ANDROID_TARGET: 'google_atd'
jobs:
build-and-test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
##########################################################################
# Setup
##########################################################################
- uses: solana-mobile/gha-free-disk-space-for-android-build-and-test@v1
- uses: actions/checkout@v4
- name: Enable KVM for Android Virtual Device acceleration
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Gradle cache
uses: gradle/actions/setup-gradle@v4
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.AVD_ANDROID_ARCH }}-${{ env.AVD_ANDROID_API_LEVEL }}-${{ env.AVD_ANDROID_TARGET }}
# NOTE: Keep AVD snapshot generation option in sync with the AVD test execution step below
- 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: ${{ env.AVD_ANDROID_API_LEVEL }}
arch: ${{ env.AVD_ANDROID_ARCH }}
target: ${{ env.AVD_ANDROID_TARGET }}
enable-hw-keyboard: true
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
##########################################################################
# Build
##########################################################################
- name: Build with Gradle
run: ./gradlew build assembleAndroidTest
##########################################################################
# Upload build artifacts
##########################################################################
# Upload libraries to workflow artifacts
- uses: actions/upload-artifact@v4
if: ${{ github.event_name != 'pull_request' }}
with:
name: libraries
path: seedvault/build/outputs/aar/*.aar
if-no-files-found: error
retention-days: 5
# Upload javadoc to workflow artifacts
- uses: actions/upload-artifact@v4
if: ${{ github.event_name != 'pull_request' }}
with:
name: seedvault-javadoc
path: |
seedvault/build/docs/*
!seedvault/build/docs/**/*.zip
if-no-files-found: error
retention-days: 1
##########################################################################
# Test
##########################################################################
- name: run CTS test automation
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.AVD_ANDROID_API_LEVEL }}
arch: ${{ env.AVD_ANDROID_ARCH }}
target: ${{ env.AVD_ANDROID_TARGET }}
enable-hw-keyboard: true
force-avd-creation: false
emulator-boot-timeout: 120 # 2 minutes. Fail fast.
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb logcat -c
mkdir -p cts/build/reports/androidTests/connected
adb logcat >> cts/build/reports/androidTests/connected/instrumented_tests_logcat.txt &
./gradlew :SeedVaultSimulator:installDebug
./gradlew :cts:connectedGenericDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.SeedVaultSimulatorSetup
./gradlew :cts:connectedGenericDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.RunCtsTestsOnSimulator
./gradlew :cts:connectedPrivilegedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.SeedVaultSimulatorSetup
./gradlew :cts:connectedPrivilegedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.solanamobile.seedvault.cts.RunCtsTestsOnSimulator
##########################################################################
# Upload test artifacts
##########################################################################
# Upload test results to workflow artifacts
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-results
path: cts/build/reports/androidTests/connected/**
if-no-files-found: error
retention-days: 5
##########################################################################
# Publish to Maven Central
##########################################################################
- name: Publish to Maven Central (release only)
if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v') }} # (only for releases that start with 'v')
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PRIVATE_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PUBLISHING_PASSWORD }}
TAG: ${{ github.event.release.tag_name }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -P version=${TAG:1} --no-configuration-cache
# Note: only runs on 'push' events for main
publish-to-gh-pages:
runs-on: ubuntu-latest
needs: build-and-test
concurrency: publish-to-gh-pages
if: ${{ github.event_name == 'push' && github.event.push.base_ref == 'main' }}
steps:
- name: Update seedvault javadoc
uses: solana-mobile/gha-commit-artifact-to-branch@v2
with:
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }}
branch: gh-pages
artifact-name: seedvault-javadoc
dest: seedvault
commit-message: 'Update seedvault javadoc'
# Note: only runs on 'release' events
upload-to-release:
runs-on: ubuntu-latest
needs: build-and-test
permissions:
contents: write # needed for uploading files to releases
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/download-artifact@v4
with:
name: libraries
path: libraries
- uses: actions/download-artifact@v4
with:
name: seedvault-javadoc
path: seedvault-javadoc
- uses: actions/download-artifact@v4
with:
name: test-results
path: test-results
- name: Compress seedvault javadoc
run: tar -cvzf seedvault-javadoc.tgz -C seedvault-javadoc .
- name: Compress test results
run: tar -cvzf test-results.tgz -C test-results .
- name: Upload files to release
run: gh release -R ${GITHUB_REPOSITORY} upload ${TAG} ${FILES}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name }}
FILES: |
libraries/*.aar
seedvault-javadoc.tgz
test-results.tgz