Fix a bug with showSeedSettings result handling (#375) #416
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |