forked from philips-software/spdx-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
330 lines (323 loc) · 14.8 KB
/
action.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
name: 'Run ORT'
description: >
Run oss-review-toolkit to review Open Source software dependencies.
author: "edulix"
branding:
icon: "activity"
color: "green"
outputs:
analyzer-result:
description: "output file for the analyze step"
value: ${{ steps.analyze.outputs.analyzer-result }}
evaluation-result:
description: "output file for the evaluate step"
value: ${{ steps.evaluate.outputs.evaluation-result }}
results-dir:
description: "output directory for the report step"
value: ${{ steps.init.outputs.results-dir }}
inputs:
ort-version:
description: "edulix/ort docker hub tag to use."
required: false
default: 'latest'
analyze:
description: >
Set to `false` to disable the execution of the ORT `analyze`
ORT Action. Default: `true`.
required: false
default: true
evaluate:
description: >
Set to `false` to disable the execution of the ORT `evaluate`
ORT Action. Default: `true`.
required: false
default: true
report:
description: >
Set to `false` to disable the execution of the ORT `report`
ORT Action. Default: `true`.
required: false
default: true
verbosity:
description: >
Verbosity level in ORT to use. Possible values: [
`warn`, `info`, `performance`, `debug`]. Default to `warn`.
required: false
default: 'warn'
package-curations-dir:
description: >-
Specifies path relative to the project directory for the curations
directory. Used in `analyze` and `evaluate` actions. It's the
`--package-curations-dir` option for ORT.
required: false
rules-file:
description: >-
Specifies path relative to the project directory for the rules of the
`evaluate` action. It's the `--rules-file` option for ORT.
required: false
license-classifications-file:
description: >-
Specifies path relative to the project directory for the license
classifications file of the `evaluate` action. It's the
`--license-classifications-file` option for ORT.
required: false
reporters:
description: >-
List of reporters to run. Default: Excel,StaticHtml,WebApp
required: false
default: Excel,StaticHtml,WebApp
ort-extra-args:
description: >-
List of extra arguments for ORT, for all commands, set before
the verb (before analyze, evaluate or report).
required: false
default: ""
analyze-extra-args:
description: List of extra arguments for the `analyze` action.
required: false
evaluate-extra-args:
description: List of extra arguments for the `evaluate` action.
required: false
report-extra-args:
description: List of extra arguments for the `report` action.
required: false
runs:
using: "composite"
steps:
- name: Initialization
id: init
shell: bash
env:
VERBOSITY: ${{ inputs.verbosity }}
run: |
echo "-----------------------------------------------------------------"
echo " Initialization step"
echo "-----------------------------------------------------------------"
echo " Inputs: "
echo " VERBOSITY : '${VERBOSITY}' "
echo "-----------------------------------------------------------------"
[ -d ${{ github.workspace }}/ort/ ] || mkdir ${{ github.workspace }}/ort/
[ -d ${{ github.workspace }}/.ort/ ] || mkdir ${{ github.workspace }}/.ort/
[ -d ${{ github.workspace }}/.config/ ] || mkdir ${{ github.workspace }}/.config/
[ -d ${{ github.workspace }}/.cache/ ] || mkdir ${{ github.workspace }}/.cache/
[ -d ${{ github.workspace }}/.local/ ] || mkdir ${{ github.workspace }}/.local/
chmod -R aug+w ${{ github.workspace }}/
echo "-----------------------------------------------------------------"
echo " Output directory ${{ github.workspace }}/ort/ contents:"
echo "-----------------------------------------------------------------"
ls -lah ${{ github.workspace }}/ort/
echo "-----------------------------------------------------------------"
echo "::set-output name=results-dir::ort/"
echo "-----------------------------------------------------------------"
echo " Parsing VERBOSITY"
echo "-----------------------------------------------------------------"
if [ ${VERBOSITY} = "warn" ]; then
echo "::set-output name=verbosity::"
echo " Setting verbosity as warning level"
elif [[ ${VERBOSITY} == +(info|performance|debug) ]]; then
echo "::set-output name=verbosity::--${VERBOSITY}"
echo " Setting verbosity as ${VERBOSITY} level"
else
echo "Error: verbosity='${VERBOSITY}' should be one of: warn, debug, info, performance"
exit 1
fi
echo "-----------------------------------------------------------------"
- name: ORT analyze
id: analyze
shell: bash
env:
ORT_EXTRA_ARGS: ${{ inputs.ort-extra-args }}
VERBOSITY: ${{ steps.init.outputs.verbosity }}
RUN_ANALYZE: ${{ inputs.analyze }}
ANALYZE_EXTRA_ARGS: ${{ inputs.analyze-extra-args }}
run: |
[ "${RUN_ANALYZE}" = "true" ] || \
{ echo "analyze is not true but '${RUN_ANALYZE}' so don't perform this step"; exit 0; }
export USER_ID=$(id -u ${USER})
echo "-----------------------------------------------------------------"
echo " ORT analyze step"
echo "-----------------------------------------------------------------"
echo " Inputs: "
echo " ORT_EXTRA_ARGS : '${ORT_EXTRA_ARGS}' "
echo " ANALYZE_EXTRA_ARGS : '${ANALYZE_EXTRA_ARGS}' "
echo "-----------------------------------------------------------------"
echo " Set X_EXTRA_ARGS from ANALYZE_EXTRA_ARGS"
echo "-----------------------------------------------------------------"
[ -z "$ANALYZE_EXTRA_ARGS" ] && \
X_EXTRA_ARGS="" || \
X_EXTRA_ARGS="${ANALYZE_EXTRA_ARGS}"
echo " X_EXTRA_ARGS: '${X_EXTRA_ARGS}'"
echo "-----------------------------------------------------------------"
echo " Running ORT analyze"
echo "-----------------------------------------------------------------"
cat << EOF
docker run \\
-e ORT_DATA_DIR=/project/.ort/ \\
-e JAVA_OPTS="--illegal-access=permit" \\
-e SBT_OPTS="-verbose -debug -Dsbt.global.base=.sbt -Dsbt.boot.directory=.sbt -Dsbt.ivy.home=.ivy2" \\
-v ${{ github.workspace }}/.config:/.config \\
-v ${{ github.workspace }}/.cache:/.cache \\
-v ${{ github.workspace }}/.local:/.local \\
-v ${{ github.workspace }}:/project \\
--user ${USER_ID} \\
edulix/ort:${{ inputs.ort-version }} \\
${ORT_EXTRA_ARGS} \\
${VERBOSITY} \\
analyze \\
-i /project \\
-o /project/ort \\
${X_EXTRA_ARGS}
EOF
docker run \
-e ORT_DATA_DIR=/project/.ort/ \
-e JAVA_OPTS="--illegal-access=permit" \
-e SBT_OPTS="-Dsbt.global.base=.sbt -Dsbt.boot.directory=.sbt -Dsbt.ivy.home=.ivy2" \
-v ${{ github.workspace }}/.config:/.config \
-v ${{ github.workspace }}/.cache:/.cache \
-v ${{ github.workspace }}/.local:/.local \
-v ${{ github.workspace }}:/project \
--user ${USER_ID} \
edulix/ort:${{ inputs.ort-version }} \
${ORT_EXTRA_ARGS} \
${VERBOSITY} \
analyze \
-i /project \
-o /project/ort \
${X_EXTRA_ARGS}
echo "-----------------------------------------------------------------"
echo " Finished!"
echo "-----------------------------------------------------------------"
echo " Output directory ${{ github.workspace }}/ort/ contents:"
echo "-----------------------------------------------------------------"
ls -lah ${{ github.workspace }}/ort/
echo "-----------------------------------------------------------------"
echo "::set-output name=analyzer-result::ort/analyzer-result.yml"
- name: ORT evaluate
id: evaluate
shell: bash
env:
ORT_EXTRA_ARGS: ${{ inputs.ort-extra-args }}
VERBOSITY: ${{ steps.init.outputs.verbosity }}
RUN_EVALUATE: ${{ inputs.evaluate }}
PACKAGE_CURATIONS_DIR: ${{ inputs.package-curations-dir }}
RULES_FILE: ${{ inputs.rules-file }}
LICENSE_CLASSIFICATIONS_FILE: ${{ inputs.license-classifications-file }}
EVALUATE_EXTRA_ARGS: ${{ inputs.evaluate-extra-args }}
run: |
[ "${RUN_EVALUATE}" = "true" ] || \
{ echo "evaluate is not true but '${RUN_EVALUATE}' so don't perform this step"; exit 0; }
echo "-----------------------------------------------------------------"
echo " ORT evaluate step"
echo "-----------------------------------------------------------------"
echo " Inputs: "
echo " ORT_EXTRA_ARGS : '${ORT_EXTRA_ARGS}' "
echo " PACKAGE_CURATIONS_DIR : '${PACKAGE_CURATIONS_DIR}' "
echo " RULES_FILE : '${RULES_FILE}' "
echo " LICENSE_CLASSIFICATIONS_FILE : '${LICENSE_CLASSIFICATIONS_FILE}' "
echo " EVALUATE_EXTRA_ARGS : '${EVALUATE_EXTRA_ARGS}' "
echo "-----------------------------------------------------------------"
echo " Set X_CURATIONS_DIR from PACKAGE_CURATIONS_DIR"
echo "-----------------------------------------------------------------"
[ -z "$PACKAGE_CURATIONS_DIR" ] && \
X_CURATIONS_DIR="" || \
X_CURATIONS_DIR="--package-curations-dir /project/${PACKAGE_CURATIONS_DIR}"
echo " X_CURATIONS_DIR: '${X_CURATIONS_DIR}'"
echo " Set X_RULES_FILE from RULES_FILE"
echo "-----------------------------------------------------------------"
[ -z "$RULES_FILE" ] && \
X_RULES_FILE="" || \
X_RULES_FILE="--rules-file /project/${RULES_FILE}"
echo " X_RULES_FILE: '${X_RULES_FILE}'"
echo "-----------------------------------------------------------------"
echo " Set X_LICENSE_CLASS from LICENSE_CLASSIFICATIONS_FILE"
echo "-----------------------------------------------------------------"
[ -z "$LICENSE_CLASSIFICATIONS_FILE" ] && \
X_LICENSE_CLASS="" || \
X_LICENSE_CLASS="--license-classifications-file /project/${LICENSE_CLASSIFICATIONS_FILE}"
echo " X_LICENSE_CLASS: '${X_LICENSE_CLASS}'"
echo "-----------------------------------------------------------------"
echo " Set X_EXTRA_ARGS"
echo "-----------------------------------------------------------------"
[ -z "$EVALUATE_EXTRA_ARGS" ] && \
X_EXTRA_ARGS="" || \
X_EXTRA_ARGS="${EVALUATE_EXTRA_ARGS}"
echo " X_EXTRA_ARGS: '${X_EXTRA_ARGS}'"
echo "-----------------------------------------------------------------"
docker run \
-e ORT_DATA_DIR=/project/.ort/ \
-v ${{ github.workspace }}:/project \
--user 10001 \
edulix/ort:${{ inputs.ort-version }} \
${ORT_EXTRA_ARGS} \
${VERBOSITY} \
evaluate \
-i /project/ort/analyzer-result.yml \
-o /project/ort \
${X_CURATIONS_DIR} \
${X_RULES_FILE} \
${X_LICENSE_CLASS} \
${X_EXTRA_ARGS}
echo "-----------------------------------------------------------------"
echo " Finished!"
echo "-----------------------------------------------------------------"
echo " Output directory ${{ github.workspace }}/ort/ contents:"
echo "-----------------------------------------------------------------"
ls -lah ${{ github.workspace }}/ort/
echo "-----------------------------------------------------------------"
echo "::set-output name=evaluation-result::ort/evaluation-result.yml"
- name: ORT report
id: report
shell: bash
env:
ORT_EXTRA_ARGS: ${{ inputs.ort-extra-args }}
VERBOSITY: ${{ steps.init.outputs.verbosity }}
RUN_REPORT: ${{ inputs.report }}
REPORTERS: ${{ inputs.reporters }}
REPORT_EXTRA_ARGS: ${{ inputs.report-extra-args }}
run: |
[ "${RUN_REPORT}" = "true" ] || \
{ echo "report is not true but '${RUN_REPORT}' so don't perform this step"; exit 0; }
echo "-----------------------------------------------------------------"
echo " ORT report step"
echo "-----------------------------------------------------------------"
echo " Inputs: "
echo " ORT_EXTRA_ARGS : '${ORT_EXTRA_ARGS}' "
echo " REPORTERS : '${REPORTERS}' "
echo " REPORT_EXTRA_ARGS : '${REPORT_EXTRA_ARGS}' "
echo "-----------------------------------------------------------------"
echo " Set X_REPORTERS from REPORTERS"
echo "-----------------------------------------------------------------"
[ -z "$REPORTERS" ] && \
X_REPORTERS="" || \
X_REPORTERS="${REPORTERS}"
echo " X_REPORTERS: '${X_REPORTERS}'"
echo "-----------------------------------------------------------------"
echo " Set X_EXTRA_ARGS from REPORT_EXTRA_ARGS"
echo "-----------------------------------------------------------------"
[ -z "$REPORT_EXTRA_ARGS" ] && \
X_EXTRA_ARGS="" || \
X_EXTRA_ARGS="${REPORT_EXTRA_ARGS}"
echo " X_EXTRA_ARGS: '${X_EXTRA_ARGS}'"
echo "-----------------------------------------------------------------"
echo " Running ORT report"
echo "-----------------------------------------------------------------"
echo "command: 'docker run -e ORT_DATA_DIR=/project/.ort/ -v ${{ github.workspace }}:/project --user 10001 edulix/ort:${{ inputs.ort-version }} --info report -i /project/ort/evaluation-result.yml -o /project/ort -f ${X_REPORTERS} ${X_EXTRA_ARGS}'"
docker run \
-e ORT_DATA_DIR=/project/.ort/ \
-v ${{ github.workspace }}:/project \
--user 10001 \
edulix/ort:${{ inputs.ort-version }} \
${ORT_EXTRA_ARGS} \
${VERBOSITY} \
report \
-i /project/ort/evaluation-result.yml \
-o /project/ort \
-f ${X_REPORTERS} \
${X_EXTRA_ARGS}
echo "-----------------------------------------------------------------"
echo " Finished!"
echo "-----------------------------------------------------------------"
echo " Output directory ${{ github.workspace }}/ort/ contents:"
echo "-----------------------------------------------------------------"
ls -lah ${{ github.workspace }}/ort/
echo "-----------------------------------------------------------------"