Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·101 lines (88 loc) · 2.78 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·101 lines (88 loc) · 2.78 KB
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
#!/usr/bin/env bash
set -euo pipefail
SOLUTION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUT_DIR="$SOLUTION_DIR/out"
SOLUTION_FILE="${BUILD_SOLUTION_FILE:-Solution.NoMobile.slnx}"
VERSION_ARGS=()
if [ -n "${BUILD_VERSION:-}" ]; then
VERSION_ARGS=(-p:Version="$BUILD_VERSION")
fi
COMMON_ARGS=()
TEST_CONSOLE_LOGGER=()
QUIET=0
if [ "${BUILD_VERBOSITY:-}" = "quiet" ]; then
COMMON_ARGS+=(-v quiet --tl:on)
TEST_CONSOLE_LOGGER=(--logger "console;verbosity=quiet")
QUIET=1
else
COMMON_ARGS+=(--tl:auto)
fi
build() {
dotnet build "$SOLUTION_DIR/$SOLUTION_FILE" -c Release --no-incremental \
"${COMMON_ARGS[@]}" "${VERSION_ARGS[@]}"
[ "$QUIET" = 1 ] && echo "Build Succeeded"
return 0
}
test() {
rm -rf "$OUT_DIR/test-results"
local test_plugins_dir="$OUT_DIR/test/plugins"
rm -rf "$test_plugins_dir"
mkdir -p "$test_plugins_dir"
for proj in "$SOLUTION_DIR"/src/plugins/*/*/*.csproj; do
case "$proj" in */src/plugins/shared/*) continue ;; esac
local name
name="$(basename "$(dirname "$proj")")"
dotnet publish "$proj" -c Release --no-build \
"${COMMON_ARGS[@]}" -o "$test_plugins_dir/$name"
done
dotnet test "$SOLUTION_DIR/$SOLUTION_FILE" -c Release --no-build \
"${COMMON_ARGS[@]}" "${TEST_CONSOLE_LOGGER[@]}" \
--collect:"XPlat Code Coverage" \
--settings "$SOLUTION_DIR/coverage.runsettings" \
--logger "trx;LogFileName=results.trx" \
--results-directory "$OUT_DIR/test-results"
local reports
reports=$(find "$OUT_DIR/test-results" -name "coverage.cobertura.xml" -printf "%p;" 2>/dev/null)
if [ -n "$reports" ]; then
dotnet tool restore > /dev/null
dotnet tool run reportgenerator \
-reports:"${reports%;}" \
-targetdir:"$OUT_DIR/test-results/coverage" \
-reporttypes:Cobertura\;TextSummary \
> /dev/null
[ "$QUIET" = 1 ] && echo " $OUT_DIR/test-results/coverage/Summary.txt"
[ "$QUIET" = 1 ] || cat "$OUT_DIR/test-results/coverage/Summary.txt"
fi
[ "$QUIET" = 1 ] && echo "Test Succeeded"
return 0
}
if [ $# -eq 0 ]; then
echo "Usage: $0 {build|test} [...]"
echo ""
echo "Environment:"
echo " BUILD_VERSION Version string (default: from Directory.Build.props)"
echo " BUILD_VERBOSITY 'quiet' suppresses output except warnings and errors"
echo " BUILD_SOLUTION_FILE Solution file to build (default: Solution.slnx)"
echo ""
echo "For publishing and packaging, see scripts/publish/*.sh"
exit 1
fi
declare -A requested=()
for cmd in "$@"; do
case "$cmd" in
build|test) requested[$cmd]=1 ;;
*)
echo "Error: unknown command '$cmd'"
echo "Usage: $0 {build|test} [...]"
exit 1
;;
esac
done
for cmd in build test; do
if [ -n "${requested[$cmd]:-}" ]; then
case "$cmd" in
build) build ;;
test) test ;;
esac
fi
done