2019-09-02 23:13:57 +08:00
|
|
|
|
function installDB() {
|
2019-05-29 17:54:58 +08:00
|
|
|
|
write-host "init sqlserver database..." -ForegroundColor Cyan
|
2019-09-02 23:13:57 +08:00
|
|
|
|
$startPath = "$($env:appveyor_build_folder)\scripts\SqlServer"
|
2019-05-28 09:43:49 +08:00
|
|
|
|
$sqlInstance = "(local)\SQL2014"
|
|
|
|
|
$outFile = join-path $startPath "output.log"
|
|
|
|
|
$sqlFile = join-path $startPath "Install.sql"
|
|
|
|
|
$initFile = join-path $startPath "InitData.sql"
|
|
|
|
|
|
|
|
|
|
sqlcmd -S "$sqlInstance" -U sa -P Password12! -i "$sqlFile" -i "$initFile" -o "$outFile"
|
|
|
|
|
|
2019-05-29 17:54:58 +08:00
|
|
|
|
write-host "init mysql database..." -ForegroundColor Cyan
|
2019-05-28 09:43:49 +08:00
|
|
|
|
$env:MYSQL_PWD="Password12!"
|
|
|
|
|
$mysql = '"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe"'
|
|
|
|
|
$cmd = $mysql + ' -e "create database BootstrapAdmin;" -uroot'
|
|
|
|
|
cmd.exe /c $cmd
|
|
|
|
|
|
2019-09-02 23:13:57 +08:00
|
|
|
|
$startPath = "$($env:appveyor_build_folder)\scripts\MySQL"
|
2019-05-28 09:43:49 +08:00
|
|
|
|
$para = ' -hlocalhost -uroot -DBootstrapAdmin < '
|
|
|
|
|
$sqlFile = join-path $startPath "Install.sql"
|
|
|
|
|
$cmd = $mysql + $para + $sqlFile
|
|
|
|
|
cmd.exe /c $cmd
|
|
|
|
|
|
|
|
|
|
$initFile = join-path $startPath "InitData.sql"
|
|
|
|
|
$cmd = $mysql + $para + $initFile
|
|
|
|
|
cmd.exe /c $cmd
|
|
|
|
|
|
2019-05-29 17:54:58 +08:00
|
|
|
|
write-host "init mongodb data..." -ForegroundColor Cyan
|
2019-09-02 23:13:57 +08:00
|
|
|
|
$initFolder = "$($env:appveyor_build_folder)\scripts\MongoDB"
|
2019-05-28 09:43:49 +08:00
|
|
|
|
cd $initFolder
|
|
|
|
|
|
|
|
|
|
cmd.exe /c "C:\mongodb\bin\mongo init.js"
|
|
|
|
|
|
|
|
|
|
$cmd = 'C:\mongodb\bin\mongo BootstrapAdmin --eval "printjson(db.getCollectionNames())"'
|
|
|
|
|
iex "& $cmd"
|
|
|
|
|
|
|
|
|
|
cd $($env:appveyor_build_folder)
|
2019-06-02 00:18:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-15 13:20:26 +08:00
|
|
|
|
function runUnitTest() {
|
2019-09-02 23:13:57 +08:00
|
|
|
|
write-host "dotnet test test\UnitTest" -ForegroundColor Cyan
|
|
|
|
|
dotnet test test\UnitTest /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap*]*" /p:ExcludeByFile="..\..\src\admin\Bootstrap.Admin\Program.cs%2c..\..\src\admin\Bootstrap.Admin\Startup.cs%2c..\..\src\admin\Bootstrap.Admin\HttpHeaderOperation.cs" /p:CoverletOutput=..\..\
|
2019-06-15 13:20:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 00:18:21 +08:00
|
|
|
|
function coverallUnitTest() {
|
|
|
|
|
write-host "install coveralls.net tools" -ForegroundColor Cyan
|
2019-09-02 23:13:57 +08:00
|
|
|
|
dotnet tool install coveralls.net --version 1.0.0 --tool-path ".\tools"
|
2019-06-15 13:20:26 +08:00
|
|
|
|
runUnitTest
|
|
|
|
|
write-host "report UnitTest with Coveralls" -ForegroundColor Cyan
|
2019-06-02 00:18:21 +08:00
|
|
|
|
cmd.exe /c ".\tools\csmacnz.Coveralls.exe --opencover -i coverage.opencover.xml --useRelativePaths"
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-15 13:20:26 +08:00
|
|
|
|
function codecovUnitTest() {
|
2019-06-04 10:27:13 +08:00
|
|
|
|
Set-AppveyorBuildVariable COVERALLS_REPO_TOKEN $($env:COVERALLS_REPO_TOKEN_GITLAB)
|
|
|
|
|
Set-AppveyorBuildVariable CODECOV_TOKEN $($env:CODECOV_TOKEN_GITLAB)
|
|
|
|
|
|
|
|
|
|
$codecovCmd = "C:\ProgramData\chocolatey\lib\codecov\tools\codecov.exe"
|
|
|
|
|
$codecov = Test-Path $codecovCmd
|
|
|
|
|
if (!$codecov) {
|
|
|
|
|
write-host "install codecov tools" -ForegroundColor Cyan
|
|
|
|
|
choco install codecov
|
|
|
|
|
}
|
2019-06-15 13:20:26 +08:00
|
|
|
|
$coverageFile = Test-Path coverage.opencover.xml
|
|
|
|
|
if (!$coverageFile) {
|
|
|
|
|
runUnitTest
|
|
|
|
|
}
|
|
|
|
|
write-host "report UnitTest with Codecov" -ForegroundColor Cyan
|
2019-06-04 10:27:13 +08:00
|
|
|
|
cmd.exe /c "$codecovCmd -f ""coverage.opencover.xml"""
|
|
|
|
|
}
|
2019-06-15 13:20:26 +08:00
|
|
|
|
|
|
|
|
|
installDB
|
|
|
|
|
coverallUnitTest
|
|
|
|
|
codecovUnitTest
|