-
Notifications
You must be signed in to change notification settings - Fork 7
380 lines (329 loc) · 12.6 KB
/
pr_and_main.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
name: "Test and build"
on:
pull_request:
push:
branches:
- main
permissions:
id-token: write
contents: read
pull-requests: read
jobs:
cancel:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
actions: write
steps:
- name: Cancel Previous Runs
uses: RDXWorks-actions/cancel-workflow-action@main
phylum-analyze:
if: ${{ github.event.pull_request }}
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/phylum-analyze.yml@main
permissions:
id-token: write
pull-requests: write
contents: read
deployments: write
secrets:
phylum_api_key: ${{ secrets.PHYLUM_API_KEY }}
with:
phylum_pr_number: ${{ github.event.number }}
phylum_pr_name: ${{ github.head_ref }}
phylum_group_name: Wallet
phylum_project_id: 7d09edfc-1ff4-4f88-9389-5da831913983
github_repository: ${{ github.repository }}
add_report_comment_to_pull_request: true
snyk_scan_deps_licences:
name: "Snyk deps/licenses"
runs-on: ubuntu-latest
steps:
- uses: RDXWorks-actions/checkout@main
- name: Fetch Snyk credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.COMMON_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'snyk-licenses'
secret_prefix: 'SNYK'
secret_name: "github-actions/common/snyk-credentials"
parse_json: true
- name: Run Snyk to check for deps vulnerabilities
uses: RDXWorks-actions/snyk-actions/gradle-jdk17@master
with:
args: --all-projects --org=${{ env.SNYK_COREAPPS_ORG_ID }} --severity-threshold=critical
env:
SNYK_TOKEN: ${{ env.SNYK_TOKEN }}
snyk_scan_code:
name: "Snyk code"
runs-on: ubuntu-latest
steps:
- uses: RDXWorks-actions/checkout@main
- name: Fetch Snyk credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.COMMON_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'snyk-licenses'
secret_prefix: 'SNYK'
secret_name: "github-actions/common/snyk-credentials"
parse_json: true
- name: Run Snyk to check for code vulnerabilities
uses: RDXWorks-actions/snyk-actions/gradle-jdk17@master
continue-on-error: true
with:
args: --all-projects --org=${{ env.SNYK_COREAPPS_ORG_ID }} --severity-threshold=high
command: code test
env:
SNYK_TOKEN: ${{ env.SNYK_TOKEN }}
snyk_sbom:
name: "Snyk SBOM"
runs-on: ubuntu-latest
steps:
- uses: RDXWorks-actions/checkout@main
- name: Fetch Snyk credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.COMMON_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'snyk-licenses'
secret_prefix: 'SNYK'
secret_name: "github-actions/common/snyk-credentials"
parse_json: true
- name: Fetch AppsFlyer credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'sbom-flyers'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/apps-flyer-secret"
parse_json: true
- name: Output AppsFlyer secret to file
shell: bash
run: |
mkdir -p config/secrets/
echo "appsFlyerDevKey=${{ env.GH_APPS_FLYER_DEV_KEY }}" > config/secrets/secrets.properties
- name: Generate SBOM # check SBOM can be generated but nothing is done with it
uses: RDXWorks-actions/snyk-actions/gradle-jdk17@master
with:
args: --all-projects --org=${{ env.SNYK_COREAPPS_ORG_ID }} --format=cyclonedx1.4+json > sbom.json
command: sbom
env:
SNYK_TOKEN: ${{ env.SNYK_TOKEN }}
unit_tests:
name: "Unit tests"
runs-on: ubuntu-latest
steps:
- uses: RDXWorks-actions/checkout@main
- uses: RDXWorks-actions/setup-java@main
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Fetch GPR credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'unit-gpr'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true
- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'unit-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true
- name: Fetch AppsFlyer credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'unit-flyers'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/apps-flyer-secret"
parse_json: true
- name: Output AppsFlyer secret to file
shell: bash
run: |
mkdir -p config/secrets/
echo "appsFlyerDevKey=${{ env.GH_APPS_FLYER_DEV_KEY }}" > config/secrets/secrets.properties
- name: Decode Firebase Crashlytics json
uses: RDXWorks-actions/base64-to-file@main
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}
- name: "Run unit tests"
run: ./gradlew testDebugUnitTest
env:
GPR_USER: ${{ env.GH_GPR_USER }}
GPR_TOKEN: ${{ env.GH_GPR_TOKEN }}
static_analysis:
name: "Static analysis and SonarCloud"
# jacoco runs unit tests and since they depend on sargon-desktop we need mac os
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- uses: RDXWorks-actions/setup-java@main
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Fetch GPR credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'sonar'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true
- name: Fetch Sonar token
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'sonar-1'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/sonar-token"
parse_json: true
- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'static-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true
- name: Decode Firebase Crashlytics json
uses: RDXWorks-actions/base64-to-file@main
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}
- name: Fetch AppsFlyer credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'sonar-flyers'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/apps-flyer-secret"
parse_json: true
- name: Output AppsFlyer secret to file
shell: bash
run: |
mkdir -p config/secrets/
echo "appsFlyerDevKey=${{ env.GH_APPS_FLYER_DEV_KEY }}" > config/secrets/secrets.properties
- name: Export vars
run: |
echo "GPR_USER=${{ env.GH_GPR_USER }}" >> $GITHUB_ENV
echo "GPR_TOKEN=${{ env.GH_GPR_TOKEN }}" >> $GITHUB_ENV
echo "SONAR_TOKEN=${{ env.GH_SONAR_TOKEN }}" >> $GITHUB_ENV
- name: "Run detekt"
run: |
env
./gradlew detektMain
- name: "Run jacoco"
run: |
./gradlew jacocoTestReport
- name: "Run Sonarcloud"
run: |
./gradlew sonarqube
build:
name: "Build"
runs-on: ubuntu-latest
needs:
# - unit_tests
# - static_analysis
- snyk_scan_deps_licences
- snyk_scan_code
- snyk_sbom
steps:
- uses: RDXWorks-actions/checkout@main
- name: Dump context
uses: RDXWorks-actions/ghaction-dump-context@master
- uses: RDXWorks-actions/setup-java@main
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
- name: Fetch GPR credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'build'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true
- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'build-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true
- name: Decode Firebase Crashlytics json
uses: RDXWorks-actions/base64-to-file@main
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}
- name: Fetch AppsFlyer credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'build-flyers'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/apps-flyer-secret"
parse_json: true
- name: Output AppsFlyer secret to file
shell: bash
run: |
mkdir -p config/secrets/
echo "appsFlyerDevKey=${{ env.GH_APPS_FLYER_DEV_KEY }}" > config/secrets/secrets.properties
- name: "Build"
run: |
./gradlew assembleDebug
env:
GPR_USER: ${{ env.GH_GPR_USER }}
GPR_TOKEN: ${{ env.GH_GPR_TOKEN }}
snyk_online_monitor:
name: "Snyk monitoring"
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- build
steps:
- uses: RDXWorks-actions/checkout@main
- name: Fetch Snyk credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.COMMON_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'snyk-licenses'
secret_prefix: 'SNYK'
secret_name: "github-actions/common/snyk-credentials"
parse_json: true
- name: Enable Snyk online monitoring to check for vulnerabilities
uses: RDXWorks-actions/snyk-actions/gradle-jdk17@master
with:
args: --all-projects --org=${{ env.SNYK_COREAPPS_ORG_ID }}
command: monitor
env:
SNYK_TOKEN: ${{ env.SNYK_TOKEN }}