-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (137 loc) · 5.11 KB
/
ci.yaml
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
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
#
# Used GitHub actions:
# * https://github.com/marketplace/actions/checkout
# * https://github.com/marketplace/actions/cache
# * https://github.com/marketplace/actions/setup-java-jdk
# * https://github.com/marketplace/actions/gradle-build-action
# * https://github.com/marketplace/actions/android-emulator-runner
name: CI
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'dev-[0-9]+'
paths-ignore:
- 'docs/**'
pull_request:
branches:
- master
paths-ignore:
- 'docs/**'
workflow_dispatch:
inputs:
test_deploy:
description: 'Build app release but skip actual deploy process'
type: boolean
default: false
skip_tests:
description: 'Skip actual test runs'
type: boolean
default: false
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run tests
if: ${{ !inputs.skip_tests }}
run: ./gradlew test --stacktrace
instrumentation-tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- api-level: 26
arch: x86
target: default
- api-level: 34
arch: x86_64
target: google_apis
steps:
- name: Checkout
uses: actions/checkout@v3
# See https://github.com/marketplace/actions/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
- name: Enable KVM group perms
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 environment
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ 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: ${{ matrix.target }}
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."
- name: Run tests
if: ${{ !inputs.skip_tests }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch }}
target: ${{ matrix.target }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew connectedCheck
build-deploy:
if: ${{ github.ref_type == 'tag' || inputs.test_deploy }}
runs-on: ubuntu-latest
needs: [unit-tests, instrumentation-tests]
steps:
- name: Check-out repository
uses: actions/checkout@v3
- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Prepare app environment
run: |
# Decode Google Service Account JSON file
echo ${{ secrets.PLAY_SERVICES_FILE_BASE64 }} | base64 -d > ${{ secrets.PLAY_SERVICES_FILE }}
# Decode keystore file from variable
echo ${{ secrets.PLAY_KEY_STORE_BASE64 }} | base64 -d > ${{ secrets.PLAY_KEY_STORE }}
# Write keystore properties file
printf 'storeFile=%s\nstorePassword=%s\nkeyAlias=%s\nkeyPassword=%s\nplayServicesFile=%s\n' \
${{ secrets.PLAY_KEY_STORE }} ${{ secrets.PLAY_STORE_PASSWORD }} ${{ secrets.PLAY_KEY_ALIAS }} ${{ secrets.PLAY_KEY_PASSWORD }} ${{ secrets.PLAY_SERVICES_FILE }} > keystore.properties
- name: Build development release
if: ${{ startsWith(github.ref_name, 'dev-') || inputs.test_deploy }}
run: ./gradlew bundleDevRelease
- name: Deploy development release
if: ${{ startsWith(github.ref_name, 'dev-') && !inputs.test_deploy }}
run: ./gradlew publishDevReleaseBundle
- name: Build stable release
if: ${{ startsWith(github.ref_name, 'v') || inputs.test_deploy }}
run: ./gradlew bundleStableRelease
- name: Deploy stable release
if: ${{ startsWith(github.ref_name, 'v') && !inputs.test_deploy }}
run: ./gradlew publishStableReleaseBundle