Skip to content

Commit

Permalink
fix build script
Browse files Browse the repository at this point in the history
  • Loading branch information
lvermeulen committed Feb 8, 2018
1 parent 443b846 commit 9083e1a
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 75 deletions.
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ branches:
- master
pull_requests:
do_not_increment_build_number: true
image: Visual Studio 2017
environment:
COVERALLS_REPO_TOKEN:
secure: kDcf0mhCCCONpQVpeaA6M5qIuuLggG7lfv1tCMiZCzUmdjtmoIcwFaRQRf00bIdn
Expand All @@ -15,10 +16,10 @@ test_script:
if ($true)
{
.\build\test.ps1
.\build\cover.ps1 "$env:COVERALLS_REPO_TOKEN" "$env:COVER_FILTER"
#.\build\cover.ps1 "$env:COVERALLS_REPO_TOKEN" "$env:COVER_FILTER"
}
artifacts:
- path: '**\*.nupkg'
- path: '.\artifacts\*.nupkg'
deploy:
- provider: NuGet
api_key:
Expand Down
36 changes: 18 additions & 18 deletions build/build.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
param (
[string]$BuildVersionNumber=$(throw "-BuildVersionNumber is required."),
[string]$TagVersionNumber
[string]$BuildVersionNumber=$(throw "-BuildVersionNumber is required."),
[string]$TagVersionNumber
)

# set version number in package.json
Get-ChildItem -Path $PSScriptRoot\..\src -Filter *.csproj -Recurse | ForEach-Object{
$ProjectPath = $_.FullName
if ($TagVersionNumber){
(gc -Path $ProjectPath) `
-replace "(?<=`"version`":\s`")[.\w-]*(?=`",)", "$TagVersionNumber" |
sc -Path $ProjectPath -Encoding UTF8
& dotnet restore --no-cache

foreach ($src in ls $PSScriptRoot\..\src/*) {
Push-Location $src

Write-Output "build: Building & packaging project in $src"

if ($TagVersionNumber -ne $null) {
$version = $TagVersionNumber
}
else{
(gc -Path $ProjectPath) `
-replace "(?<=`"version`":\s`")[.\w-]*(?=`",)", "$BuildVersionNumber" |
sc -Path $ProjectPath -Encoding UTF8
else {
$version = $BuildVersionNumber
}
}

# run restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot\..\src -Filter *.csproj -Recurse | ForEach-Object { & dotnet restore $_.FullName 2>1 }
& dotnet build -c Release
& dotnet pack -c Release --include-symbols -o ..\..\artifacts --no-build /p:PackageVersion=$version
if($LASTEXITCODE -ne 0) { exit 1 }

# run pack on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot\..\src -Filter *.csproj -Recurse | ForEach-Object { & dotnet pack $_.FullName -c Release 2>1 }
Pop-Location
}
110 changes: 55 additions & 55 deletions build/cover.ps1
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
param (
[string]$CoverallsRepoToken=$(throw "-CoverallsRepoToken is required."),
[string]$CoverFilter=$(throw "-CoverFilter is required.")
)
#param (
# [string]$CoverallsRepoToken=$(throw "-CoverallsRepoToken is required."),
# [string]$CoverFilter=$(throw "-CoverFilter is required.")
#)

Write-Output "Starting code coverage with filter: $CoverFilter"
#Write-Output "Starting code coverage with filter: $CoverFilter"

$alwaysFilter = "-[xunit*]* -[Microsoft*]* -[dotnet*]* -[NuGet*]* -[Newtonsoft*]* -[Consul*]* -[Nancy*]* -[AngleSharp]* -[csc]* -[Anonymously*]*"
$filter = "$CoverFilter $alwaysFilter"
#$alwaysFilter = "-[xunit*]* -[Microsoft*]* -[dotnet*]* -[NuGet*]* -[Newtonsoft*]* -[Consul*]* -[Nancy*]* -[AngleSharp]* -[csc]* -[Anonymously*]*"
#$filter = "$CoverFilter $alwaysFilter"

$packagesPath = $env:USERPROFILE + "\.nuget\packages"
$opencoverPath = $packagesPath + "\OpenCover\4.6.519\tools\OpenCover.Console.exe"
$coverallsPath = $packagesPath + "\coveralls.io\1.3.4\tools\coveralls.net.exe"
$tempPath = "c:\codecoverage"
$tempCoveragePath = $tempPath + "\coverage\"
$tempCoverageFileName = $tempCoveragePath + "coverage.xml"
#$packagesPath = $env:USERPROFILE + "\.nuget\packages"
#$opencoverPath = $packagesPath + "\OpenCover\4.6.519\tools\OpenCover.Console.exe"
#$coverallsPath = $packagesPath + "\coveralls.io\1.3.4\tools\coveralls.net.exe"
#$tempPath = "c:\codecoverage"
#$tempCoveragePath = $tempPath + "\coverage\"
#$tempCoverageFileName = $tempCoveragePath + "coverage.xml"

# create temp path
if (-not (test-path $tempPath) ) {
mkdir $tempPath | Out-Null
}
## create temp path
#if (-not (test-path $tempPath) ) {
# mkdir $tempPath | Out-Null
#}

# run opencover
Get-ChildItem -Path $PSScriptRoot\..\test -Filter *.csproj -Recurse | ForEach-Object {
$path = "$tempPath\$($_.Directory.BaseName)"
if (-not (test-path $path) ) {
mkdir $path | Out-Null
}
## run opencover
#Get-ChildItem -Path $PSScriptRoot\..\test -Filter *.csproj -Recurse | ForEach-Object {
# $path = "$tempPath\$($_.Directory.BaseName)"
# if (-not (test-path $path) ) {
# mkdir $path | Out-Null
# }

$tempBinPath = $path + "\bin\"
$targetArgs = "`"test -o $tempBinPath $($_.FullName)`""
# $tempBinPath = $path + "\bin\"
# $targetArgs = "`"test -o $tempBinPath $($_.FullName)`""

if (-not (test-path $tempBinPath) ) {
mkdir $tempBinPath | Out-Null
}
# if (-not (test-path $tempBinPath) ) {
# mkdir $tempBinPath | Out-Null
# }

if (-not (test-path $tempCoveragePath) ) {
mkdir $tempCoveragePath | Out-Null
}
# if (-not (test-path $tempCoveragePath) ) {
# mkdir $tempCoveragePath | Out-Null
# }

& $opencoverPath `
-register:user `
-target:"dotnet.exe" `
-targetargs:$targetArgs `
-searchdirs:$tempBinPath `
-output:$tempCoverageFileName `
-mergebyhash `
-mergeoutput `
-skipautoprops `
-returntargetcode `
-filter:$filter `
-hideskipped:Filter `
-oldstyle
}
# & $opencoverPath `
# -register:user `
# -target:"dotnet.exe" `
# -targetargs:$targetArgs `
# -searchdirs:$tempBinPath `
# -output:$tempCoverageFileName `
# -mergebyhash `
# -mergeoutput `
# -skipautoprops `
# -returntargetcode `
# -filter:$filter `
# -hideskipped:Filter `
# -oldstyle
#}

# upload to coveralls.io
Write-Output "Sending code coverage results to coveralls.io"
## upload to coveralls.io
#Write-Output "Sending code coverage results to coveralls.io"

& $coverallsPath `
--opencover $tempCoverageFileName `
--full-sources `
--repo-token $CoverallsRepoToken
#& $coverallsPath `
# --opencover $tempCoverageFileName `
# --full-sources `
# --repo-token $CoverallsRepoToken

7z a codecoverage.zip $tempCoverageFileName
Push-AppveyorArtifact codecoverage.zip
#7z a codecoverage.zip $tempCoverageFileName
#Push-AppveyorArtifact codecoverage.zip

pip install codecov
codecov -f $tempCoverageFileName -X gcov
#pip install codecov
#codecov -f $tempCoverageFileName -X gcov


68 changes: 68 additions & 0 deletions build/coverlocal.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Write-Host "PSScriptRoot: " $PSScriptRoot
$CoverFilter='+[Flurl.Http.Xml*]* -[*]*.Logging.* -[*Tests]*'

Write-Output "Starting code coverage with filter: $CoverFilter"

$alwaysFilter = "-[xunit*]* -[Microsoft*]* -[dotnet*]* -[NuGet*]* -[Newtonsoft*]* -[Consul*]* -[Nancy*]* -[AngleSharp]* -[csc]* -[Anonymously*]*"
$filter = "$CoverFilter $alwaysFilter"

$packagesPath = $env:USERPROFILE + "\.nuget\packages"
$opencoverPath = $packagesPath + "\OpenCover\4.6.519\tools\OpenCover.Console.exe"
$coverallsPath = $packagesPath + "\coveralls.io\1.3.4\tools\coveralls.net.exe"
$tempPath = "c:\codecoverage"
$tempCoveragePath = $tempPath + "\coverage\"
$tempCoverageFileName = $tempCoveragePath + "coverage.xml"

# create temp path
if (-not (test-path $tempPath) ) {
mkdir $tempPath | Out-Null
}

# run opencover
Get-ChildItem -Path $PSScriptRoot\..\test -Filter *.csproj -Recurse | ForEach-Object {
$path = "$tempPath\$($_.Directory.BaseName)"
if (-not (test-path $path) ) {
mkdir $path | Out-Null
}

$tempBinPath = $path + "\bin\"
$targetArgs = "`"test -o $tempBinPath $($_.FullName)`""

if (-not (test-path $tempBinPath) ) {
mkdir $tempBinPath | Out-Null
}

if (-not (test-path $tempCoveragePath) ) {
mkdir $tempCoveragePath | Out-Null
}

& $opencoverPath `
-register:user `
-target:"dotnet.exe" `
-targetargs:$targetArgs `
-searchdirs:$tempBinPath `
-output:$tempCoverageFileName `
-mergebyhash `
-mergeoutput `
-skipautoprops `
-returntargetcode `
-filter:$filter `
-hideskipped:Filter `
-oldstyle
}
<#
# upload to coveralls.io
Write-Output "Sending code coverage results to coveralls.io"
& $coverallsPath `
--opencover $tempCoverageFileName `
--full-sources `
--repo-token $CoverallsRepoToken
7z a codecoverage.zip $tempCoverageFileName
Push-AppveyorArtifact codecoverage.zip
pip install codecov
codecov -f $tempCoverageFileName -X gcov
#>

0 comments on commit 9083e1a

Please sign in to comment.