implement docker-based mono build and test running within teamcity ci
This commit is contained in:
Родитель
65d4c478e7
Коммит
ec81f7d805
|
@ -123,7 +123,7 @@ Target "CleanTests" <| fun _ ->
|
|||
//--------------------------------------------------------------------------------
|
||||
// Run tests
|
||||
|
||||
open XUnit2Helper
|
||||
open Fake.Testing
|
||||
Target "RunTests" <| fun _ ->
|
||||
let xunitTestAssemblies = !! "src/**/bin/Release/*.Tests.dll"
|
||||
|
||||
|
@ -132,7 +132,8 @@ Target "RunTests" <| fun _ ->
|
|||
let xunitToolPath = findToolInSubPath "xunit.console.exe" "src/packages/xunit.runner.console*/tools"
|
||||
printfn "Using XUnit runner: %s" xunitToolPath
|
||||
xUnit2
|
||||
(fun p -> { p with OutputDir = testOutput; ToolPath = xunitToolPath })
|
||||
(fun p -> { p with HtmlOutputPath = Some(testOutput @@ "xunit.html")
|
||||
ForceTeamCity = true })
|
||||
xunitTestAssemblies
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
|
|
2
build.sh
2
build.sh
|
@ -27,7 +27,7 @@ popd > /dev/null
|
|||
|
||||
mono $SCRIPT_PATH/src/.nuget/NuGet.exe update -self
|
||||
|
||||
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install FAKE -OutputDirectory $SCRIPT_PATH/src/packages -ExcludeVersion -Version 4.16.1
|
||||
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install FAKE -OutputDirectory $SCRIPT_PATH/src/packages -ExcludeVersion -Version 4.47.1
|
||||
|
||||
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install xunit.runner.console -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 2.0.0
|
||||
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install NUnit.Console -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 3.2.1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<configuration>
|
||||
<connectionStrings>
|
||||
<!--<add name="TestDb" connectionString="Server=localhost;Port=5432;Database=akka_persistence_tests;User Id=postgres;Password=postgres" providerName="Npgsql" />-->
|
||||
<add name="TestDb" connectionString="Server=localhost;Port=5432;Database=akka_persistence_tests;User Id=postgres;Password=admin" providerName="Npgsql" />
|
||||
<add name="TestDb" connectionString="Host=db;Port=5432;Database=postgres;Username=postgres;Password=postgres" providerName="Npgsql" />
|
||||
</connectionStrings>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.PostgreSql", "Akka.Persistence.PostgreSql\Akka.Persistence.PostgreSql.csproj", "{4B89227B-5AD1-4061-816F-570067C3727F}"
|
||||
EndProject
|
||||
|
@ -20,6 +20,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F945729D
|
|||
..\build.cmd = ..\build.cmd
|
||||
..\build.fsx = ..\build.fsx
|
||||
..\build.sh = ..\build.sh
|
||||
..\start_db_container.sh = ..\start_db_container.sh
|
||||
..\teardown_db_container.sh = ..\teardown_db_container.sh
|
||||
..\wait-for-it.sh = ..\wait-for-it.sh
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EEDB424A-4F28-4171-99D1-08C8DA880BE6}"
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
while getopts ":i:" opt; do
|
||||
case $opt in
|
||||
i)
|
||||
imageName=$OPTARG
|
||||
echo "imageName = $imageName"
|
||||
echo "Tearing down any existing containers with deployer=akkadotnet"
|
||||
runningContainers=$(docker ps -aq -f label=deployer=akkadotnet)
|
||||
if [ ${#runningContainers[@]} -gt 0 ]
|
||||
then
|
||||
for i in $runningContainers
|
||||
do
|
||||
if [ "$i" != "" ] # 1st query can return non-empty array with null element
|
||||
then
|
||||
docker stop $i
|
||||
docker rm $i
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo "Starting docker container with imageName=$imageName and name=akka-postgres-db"
|
||||
docker run -d --name=akka-postgres-db -l deployer=akkadotnet -e POSTGRES_PASSWORD=postgres $imageName
|
||||
;;
|
||||
:)
|
||||
echo "imageName (-i) argument required" >&2
|
||||
exit 1
|
||||
;;
|
||||
\?)
|
||||
echo "imageName (-i) flag is required" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Tearing down any existing containers with deployer=akkadotnet"
|
||||
runningContainers=$(docker ps -aq -f label=deployer=akkadotnet)
|
||||
if [ ${#runningContainers[@]} -gt 0 ]
|
||||
then
|
||||
for i in $runningContainers
|
||||
do
|
||||
if [ "$i" != "" ] # 1st query can return non-empty array with null element
|
||||
then
|
||||
docker stop $i
|
||||
docker rm $i
|
||||
fi
|
||||
done
|
||||
fi
|
|
@ -0,0 +1,155 @@
|
|||
#!/usr/bin/env bash
|
||||
# Use this script to test if a given TCP host/port are available
|
||||
# https://github.com/vishnubob/wait-for-it
|
||||
|
||||
cmdname=$(basename $0)
|
||||
|
||||
echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << USAGE >&2
|
||||
Usage:
|
||||
$cmdname host:port [-s] [-t timeout] [-- command args]
|
||||
-h HOST | --host=HOST Host or IP under test
|
||||
-p PORT | --port=PORT TCP port under test
|
||||
Alternatively, you specify the host and port as host:port
|
||||
-s | --strict Only execute subcommand if the test succeeds
|
||||
-q | --quiet Don't output any status messages
|
||||
-t TIMEOUT | --timeout=TIMEOUT
|
||||
Timeout in seconds, zero for no timeout
|
||||
-- COMMAND ARGS Execute command with args after the test finishes
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
wait_for()
|
||||
{
|
||||
if [[ $TIMEOUT -gt 0 ]]; then
|
||||
echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
|
||||
else
|
||||
echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
|
||||
fi
|
||||
start_ts=$(date +%s)
|
||||
while :
|
||||
do
|
||||
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
|
||||
result=$?
|
||||
if [[ $result -eq 0 ]]; then
|
||||
end_ts=$(date +%s)
|
||||
echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return $result
|
||||
}
|
||||
wait_for_wrapper()
|
||||
{
|
||||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
|
||||
if [[ $QUIET -eq 1 ]]; then
|
||||
timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
|
||||
else
|
||||
timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
|
||||
fi
|
||||
PID=$!
|
||||
trap "kill -INT -$PID" INT
|
||||
wait $PID
|
||||
RESULT=$?
|
||||
if [[ $RESULT -ne 0 ]]; then
|
||||
echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
|
||||
fi
|
||||
return $RESULT
|
||||
}
|
||||
# process arguments
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case "$1" in
|
||||
*:* )
|
||||
hostport=(${1//:/ })
|
||||
HOST=${hostport[0]}
|
||||
PORT=${hostport[1]}
|
||||
shift 1
|
||||
;;
|
||||
--child)
|
||||
CHILD=1
|
||||
shift 1
|
||||
;;
|
||||
-q | --quiet)
|
||||
QUIET=1
|
||||
shift 1
|
||||
;;
|
||||
-s | --strict)
|
||||
STRICT=1
|
||||
shift 1
|
||||
;;
|
||||
-h)
|
||||
HOST="$2"
|
||||
if [[ $HOST == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--host=*)
|
||||
HOST="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-p)
|
||||
PORT="$2"
|
||||
if [[ $PORT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--port=*)
|
||||
PORT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
-t)
|
||||
TIMEOUT="$2"
|
||||
if [[ $TIMEOUT == "" ]]; then break; fi
|
||||
shift 2
|
||||
;;
|
||||
--timeout=*)
|
||||
TIMEOUT="${1#*=}"
|
||||
shift 1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
CLI="$@"
|
||||
break
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
echoerr "Unknown argument: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ "$HOST" == "" || "$PORT" == "" ]]; then
|
||||
echoerr "Error: you need to provide a host and port to test."
|
||||
usage
|
||||
fi
|
||||
TIMEOUT=${TIMEOUT:-15}
|
||||
STRICT=${STRICT:-0}
|
||||
CHILD=${CHILD:-0}
|
||||
QUIET=${QUIET:-0}
|
||||
if [[ $CHILD -gt 0 ]]; then
|
||||
wait_for
|
||||
RESULT=$?
|
||||
exit $RESULT
|
||||
else
|
||||
if [[ $TIMEOUT -gt 0 ]]; then
|
||||
wait_for_wrapper
|
||||
RESULT=$?
|
||||
else
|
||||
wait_for
|
||||
RESULT=$?
|
||||
fi
|
||||
fi
|
||||
if [[ $CLI != "" ]]; then
|
||||
if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
|
||||
echoerr "$cmdname: strict mode, refusing to execute subprocess"
|
||||
exit $RESULT
|
||||
fi
|
||||
exec $CLI
|
||||
else
|
||||
exit $RESULT
|
||||
fi
|
Загрузка…
Ссылка в новой задаче