From 9959d7cfbc6dbf17a8aaac62f3b1e9f2acf63b39 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 2 Jun 2019 00:18:21 +0800 Subject: [PATCH] =?UTF-8?q?doc(test):=20=E9=87=8D=E6=9E=84Appveyor?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appveyor.test.ps1 | 34 ++++++++++++++++++++++++++++------ appveyor.yml | 13 +++++++++++-- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/appveyor.test.ps1 b/appveyor.test.ps1 index 425b122c..a81b0beb 100644 --- a/appveyor.test.ps1 +++ b/appveyor.test.ps1 @@ -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)""" diff --git a/appveyor.yml b/appveyor.yml index 0b91b736..18cb00bc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: >-