forked from googleapis/google-cloud-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·82 lines (68 loc) · 2.07 KB
/
build.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
75
76
77
78
79
80
81
82
#!/bin/bash
set -e
cd $(dirname $0)
# Disable automatic test reporting to AppVeyor.
# See https://github.com/GoogleCloudPlatform/google-cloud-dotnet/issues/1232
unset APPVEYOR_API_URL
# Make it easier to handle globbing that doesn't
# match anything, e.g. when looking for tests.
shopt -s nullglob
echo "$(date +%T) Building analyzers"
# First build the analyzers, for use in everything else.
dotnet publish -c Release -f netstandard1.3 tools/Google.Cloud.Tools.Analyzers
# Command line arguments are the APIs to build. Each argument
# should be the name of a directory, either relative to the location
# of this script, or under apis.
apis=()
runtests=true
while (( "$#" )); do
if [[ "$1" == "--notests" ]]
then
echo "Not running tests..."
runtests=false
elif [[ "$1" == "--diff" ]]
then
apis+=($(git diff master --name-only | grep apis/Google | cut -d/ -f 2 | uniq))
else
apis+=($1)
fi
shift
done
# Build and test the tools, but only on Windows
[[ "$OS" == "Windows_NT" ]] && tools="tools" || tools=""
if [ ${#apis[@]} -eq 0 ]
then
apis=(${tools} $(echo apis/Google.* | sed 's/apis\///g'))
fi
# First build, working out the test projects as we go.
> AllTests.txt
for api in ${apis[*]}
do
echo "$(date +%T) Building $api"
[[ -d "$api" ]] && apidir=$api || apidir=apis/$api
# Only build ASP.NET support on Windows
if [[ "$OS" != "Windows_NT" ]] && [[ "$apidir" == "apis/Google.Cloud.Diagnostics.AspNet" ]]
then
continue
fi
dotnet build -c Release $apidir
# On Linux, we don't have desktop .NET, so any projects which only
# support desktop .NET are going to be broken. Just don't add them.
for testproject in $apidir/*.Tests/*.csproj
do
if [[ "$OS" == "Windows_NT" ]] || ! grep -q -E '>net[0-9]+<' $testproject
then
echo "$testproject" >> AllTests.txt
fi
done
done
if [[ "$runtests" = true ]]
then
# Could use xargs, but this is more flexible
while read testproject
do
echo "$(date +%T) Testing $testproject"
dotnet test -c Release $testproject
done < AllTests.txt
fi
echo "$(date +%T) Build finished."