Skip to content

Commit

Permalink
Build Ix with VSTS (#616)
Browse files Browse the repository at this point in the history
* build with vsts

* update xunit with vsts support

* add versioning files

* fix test run

* stamp full hash in assembly
  • Loading branch information
Oren Novotny authored Jun 19, 2018
1 parent 9a3def6 commit 29fa48f
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 60 deletions.
50 changes: 50 additions & 0 deletions .vsts.ix-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
trigger:
branches:
include:
- master
- rel/*
paths:
include:
- Ix.NET/Source/*
- .editorconfig
- .vsts.ix-ci.yml
- NuGet.Config

queue: Hosted VS2017

variables:
BuildConfiguration: Release
BuildPlatform: Any CPU

steps:
- task: BatchScript@1
inputs:
filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
arguments: -no_logo
modifyEnvironment: true
displayName: Setup Environment Variables

- task: DotNetCoreCLI@2
inputs:
command: build
projects: Ix.NET/Source/build/setversion.csproj
arguments: -c $(BuildConfiguration)
displayName: Set Version

- task: PowerShell@1
inputs:
scriptName: 'Ix.NET/Source/build-new.ps1'
workingFolder: 'Ix.NET/Source'
env:
VSTS_ACCESS_TOKEN: $(System.AccessToken)
SignClientUser: $(SignClientUser)
SignClientSecret: $(SignClientSecret)
COVERALLS_REPO_TOKEN: $(CoverallsToken)
displayName: Build

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'Ix.NET/Source/artifacts'
ArtifactName: artifacts
publishLocation: Container
condition: always()
29 changes: 29 additions & 0 deletions .vsts.ix-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
trigger: none
queue: Hosted VS2017

variables:
BuildConfiguration: Release
BuildPlatform: Any CPU

steps:
- task: BatchScript@1
inputs:
filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
arguments: -no_logo
modifyEnvironment: true
displayName: Setup Environment Variables

- task: PowerShell@1
inputs:
scriptName: 'Ix.NET/Source/build-new.ps1'
workingFolder: 'Ix.NET/Source'
env:
VSTS_ACCESS_TOKEN: $(System.AccessToken)
displayName: Build

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'Ix.NET/Source/artifacts'
ArtifactName: artifacts
publishLocation: Container
condition: eq(variables['system.pullrequest.isfork'], false)
33 changes: 14 additions & 19 deletions Ix.NET/Source/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,22 @@
<DefaultLanguage>en-US</DefaultLanguage>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<DebugType>embedded</DebugType>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false'">
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.6.0" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup>
<NerdbankGitVersioningVersion>2.0.41</NerdbankGitVersioningVersion>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.0.41" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
</ItemGroup>

<Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
<_Parameter1>CommitHash</_Parameter1>
<_Parameter2>$(SourceRevisionId)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>

<!-- https://github.com/NuGet/Home/issues/4337 -->
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' == 'true' ">
<Import Project="$(NuGetPackageRoot)\nerdbank.gitversioning\$(NerdbankGitVersioningVersion)\buildCrossTargeting\Nerdbank.GitVersioning.targets"
Condition="Exists('$(NuGetPackageRoot)\nerdbank.gitversioning\$(NerdbankGitVersioningVersion)\buildCrossTargeting\Nerdbank.GitVersioning.targets')" />
</ImportGroup>
<Target Name="FixUpVersion"
BeforeTargets="_GenerateRestoreProjectSpec"
DependsOnTargets="GetBuildVersion"
Condition=" '$(NerdbankGitVersioningTasksPath)' != '' " />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.2.build4010" />
<PackageReference Include="FluentAssertions" Version="4.19.2 " />

<PackageReference Include="xunit" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.4.0-beta.2.build4010" />

</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.2.build4010" />
<PackageReference Include="FluentAssertions" Version="4.19.2 " />

<PackageReference Include="xunit" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

<PackageReference Include="xunit" Version="2.4.0-beta.2.build4010" />
</ItemGroup>

</Project>
34 changes: 12 additions & 22 deletions Ix.NET/Source/build-new.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition

$configuration = "Release"

$isAppVeyor = Test-Path -Path env:\APPVEYOR
$isCloudBuild = Test-Path -Path env:\TF_BUILD
$outputLocation = Join-Path $scriptPath "testResults"
$xUnitConsolePath = ".\packages\xunit.runner.console\tools\net452\xunit.console.exe"
$rootPath = (Resolve-Path .).Path
$artifacts = Join-Path $rootPath "artifacts"

Expand All @@ -30,8 +29,7 @@ if (!(Test-Path .\nuget.exe)) {
# get tools
.\nuget.exe install -excludeversion SignClient -Version 0.9.0 -outputdirectory packages
.\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
.\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.41 -outputdirectory packages
.\nuget.exe install -excludeversion xunit.runner.console -outputdirectory packages
.\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.1.23 -outputdirectory packages
.\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
#.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
.\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
Expand All @@ -45,13 +43,6 @@ Write-Host "Building $packageSemVer" -Foreground Green
New-Item -ItemType Directory -Force -Path $artifacts


Write-Host "Restoring packages for $scriptPath\Ix.NET.sln" -Foreground Green
# use nuget.exe to restore on the legacy proj type
#.\nuget.exe restore "$scriptPath\System.Interactive.Tests.Uwp.DeviceRunner\System.Interactive.Tests.Uwp.DeviceRunner.csproj"
dotnet restore "$scriptPath\Ix.NET.sln"
# Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
dotnet restore "$scriptPath\Ix.NET.sln"

Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green

# Using MSBuild here since th UWP test project cannot be built by the dotnet CLI
Expand All @@ -62,7 +53,7 @@ Write-Host "Building Packages" -Foreground Green
dotnet pack "$scriptPath\System.Interactive\System.Interactive.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
if ($LastExitCode -ne 0) {
Write-Host "Error with build" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
Expand All @@ -71,7 +62,7 @@ if ($LastExitCode -ne 0) {
dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
if ($LastExitCode -ne 0) {
Write-Host "Error with build" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
Expand All @@ -80,7 +71,7 @@ if ($LastExitCode -ne 0) {
dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
if ($LastExitCode -ne 0) {
Write-Host "Error with build" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
Expand All @@ -89,7 +80,7 @@ if ($LastExitCode -ne 0) {
dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
if ($LastExitCode -ne 0) {
Write-Host "Error with build" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
Expand All @@ -106,7 +97,7 @@ if($hasSignClientSecret) {

if ($LastExitCode -ne 0) {
Write-Host "Error signing $nupkg" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
Expand All @@ -123,24 +114,23 @@ $testDirectory = Join-Path $scriptPath "System.Interactive.Tests"

# OpenCover isn't working currently. So run tests on CI and coverage with JetBrains

# Use xUnit CLI as it's significantly faster than vstest (dotnet test)
$dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1"
.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --filter `"SkipCI!=true`"" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1"

if ($LastExitCode -ne 0) {
Write-Host "Error with tests" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
}

$testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests"
.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"
.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --filter `"SkipCI!=true`"" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"

if ($LastExitCode -ne 0) {
Write-Host "Error with tests" -Foreground Red
if($isAppVeyor) {
if($isCloudBuild) {
$host.SetShouldExit($LastExitCode)
exit $LastExitCode
}
Expand All @@ -150,7 +140,7 @@ if ($LastExitCode -ne 0) {
.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties

# Either display or publish the results
if ($env:CI -eq 'True')
if ($isCloudBuild -eq 'True')
{
.\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
}
Expand Down
7 changes: 7 additions & 0 deletions Ix.NET/Source/build/setversion.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
8 changes: 8 additions & 0 deletions Ix.NET/Source/build/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"inherit": true,
"cloudBuild": {
"buildNumber": {
"enabled": true
}
}
}
5 changes: 2 additions & 3 deletions Ix.NET/Source/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
"version": "3.2.0-preview.{height}",
"publicReleaseRefSpec": [
"^refs/heads/master$", // we release out of master
"^refs/heads/develop$", // we release out of develop
"^refs/tags/v\\d+\\.\\d+" // we also release tags starting with vN.N
"^refs/heads/rel/v\\d+\\.\\d+" // we also release branches starting with vN.N
],
"nugetPackageVersion":{
"semVer": 2
},
"cloudBuild": {
"buildNumber": {
"enabled": true
"enabled": false
}
}
}
7 changes: 0 additions & 7 deletions build.ps1

This file was deleted.

0 comments on commit 29fa48f

Please sign in to comment.