doc(test): 重构Appveyor单元测试命令

This commit is contained in:
Argo Zhang 2019-06-02 00:18:21 +08:00
parent c73db6cc17
commit 9959d7cfbc
2 changed files with 39 additions and 8 deletions

View File

@ -1,4 +1,4 @@
if ("$($env:APPVEYOR_REPO_BRANCH)" -eq "master") {
function installDB() {
write-host "init sqlserver database..." -ForegroundColor Cyan
$startPath = "$($env:appveyor_build_folder)\DatabaseScripts\SqlServer"
$sqlInstance = "(local)\SQL2014"
@ -34,14 +34,36 @@ if ("$($env:APPVEYOR_REPO_BRANCH)" -eq "master") {
iex "& $cmd"
cd $($env:appveyor_build_folder)
}
function coverallUnitTest() {
write-host "install coveralls.net tools" -ForegroundColor Cyan
dotnet tool install coveralls.net --version 1.0.0 --tool-path "./tools"
write-host "dotnet test UnitTest with Coveralls" -ForegroundColor Cyan
dotnet test UnitTest --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap*]*" /p:ExcludeByFile="../Bootstrap.Admin/Program.cs%2c../Bootstrap.Admin/Startup.cs%2c../Bootstrap.Admin/HttpHeaderOperation.cs" /p:CoverletOutput=../
cmd.exe /c ".\tools\csmacnz.Coveralls.exe --opencover -i coverage.opencover.xml --useRelativePaths"
}
if ("$($env:APPVEYOR_REPO_BRANCH)" -eq "master") {
installDB
if ("$($env:APPVEYOR_REPO_PROVIDER)" -eq "gitHub") {
write-host "install coveralls.net tools" -ForegroundColor Cyan
dotnet tool install coveralls.net --version 1.0.0 --tool-path "./tools"
coverallUnitTest
}
elseif ("$($env:APPVEYOR_REPO_PROVIDER)" -eq "gitLab") {
coverallUnitTest
write-host "dotnet test UnitTest with Coveralls" -ForegroundColor Cyan
dotnet test UnitTest --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap*]*" /p:ExcludeByFile="../Bootstrap.Admin/Program.cs%2c../Bootstrap.Admin/Startup.cs%2c../Bootstrap.Admin/HttpHeaderOperation.cs" /p:CoverletOutput=../
cmd.exe /c ".\tools\csmacnz.Coveralls.exe --opencover -i coverage.opencover.xml --useRelativePaths"
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
}
cmd.exe /c "$codecovCmd -f ""coverage.opencover.xml"""
}
else {
write-warning "Coveralls has been skipped because current provider is ""$($env:APPVEYOR_REPO_PROVIDER)"""

View File

@ -6,11 +6,18 @@ branches:
image: Visual Studio 2017
clone_depth: 1
init:
- ps: dotnet --version
- ps: git version
environment:
Appveyor: true
COVERALLS_REPO_TOKEN:
secure: 5L1b6XqSNTOfU1iZrARo5eUOi1HOleVO3VDCW0pr6yaspgkC5jxL+gBDK0OEY8EI
COVERALLS_REPO_TOKEN_GITLAB:
secure: yPxFQv4kSWtZ7Vvs70bIXDx9IOEEJ9utI3UyZsJGU7rt63gZnHOry0kt9DBMWcwV
CODECOV_TOKEN:
secure: 6rKKLXCmy3HZBxW5SjoO4Ox7G09FC0NJgGnvukWkYyJ2rx1GCzu4JvmLin69SHRz
CODECOV_TOKEN_GITLAB:
secure: +22PuAn5seq4bbCVCly8zDFuyEV3m2NjW3QuM0+2gm4c8akwicNFmv2T/ZGd0Jpd
cache: C:\ProgramData\chocolatey\lib\codecov\tools
services:
- mssql2014
- mysql
@ -18,7 +25,9 @@ services:
install:
- ps: >-
#copy my.ini into mysql folder
dotnet --version
xcopy "$($env:appveyor_build_folder)\DatabaseScripts\MySQL\my.ini" "C:\Program Files\MySQL\MySQL Server 5.7" /y
build_script:
- ps: >-