-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathsend_report.yml
58 lines (50 loc) · 1.76 KB
/
send_report.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
description: "Download Codacy's coverage reporter and run it"
parameters:
tool_version:
type: string
default: ''
description: "Specify Codacy's coverage reporter tool version"
project-token:
type: string
default: ${CODACY_PROJECT_TOKEN}
description: Specify Codacy's project token
coverage-reports:
type: string
description: 'Optional comma separated list of coverage reports to send to Codacy'
default: ''
skip:
type: boolean
description: Skip if token isn't defined. Useful to let forks CI pass without passing secrets
default: false
steps:
- run:
name: Upload Coverage Results to Codacy
command: |
export CODACY_REPORTER_VERSION=<< parameters.tool_version >>
export CODACY_PROJECT_TOKEN=<< parameters.project-token >>
# comma separated list of report files
# reference from https://unix.stackexchange.com/a/191125
# plus https://stackoverflow.com/a/20323801/7898052
report_array=$(printf "<< parameters.coverage-reports >>" | cut -d',' -f1)
params=''
for report in $report_array
do
if [ ! -z "$report" ]
then
params="$params -r $report"
fi
done
if << parameters.skip >>; then
skip_option="--skip"
else
skip_option=""
fi
if [ -x "$(which curl)" ]; then
curl -Ls https://coverage.codacy.com/get.sh > get.sh
elif [ -x "$(which wget)" ] ; then
wget -qO - https://coverage.codacy.com/get.sh > get.sh
else
printf "Could not find curl or wget, please install one."
fi
source get.sh report $params --partial $skip_option &&\
source get.sh final $skip_option