forked from googleapis/google-cloud-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createcoveragereport.sh
executable file
·74 lines (61 loc) · 1.85 KB
/
createcoveragereport.sh
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
#!/bin/bash
set -e
source toolversions.sh
if [ ! -d coverage ]
then
mkdir coverage
fi
if ! compgen -G "coverage/*.dvcr"
then
echo "No coverage reports found to merge."
# This isn't an error
exit 0
fi
install_dotcover
install_reportgenerator
codecov_params=
upload_report=false
while (( "$#" )); do
if [[ "$1" == "--upload" ]]
then
upload_report=true
elif [[ "$1" == "--upload_reportname" ]]
then
shift
codecov_params="$codecov_params --flag $1"
elif [[ "$1" == "--upload_commit" ]]
then
shift
codecov_params="$codecov_params --c $1"
elif [[ "$1" == "--upload_build" ]]
then
shift
codecov_params="$codecov_params --b $1"
else
echo "Unexpected param: $1"
exit 1
fi
shift
done
rm -f coverage/all.dvcr
echo "Merging reports..."
$DOTCOVER merge -Source=$(echo coverage/*.dvcr | sed 's/ /;/g') -Output=coverage/all.dvcr ""
echo "Generating detailed xml report..."
$DOTCOVER report -Source=coverage/all.dvcr -Output=coverage/coverage.xml -ReportType=DetailedXML ""
# We assume the tools solution has already been restored as part of the build
echo "Filtering xml report..."
dotnet run -p tools/Google.Cloud.Tools.TrimCoverageReport/Google.Cloud.Tools.TrimCoverageReport.csproj -- coverage/coverage.xml coverage/coverage-filtered.xml
echo "Running ReportGenerator to create an html report..."
$REPORTGENERATOR \
-reports:coverage/coverage-filtered.xml \
-targetdir:coverage/report \
-verbosity:Error
if [[ "$upload_report" = true ]]
then
# -y option to confirm all prompts.
# --no-progress to avoid our log file being spammed with download progress
choco install codecov -y --no-progress
# Assume we've created the coverage file by this point. If we haven't, there should already have been an error.
# Pass whatever parameters we recieved.
codecov -f "coverage/coverage-filtered.xml" $codecov_params
fi