-
Notifications
You must be signed in to change notification settings - Fork 49
/
build.ps1
99 lines (76 loc) · 3.75 KB
/
build.ps1
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
# Taken from psake https://github.com/psake/psake
# Taken from psake https://github.com/psake/psake
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
exec { & dotnet restore }
$suffix = "-ci-local"
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = "$($suffix)-$($commitHash)"
Write-Output "build: Version suffix is $buildSuffix"
exec { & dotnet build Esquio.sln -c Release --version-suffix=$buildSuffix -v q /nologo }
Write-Output "Running unit tests"
try {
Push-Location -Path .\tests\UnitTests
exec { & dotnet test}
} finally {
Pop-Location
}
Write-Output "Starting docker containers"
exec { & docker-compose -f build\docker-compose-infrastructure.yml up -d }
Write-Output "Running functional tests SqlServer"
try {
$env:Data__Store='SqlServer'
$env:Data__ConnectionString='Server=tcp:localhost,5433;Initial Catalog=Esquio.UI.Tests;User Id=sa;Password=Password12!;Encrypt=False'
Push-Location -Path .\tests\FunctionalTests
exec { & dotnet test}
} finally {
Pop-Location
}
Write-Output "Running functional tests Postgress"
try {
$env:Data__Store='NpgSql'
$env:Data__ConnectionString='Host=localhost;Port=5434;Database=Esquio.UI.Tests;User Id=postgres;Password=Password12!'
Push-Location -Path .\tests\FunctionalTests
exec { & dotnet test}
} finally {
Pop-Location
}
Write-Output "Running functional tests MySql"
try {
$env:Data__Store='MySql'
$env:Data__ConnectionString='Server=127.0.0.1;Database=Esquio.UI.Tests;Uid=root;Pwd=Password12!'
Push-Location -Path .\tests\FunctionalTests
exec { & dotnet test}
} finally {
Pop-Location
}
Write-Output "Finalizing docker containers"
exec { & docker-compose -f build\docker-compose-infrastructure.yml down }
exec { & dotnet pack .\src\Esquio\Esquio.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\src\Esquio.AspNetCore\Esquio.AspNetCore.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\src\Esquio.Configuration.Store\Esquio.Configuration.Store.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\src\Esquio.Http.Store\Esquio.Http.Store.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\src\Esquio.AspNetCore.ApplicationInsightProcessor\Esquio.AspNetCore.ApplicationInsightProcessor.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\src\Esquio.Blazor.WebAssembly\Esquio.Blazor.WebAssembly.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\tools\Esquio.MiniProfiler\Esquio.MiniProfiler.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }
exec { & dotnet pack .\tools\Esquio.CliTool\Esquio.CliTool.csproj -c Release -o .\artifacts --include-symbols --no-build --version-suffix=$buildSuffix }