Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the build shell script and use it for myget (#335)
myget supports git-bash as well, so we can use a single build file. This now packs the projects as well building and testing, and tests the net451 configuration with dotnet test when on Windows. Two environment variables (PrereleaseTag and NoVersionSuffix) control what package version is built.
- Loading branch information
Showing
4 changed files
with
78 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ install: | |
- sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121 | ||
|
||
script: | ||
- ./travis.sh | ||
- ./build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ $(dotnet --info | grep "OS Platform" | grep -c Windows) -ne 0 ] | ||
then | ||
OS=Windows | ||
else | ||
OS=Linux | ||
fi | ||
|
||
|
||
CONFIG=Release | ||
# Arguments to use for all build-related commands (build, pack) | ||
DOTNET_BUILD_ARGS="-c $CONFIG" | ||
# Arguments to use for test-related commands (test) | ||
DOTNET_TEST_ARGS="$DOTNET_BUILD_ARGS" | ||
|
||
# Three options: | ||
# - No environment variables: make sure it's not for release | ||
# - PrereleaseTag set: use that | ||
# - NoVersionSuffix set: use no suffix; build as per project.json | ||
if [ -n "$PrereleaseTag" ] | ||
then | ||
DOTNET_BUILD_ARGS="$DOTNET_BUILD_ARGS --version-suffix $PrereleaseTag" | ||
elif [ -z "$NoVersionSuffix" ] | ||
then | ||
DOTNET_BUILD_ARGS="$DOTNET_BUILD_ARGS --version-suffix not-for-release" | ||
fi | ||
|
||
echo CLI args: $DOTNET_BUILD_ARGS | ||
|
||
echo Building | ||
|
||
cd tools | ||
dotnet restore | ||
dotnet build $DOTNET_BUILD_ARGS `find . -mindepth 1 -maxdepth 1 -name 'Google*' -type d ` | ||
cd .. | ||
|
||
cd apis | ||
dotnet restore | ||
dotnet build $DOTNET_BUILD_ARGS `find * -mindepth 1 -maxdepth 1 -name 'Google*' -type d` | ||
|
||
# TODO: Tests. We need to: | ||
# - Run Mono for all tests | ||
# - Run dotnet test for all netcore-supporting tests. | ||
|
||
echo Testing | ||
|
||
for testdir in */*.Tests | ||
do | ||
if [ $OS == "Windows" ] | ||
then | ||
dotnet test -f net451 $DOTNET_TEST_ARGS $testdir | ||
else | ||
api=`echo $testdir | cut -d/ -f1` | ||
project=`echo $testdir | cut -d/ -f2` | ||
bin=$testdir/bin/$CONFIG/net451/ubuntu.14.04-x64 | ||
mono $bin/dotnet-test-xunit.exe $bin/$project.dll | ||
fi | ||
done | ||
|
||
# TODO: Work out all projects we can test with dotnet test | ||
# automatically | ||
|
||
dotnet test -f netcoreapp1.0 $DOTNET_TEST_ARGS Google.Storage.V1/Google.Storage.V1.Tests | ||
dotnet test -f netcoreapp1.0 $DOTNET_TEST_ARGS Google.Bigquery.V2/Google.Bigquery.V2.Tests | ||
|
||
echo Packing | ||
|
||
# Assume each packagable project contains something like "version": "1.0.0-*" | ||
# and no other projects do. | ||
for package in `find . -name project.json | xargs grep -le 'version.*-\*' | sed 's/\/project.json//g'` | ||
do | ||
dotnet pack $DOTNET_BUILD_ARGS $package | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1 @@ | ||
@echo on | ||
|
||
dotnet restore || goto error | ||
|
||
for /D %%P in (src\Google*) do ( | ||
echo Building %%P | ||
dotnet build --version-suffix %PrereleaseTag% --configuration %Configuration% %%P || goto error | ||
) | ||
|
||
for /D %%P in (snippets\Google*) do ( | ||
echo Building %%P | ||
dotnet build --configuration %Configuration% %%P || goto error | ||
) | ||
|
||
REM We don't build/run the integration tests | ||
for /D %%P in (test\Google*.Tests) do ( | ||
echo Testing %%P | ||
dotnet test --configuration %Configuration% %%P || goto error | ||
) | ||
|
||
for /D %%P in (src\Google*) do ( | ||
echo Packing %%P | ||
dotnet pack --version-suffix %PrereleaseTag% --configuration %Configuration% %%P || goto error | ||
) | ||
|
||
echo Done! | ||
|
||
goto end | ||
|
||
:error | ||
echo Build failed due to error. | ||
exit /b 1 | ||
|
||
:end | ||
bash build.sh |