-
Notifications
You must be signed in to change notification settings - Fork 276
163 lines (135 loc) · 5.07 KB
/
build_and_test.yml
File metadata and controls
163 lines (135 loc) · 5.07 KB
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
name: Build and Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
# Ensure that only the latest commit is tested for PRs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build_test_lint:
name: "Build, Test, and Lint"
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: write # Needed for git-auto-commit-action
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Add cache-encryption-key if you set up the GRADLE_ENCRYPTION_KEY secret
# with:
# cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Decode google-services.json
env:
DEBUG_GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.DEBUG_GOOGLE_SERVICES_JSON_BASE64 }}
run: |
if [ -z "$DEBUG_GOOGLE_SERVICES_JSON_BASE64" ]; then
echo "DEBUG_GOOGLE_SERVICES_JSON_BASE64 is empty. Copying test-google-services.json."
cp test-google-services.json app/google-services.json
else
echo "Decoding DEBUG_GOOGLE_SERVICES_JSON_BASE64."
echo $DEBUG_GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/google-services.json
fi
- name: Apply Spotless
run: ./gradlew spotlessApply
- name: Commit Spotless changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 🤖 Apply Spotless formatting
file_pattern: '**/*.kt **/*.kts **/*.java **/*.xml'
- name: Build debug APK
run: ./gradlew assembleDebug --no-configuration-cache
- name: Verify Screenshot Tests (AndroidX)
run: ./gradlew validateDebugScreenshotTest
- name: Run local unit tests
run: ./gradlew testDebugUnitTest
- name: Check lint
run: ./gradlew lintDebug
- name: Upload build outputs (APKs)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: APKs
path: '**/build/outputs/apk/debug/*.apk'
- name: Upload JVM local test results (XML)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: local-test-results
path: '**/build/test-results/test*UnitTest/TEST-*.xml'
- name: Upload lint reports (HTML)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: lint-reports-html
path: '**/build/reports/lint-results-debug.html'
androidTest:
name: "Instrumentation Tests (emulator)"
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
api-level: [26]
steps:
- name: Delete unnecessary tools 🔧
uses: jlumbroso/free-disk-space@v1.3.1
with:
android: false # Don't remove Android tools
tool-cache: true # Remove image tool cache
dotnet: true
haskell: true
swap-storage: true
- 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: Checkout code
uses: actions/checkout@v4
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Decode google-services.json
env:
DEBUG_GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.DEBUG_GOOGLE_SERVICES_JSON_BASE64 }}
run: |
if [ -z "$DEBUG_GOOGLE_SERVICES_JSON_BASE64" ]; then
echo "DEBUG_GOOGLE_SERVICES_JSON_BASE64 is empty. Copying test-google-services.json."
cp test-google-services.json app/google-services.json
else
echo "Decoding DEBUG_GOOGLE_SERVICES_JSON_BASE64."
echo $DEBUG_GOOGLE_SERVICES_JSON_BASE64 | base64 --decode > app/google-services.json
fi
- name: Build
run: ./gradlew assembleDebug assembleDebugAndroidTest
- name: Build projects and run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86
disable-animations: true
disk-size: 6000M
heap-size: 600M
script: ./gradlew connectedDebugAndroidTest
- name: Upload test reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.api-level }}
path: '**/build/reports/androidTests'