diff --git a/BootstrapAdmin.sln b/BootstrapAdmin.sln index 21168b09..a491a0dd 100644 --- a/BootstrapAdmin.sln +++ b/BootstrapAdmin.sln @@ -70,6 +70,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D8F90830-15D0-4031-94EE-6E5D93CB734A}" ProjectSection(SolutionItems) = preProject appveyor.build.ps1 = appveyor.build.ps1 + appveyor.install.ps1 = appveyor.install.ps1 appveyor.test.ps1 = appveyor.test.ps1 appveyor.yml = appveyor.yml EndProjectSection @@ -110,6 +111,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ci", "ci", "{5F732D4E-133B-4DA6-811B-C369CDC3FB89}" ProjectSection(SolutionItems) = preProject appveyor.build.ps1 = appveyor.build.ps1 + appveyor.install.ps1 = appveyor.install.ps1 appveyor.test.ps1 = appveyor.test.ps1 appveyor.yml = appveyor.yml EndProjectSection diff --git a/appveyor.install.ps1 b/appveyor.install.ps1 new file mode 100644 index 00000000..0e177137 --- /dev/null +++ b/appveyor.install.ps1 @@ -0,0 +1,13 @@ +# 显示 dotnet version +write-host "dotnet --version" -ForegroundColor Cyan +dotnet --version + +# 注意 my.ini 文件行结束符必须为CRLF + +$iniPath="C:\Program Files\MySQL\MySQL Server 5.7\my.ini" +write-host "copy $($env:appveyor_build_folder)\db\MySQL\my.ini -> $iniPath" -ForegroundColor Cyan +xcopy "$($env:appveyor_build_folder)\db\MySQL\my.ini" $iniPath /y +$newText = ([System.IO.File]::ReadAllText($iniPath)).Replace("\n", "\r\n") +[System.IO.File]::WriteAllText($iniPath, $newText) + +write-host "starting database services ..." -ForegroundColor Cyan diff --git a/appveyor.test.ps1 b/appveyor.test.ps1 index 72e8251b..97b11f0a 100644 --- a/appveyor.test.ps1 +++ b/appveyor.test.ps1 @@ -8,21 +8,21 @@ sqlcmd -S "$sqlInstance" -U sa -P Password12! -i "$sqlFile" -i "$initFile" -o "$outFile" - #write-host "init mysql database..." -ForegroundColor Cyan - #$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 + write-host "init mysql database..." -ForegroundColor Cyan + $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 - #$startPath = "$($env:appveyor_build_folder)\db\MySQL" - #$para = ' -hlocalhost -uroot -DBootstrapAdmin < ' - #$sqlFile = join-path $startPath "Install.sql" - #$cmd = $mysql + $para + $sqlFile - #cmd.exe /c $cmd + $startPath = "$($env:appveyor_build_folder)\db\MySQL" + $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 + $initFile = join-path $startPath "InitData.sql" + $cmd = $mysql + $para + $initFile + cmd.exe /c $cmd write-host "init mongodb data..." -ForegroundColor Cyan $initFolder = "$($env:appveyor_build_folder)\db\MongoDB" @@ -38,7 +38,7 @@ function runUnitTest() { write-host "dotnet test test\UnitTest" -ForegroundColor Cyan - dotnet test "test\UnitTest" --filter="FullyQualifiedName!~MySql" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap.Admin*]*%2c[Bootstrap.DataAccess*]*" /p:Exclude="[*]*Program%2c[*]*Startup%2c[Bootstrap.DataAccess*]*AutoDB*%2c[Bootstrap.DataAccess]*WeChatHelper" /p:ExcludeByFile="**/SMSExtensions.cs%2c**/Helper/OAuthHelper.cs%2c**/Extensions/CloudLoggerExtensions.cs%2c**/Extensions/AutoGenerateDatabaseExtensions.cs%2c**/Api/HealthsController.cs%2c**/Pages/**%2c**/DBLogTask.cs%2c**/AutoDbHelper.cs" /p:CoverletOutput=..\..\ + dotnet test "test\UnitTest" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap.Admin*]*%2c[Bootstrap.DataAccess*]*" /p:Exclude="[*]*Program%2c[*]*Startup%2c[Bootstrap.DataAccess*]*AutoDB*%2c[Bootstrap.DataAccess]*WeChatHelper" /p:ExcludeByFile="**/SMSExtensions.cs%2c**/Helper/OAuthHelper.cs%2c**/Extensions/CloudLoggerExtensions.cs%2c**/Extensions/AutoGenerateDatabaseExtensions.cs%2c**/Api/HealthsController.cs%2c**/Pages/**%2c**/DBLogTask.cs%2c**/AutoDbHelper.cs" /p:CoverletOutput=..\..\ } function installCoveralls() { @@ -53,6 +53,11 @@ function reportCoveralls() { .\tools\csmacnz.Coveralls.exe --opencover -i coverage.opencover.xml --useRelativePaths } +function installCodecov { + write-host "install Codecov.Tool tools" -ForegroundColor Cyan + dotnet tool install Codecov.Tool --tool-path ".\tools" +} + function reportCodecov() { Set-AppveyorBuildVariable CODECOV_TOKEN $($env:CODECOV_TOKEN) Set-AppveyorBuildVariable CI $($env:CI) @@ -60,9 +65,6 @@ function reportCodecov() { $coverageFile = Test-Path coverage.opencover.xml if ($coverageFile) { - write-host "install Codecov.Tool tools" -ForegroundColor Cyan - dotnet tool install Codecov.Tool --tool-path ".\tools" - write-host "report UnitTest with Codecov" -ForegroundColor Cyan .\tools\codecov -f coverage.opencover.xml } @@ -72,6 +74,7 @@ $branch = $($env:APPVEYOR_REPO_BRANCH) if ($branch -ne "dev") { installDB installCoveralls + installCodecov runUnitTest reportCoveralls reportCodecov diff --git a/appveyor.yml b/appveyor.yml index d14e408e..153800ff 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,14 +21,11 @@ environment: secure: +22PuAn5seq4bbCVCly8zDFuyEV3m2NjW3QuM0+2gm4c8akwicNFmv2T/ZGd0Jpd services: - mssql2017 +- mysql - mongodb install: - ps: >- - #copy my.ini into mysql folder - - dotnet --version - - #xcopy "$($env:appveyor_build_folder)\db\MySQL\my.ini" "C:\Program Files\MySQL\MySQL Server 5.7" /y + .\appveyor.install.ps1 build_script: - ps: >- .\appveyor.build.ps1 diff --git a/db/MySQL/my.ini b/db/MySQL/my.ini index 9f4ad7e2..777c2b0d 100644 --- a/db/MySQL/my.ini +++ b/db/MySQL/my.ini @@ -1,9 +1,10 @@ -[client] +[mysqld] +basedir=C:\\Program Files\\MySQL\\MySQL Server 5.7 +datadir=C:\\Program Files\\MySQL\\MySQL Server 5.7\\data +character-set-server=utf8 + +[client] default-character-set=utf8 -[mysqld] -charcater_set_client=utf8 -character_set_connection=utf8 -character_set_results=utf8 -character_set_server=utf8 -character_set_database=utf8 +[mysql] +default-character-set=utf8 diff --git a/test/UnitTest/appsettings.appveyor.json b/test/UnitTest/appsettings.appveyor.json index c425e0dd..95d5a93d 100644 --- a/test/UnitTest/appsettings.appveyor.json +++ b/test/UnitTest/appsettings.appveyor.json @@ -18,7 +18,7 @@ "Enabled": true, "ProviderName": "MySql", "ConnectionStrings": { - "ba": "Server=localhost;Database=BootstrapAdmin;Uid=root;Pwd=Password12!;SslMode=none;" + "ba": "Server=localhost;Database=BootstrapAdmin;Uid=root;Pwd=Password12!;SslMode=none;charset=utf8;" } }, { diff --git a/test/UnitTest/appsettings.json b/test/UnitTest/appsettings.json index ea2a423c..32d0183b 100644 --- a/test/UnitTest/appsettings.json +++ b/test/UnitTest/appsettings.json @@ -37,7 +37,7 @@ "Enabled": false, "ProviderName": "MySql", "ConnectionStrings": { - "ba": "Server=localhost;Database=UnitTest;Uid=argozhang;Pwd=argo@163.com;SslMode=none;" + "ba": "Server=localhost;Database=UnitTest;Uid=root;Pwd=argo@163.com;SslMode=none;charset=utf8;" } }, {