-
Notifications
You must be signed in to change notification settings - Fork 0
315 lines (264 loc) · 9 KB
/
_scan_all.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
name: Scan apps on given SDK ref
on:
workflow_dispatch:
inputs:
sdk_ref:
type: string
required: false
default: 'master'
scan_stax:
type: boolean
required: false
default: true
scan_nanos:
type: boolean
required: false
default: true
scan_nanox:
type: boolean
required: false
default: true
scan_nanosp:
type: boolean
required: false
default: true
jobs:
setup-devices:
name: Setup devices
runs-on: ubuntu-latest
outputs:
names: ${{ steps.build-array.outputs.names }}
steps:
- name: Setup inputs
run: |
echo "scan_stax=${{inputs.scan_stax}}" >> $GITHUB_ENV
echo "scan_nanos=${{inputs.scan_nanos}}" >> $GITHUB_ENV
echo "scan_nanox=${{inputs.scan_nanox}}" >> $GITHUB_ENV
echo "scan_nanosp=${{inputs.scan_nanosp}}" >> $GITHUB_ENV
echo "sdk_ref=${{inputs.sdk_ref}}" >> $GITHUB_ENV
- name: Override for schedule event
if: ${{ github.event_name == 'schedule' }}
run: |
echo "scan_stax=true" >> $GITHUB_ENV
echo "scan_nanos=true" >> $GITHUB_ENV
echo "scan_nanox=true" >> $GITHUB_ENV
echo "scan_nanosp=true" >> $GITHUB_ENV
echo "sdk_ref=master" >> $GITHUB_ENV
- name: Build matrix
id: build-array
run: |
if [[ ${{ env.scan_nanos }} == "true" ]]; then
NAMES+=("nanos")
fi
if [[ ${{ env.scan_nanox }} == "true" ]]; then
NAMES+=("nanox")
fi
if [[ ${{ env.scan_nanosp }} == "true" ]]; then
NAMES+=("nanosp")
fi
if [[ ${{ env.scan_stax }} == "true" ]]; then
NAMES+=("stax")
fi
devices="[\"$(echo ${NAMES[@]} | sed 's/ /","/g')\"]"
echo "names=$devices" >> $GITHUB_OUTPUT
split-input-file:
name: Split input file
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v3
- name: Split input into 10 files
run: |
python3 scripts/split_input/split_input.py --input_file input_files/input.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_1.json
path: input_1.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_2.json
path: input_2.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_3.json
path: input_3.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_4.json
path: input_4.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_5.json
path: input_5.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_6.json
path: input_6.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_7.json
path: input_7.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_8.json
path: input_8.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_9.json
path: input_9.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: input_10.json
path: input_10.json
scan-all:
name: Scan for all targets
runs-on: ubuntu-latest
needs: [split-input-file, setup-devices]
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
strategy:
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
device: ${{ fromJSON(needs.setup-devices.outputs.names) }}
steps:
- name: Clone Repo
uses: actions/checkout@v3
- name: Download split input file
uses: actions/download-artifact@v3
with:
name: input_${{ matrix.index }}.json
- name: Setup repos
run: |
python3 scripts/build_and_test/main.py --input_file input_${{ matrix.index }}.json
- name: Launch scan
run: |
python3 scripts/build_and_test/main.py --sdk_ref ${{ inputs.sdk_ref || 'master' }} --input_file input_${{ matrix.index }}.json --scan --${{ matrix.device }} --skip_setup --output_file scan_${{ matrix.device }}_${{ matrix.index }}.json
#- name: Push info to DB
# run: |
# python3 scripts/push_db.py --input_file scan_output.json
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: scan_${{ matrix.device }}_${{ matrix.index }}.json
path: scan_${{ matrix.device }}_${{ matrix.index }}.json
info-devices:
name: Setup scan infos by devices
runs-on: ubuntu-latest
needs: [scan-all, setup-devices]
strategy:
matrix:
device: ${{ fromJSON(needs.setup-devices.outputs.names) }}
steps:
- name: Clone Repo
uses: actions/checkout@v3
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_1.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_2.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_3.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_4.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_5.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_6.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_7.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_8.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_9.json
- name: Download files
uses: actions/download-artifact@v3
with:
name: scan_${{ matrix.device }}_10.json
- name: Merge output files
run: |
python3 scripts/output_scripts/merge.py --input_pattern "scan_"${{ matrix.device }}"_*.json" --output_file merged_scan_${{ matrix.device }}.json --key "scan"
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: merged_scan_${{ matrix.device }}.json
path: merged_scan_${{ matrix.device }}.json
info-all:
name: Setup scan infos
runs-on: ubuntu-latest
needs: [info-devices, setup-devices]
steps:
- name: Clone Repo
uses: actions/checkout@v3
- name: Download LNS
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: merged_scan_nanos.json
- name: Download LNSP
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: merged_scan_nanosp.json
- name: Download LNX
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: merged_scan_nanox.json
- name: Download stax
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: merged_scan_stax.json
- name: Merge output files
run: |
python3 scripts/output_scripts/merge.py --input_pattern "merged_scan_*.json" --output_file full_scan_output.json --key "scan"
- name: Convert to markdown
run: |
python3 scripts/output_scripts/convert.py --input_file full_scan_output.json --output_file out.md --key scan
cat out.md >> $GITHUB_STEP_SUMMARY
- name: Convert to slack json
run: |
python3 scripts/output_scripts/slack.py --input_file full_scan_output.json --output_file slack.json --key scan --devices ${{ needs.setup-devices.outputs.names }}
- name: Send custom JSON data to Slack workflow
if: always() && ${{ github.event_name == 'schedule' }}
id: slack
uses: slackapi/[email protected]
with:
payload-file-path: slack.json
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Set job status
run: |
python3 scripts/output_scripts/status.py --input_file full_scan_output.json --key scan
- name: Archive output file
uses: actions/upload-artifact@v3
with:
name: full_scan_output.json
path: full_scan_output.json