Skip to content

Commit

Permalink
Improve the build shell script and use it for myget (#335)
Browse files Browse the repository at this point in the history
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
jskeet committed Aug 24, 2016
1 parent 8b970f7 commit 7fffcf9
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -12,4 +12,4 @@ install:
- sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121

script:
- ./travis.sh
- ./build.sh
76 changes: 76 additions & 0 deletions build.sh
@@ -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
35 changes: 1 addition & 34 deletions myget.bat
@@ -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
30 changes: 0 additions & 30 deletions travis.sh

This file was deleted.

0 comments on commit 7fffcf9

Please sign in to comment.