-
Notifications
You must be signed in to change notification settings - Fork 2
206 lines (171 loc) · 6.57 KB
/
nightly.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
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
204
205
206
name: Nightly build and test
env:
# The name of the main module repository
main_project_module: app
# The name in the Play Store
playstore_name: Soundscape
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Schedule the build for 05.30 UTC
schedule:
- cron: '30 5 * * *'
jobs:
check_date:
name: Check latest commit
runs-on: ubuntu-latest
environment: development
permissions:
contents: write
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check latest commit is less than a day
id: should_run
continue-on-error: true
#if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" HEAD) && echo "should_run=false" >> $GITHUB_OUTPUT
build:
name: Build debug package
runs-on: ubuntu-latest
environment: development
needs: check_date
if: ${{ needs.check_date.outputs.should_run != 'false' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
#- name: Setup tile provider API key
# env:
# TILE_PROVIDER_API_KEY: ${{ secrets.TILE_PROVIDER_API_KEY }}
# run: |
# echo tileProviderApiKey=$TILE_PROVIDER_API_KEY > local.properties
- name: Decode Google services
env:
ENCODED_STRING: ${{ secrets.GOOGLE_SERVICES }}
GOOGLE_SERVICES_PATH: ${{ secrets.GOOGLE_SERVICES_PATH }}
run: |
echo $ENCODED_STRING > google-services-b64.txt
base64 -d google-services-b64.txt > ${{ env.main_project_module }}/$GOOGLE_SERVICES_PATH
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Run lint over the repo
run: ./gradlew lint
# Run Tests Build
- name: Run gradle tests
run: ./gradlew test
# Generate the screenshots from the Preview code
- name: Generate screenshots
run : ./gradlew updateDebugScreenshotTest
# Upload screenshots as an artifact
# Noted For Output [main_project_module]/build/outputs/apk/debug/
- name: Upload screenshots
uses: actions/upload-artifact@v4
with:
name: screenshot-previews
path: ${{ env.main_project_module }}/src/debug/screenshotTest/reference/org/scottishtecharmy/soundscape/
# Create APK Debug
- name: Build apk debug project (APK)
run: |
./gradlew assembleDebug
# Upload Artifact Build
# Noted For Output [main_project_module]/build/outputs/apk/debug/
- name: Upload APK Debug
uses: actions/upload-artifact@v4
with:
name: debug-apk
path: ${{ env.main_project_module }}/build/outputs/apk/debug/
# Generate android instrumentation tests APK
- name: Assemble Android Instrumentation Tests
run: ./gradlew assembleDebugAndroidTest
- name: Upload Android Test APK
uses: actions/upload-artifact@v4
with:
name: debug-androidTest
path: ${{ env.main_project_module }}/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
instrumentation-tests:
name: Run matrix of instrumentation tests
needs: build
environment: development
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [30, 31, 34]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
#- name: Setup tile provider API key
# env:
# TILE_PROVIDER_API_KEY: ${{ secrets.TILE_PROVIDER_API_KEY }}
# run: |
# echo tileProviderApiKey=$TILE_PROVIDER_API_KEY > local.properties
- name: Decode Google services
env:
ENCODED_STRING: ${{ secrets.GOOGLE_SERVICES }}
GOOGLE_SERVICES_PATH: ${{ secrets.GOOGLE_SERVICES_PATH }}
run: |
echo $ENCODED_STRING > google-services-b64.txt
base64 -d google-services-b64.txt > ${{ env.main_project_module }}/$GOOGLE_SERVICES_PATH
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Set Up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Enable KVM
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: Instrumentation Tests
id: instrumentation-tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: default
arch: x86_64
script: |
adb logcat -c # clear logs
touch app/emulator.log # create log file
chmod 777 app/emulator.log # allow writing to log file
adb logcat >> app/emulator.log & # pipe all logcat messages into log file as a background process
./gradlew connectedCheck
firebase:
name: Run UI tests with Firebase Test Lab
needs: build
environment: development
runs-on: ubuntu-latest
steps:
- name: Download app APK
uses: actions/download-artifact@v4
with:
name: debug-apk
- name: Download Android test APK
uses: actions/download-artifact@v4
with:
name: debug-androidTest
- name: Auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_CREDENTIALS_JSON }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Set current project
run: gcloud config set project ${{ secrets.FIREBASE_PROJECT_ID }}
- name: Run Instrumentation Tests in Firebase Test Lab
run: gcloud firebase test android run --type instrumentation --use-orchestrator --app app-debug.apk --test app-debug-androidTest.apk --device model=shiba,version=34,locale=en,orientation=portrait
- name: Run Robo test in Firebase Test Lab
run: gcloud firebase test android run --type robo --app=app-debug.apk --timeout=1800s --device model=shiba,version=34,locale=en,orientation=portrait