-
Notifications
You must be signed in to change notification settings - Fork 2
270 lines (232 loc) · 9.91 KB
/
android_pr.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: Multiplatform Build
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
danger:
name: Run Danger (Ktlint, android lint)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Danger Checks
run: |
gem install bundler
bundle install
bundle exec danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
snapshot:
name: Snapshot test with paparazzi
env:
BUILD_NUMBER: ${{github.event.number}}
runs-on: macos-14
needs: danger
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Snapshot test (shared-ui)
run: ./gradlew verifyPaparazzi --continue
- name: Commit and Push Images to GitHub Pages
if: failure()
run: ./commit-images.sh
- name: Generate snapshot difference markdown
if: failure()
run: ./gradlew createPaparazziReportComment
- name: Print out contents of snapshots.md
if: failure()
run: cat snapshots.md
- name: Comment snapshot difference markdown file on PR
uses: thollander/actions-comment-pull-request@v3
if: failure()
with:
file-path: snapshots.md
github-token: ${{secrets.GITHUB_TOKEN}}
comment-tag: snapshots
iosTest:
name: Run iOS unit tests
env:
SENTRY_BASE_URL_ANDROID: ${{secrets.SENTRY_BASE_URL_ANDROID}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
runs-on: macos-latest
needs: danger
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Unit tests iOS
run: ./gradlew iosSimulatorArm64Test
jvmTest:
name: Run JVM unit tests and generate coverage badge
needs: danger
env:
SENTRY_BASE_URL_ANDROID: ${{secrets.SENTRY_BASE_URL_ANDROID}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Run JVM unit tests
run: ./gradlew testDebugUnitTest -Pkover koverXmlReport
- name: Add coverage Report to PR
id: jacoco
uses: madrapps/jacoco-report@v1.7.1
with:
paths: |
${{ github.workspace }}/build/reports/kover/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
title: Code Coverage
min-coverage-overall: 92
min-coverage-changed-files: 85
- name: Print code coverage info
run: |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"
- name: Post changed files coverage violation
if: ${{ steps.jacoco.outputs.coverage-changed-files < 80.0 }}
uses: actions/github-script@v7
with:
script: |
core.setFailed('Coverage for changed files ${{steps.jacoco.outputs.coverage-changed-files}} is less than 80%!')
# - name: Verify minimum code coverage (90%)
# run: ./gradlew testDebugUnitTest -Pkover koverVerify
- name: Post overall coverage violation
if: ${{ steps.jacoco.outputs.coverage-overall < 92.0 }}
uses: actions/github-script@v7
with:
script: |
core.setFailed('Coverage for total project: ${{steps.jacoco.outputs.coverage-overall}} is less than 92%!')
- name: Update dynamic badge gist
if: github.ref == 'refs/heads/development'
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{secrets.SECRET_GITHUB_GIST}}
gistID: 129c8d4608ea11b81849152dba085532
filename: superdiary-badge.json
label: coverage
message: ${{ steps.jacoco.outputs.coverage-overall }}
valColorRange: ${{ steps.jacoco.outputs.coverage-overall }}
minColorRange: 0
maxColorRange: 100
androidRelease:
name: Build android app (release)
runs-on: macos-14
needs: jvmTest
env:
SENTRY_BASE_URL_ANDROID: ${{secrets.SENTRY_BASE_URL_ANDROID}}
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
GOOGLE_SERVER_CLIENT_ID: ${{secrets.GOOGLE_SERVER_CLIENT_ID}}
MAPS_API_KEY_ANDROID: ${{secrets.MAPS_API_KEY_ANDROID}}
OPENAI_KEY: ${{secrets.OPENAI_KEY}}
STORE_FILE_BASE64: ${{secrets.SIGNING_KEY_BASE64}}
STORE_PASSWORD: ${{secrets.SIGNING_KEYSTORE_PASSWORD}}
KEY_ALIAS: ${{secrets.SIGNING_KEY_ALIAS}}
KEY_PASSWORD: ${{secrets.SIGNING_KEY_PASSWORD}}
SUPABASE_URL: ${{secrets.SUPABASE_URL}}
SUPABASE_KEY: ${{secrets.SUPABASE_KEY}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup secrets.properties and Configurations/Release.xcconfig
run: ./environments.sh
- name: Decode keystore file from secrets
run: echo "$STORE_FILE_BASE64" | base64 --decode > keystore
- name: Inject Signing params into gradle.properties
run: |
echo STORE_FILE=keystore >> gradle.properties
echo STORE_PASSWORD="$STORE_PASSWORD" >> gradle.properties
echo KEY_PASSWORD="$KEY_PASSWORD" >> gradle.properties
echo KEY_ALIAS="$KEY_ALIAS" >> gradle.properties
cat gradle.properties
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build Android App (Release)
run: ./gradlew androidApp:app:assembleRelease
- name: Get latest artifact ID
run: |
ARTIFACT_ID=$(gh api repos/rafsanjani/superdiary/actions/artifacts \
--jq '.artifacts | sort_by(.updated_at) | last | .id')
echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV
- name: Download the artifact
run: |
gh api repos/rafsanjani/superdiary/actions/artifacts/$ARTIFACT_ID/zip > artifact.zip
unzip artifact.zip
- name: Run APK Diff
run: |
gh release download -p '*.zip' -R jakewharton/diffuse 0.3.0
unzip diffuse-0.3.0.zip
./diffuse-0.3.0/bin/diffuse diff app-release.apk androidApp/app/build/outputs/apk/release/app-release.apk > apk_differences.txt
{ echo "\`\`\`"; head -n 17 apk_differences.txt; echo "\`\`\`"; echo; } >> apk_differences_summary.txt
- name: Post APK diff to Pull Request
uses: thollander/actions-comment-pull-request@v3
with:
file-path: apk_differences_summary.txt
github-token: ${{secrets.GITHUB_TOKEN}}
comment-tag: apk_difference
#
# iOSReleaseBuild:
# name: Build iOS app (Release)
# runs-on: macos-14
# # needs: iosTest
# steps:
# - uses: actions/checkout@v4
# with:
# lfs: true
# - uses: actions/setup-java@v4
# with:
# distribution: 'zulu'
# java-version: '17'
#
# - name: Setup secrets.properties and Configurations/Release.xcconfig
# run: ./environments.sh
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@v4
#
# - uses: maxim-lobanov/setup-xcode@v1
# with:
# xcode-version: latest-stable
#
# - name: Build iOS App (Release)
# run: |
# cd iosApp
# cat Configurations/Release.xcconfig
# xcodebuild \
# -scheme iosApp \
# -configuration Debug \
# -destination 'generic/platform=iOS' \
# build
#