Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chcosta committed Aug 7, 2019
1 parent 68e9257 commit 06665f6
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 57 deletions.
167 changes: 113 additions & 54 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ pr:
- Documentation/*

variables:
# Cannot use key:value syntax in root defined variables
- name: _TeamName
value: DotNetCore
- name: _PublishUsingPipelines
value: true
- name: _DotNetArtifactsCategory
value: .NETCore
- name: _DotNetValidationArtifactsCategory
value: .NETCoreValidation
- template: eng/common-variables.yml

resources:
containers:
- container: LinuxContainer
image: microsoft/dotnet-buildtools-prereqs:ubuntu-14.04-cross-0cd4667-20170319080304

stages:
- stage: build
- stage: Build
displayName: Build
jobs:
- template: /eng/common/templates/jobs/jobs.yml
Expand All @@ -50,10 +42,10 @@ stages:
pool:
# For public or PR jobs, use the hosted pool. For internal jobs use the internal pool.
# Will eventually change this to two BYOC pools.
${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsPublic, True) }}:
name: NetCorePublic-Pool
queue: BuildPool.Windows.10.Amd64.VS2017.Open
${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsInternal, True) }}:
name: NetCoreInternal-Pool
queue: BuildPool.Windows.10.Amd64.VS2017
variables:
Expand All @@ -63,7 +55,8 @@ stages:
- HelixApiAccessToken: ''

# Only enable publishing in non-public, non PR scenarios.
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- ${{ if eq(variables._RunAsInternal, True) }}:

# DotNet-Blob-Feed provides: dotnetfeed-storage-access-key-1
# Publish-Build-Assets provides: MaestroAccessToken, BotAccount-dotnet-maestro-bot-PAT
# DotNet-HelixApi-Access provides: HelixApiAccessToken
Expand All @@ -84,14 +77,15 @@ stages:
Build_Release:
_BuildConfig: Release
# PRs or external builds are not signed.
${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsPublic, True) }}:
_SignType: test
_DotNetPublishToBlobFeed : false
${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsInternal, True) }}:
_SignType: real
_DotNetPublishToBlobFeed : true
_Script: eng\validate-sdk.cmd
_ValidateSdkArgs: -gitHubPat $(BotAccount-dotnet-maestro-bot-PAT) -barToken $(MaestroAccessToken)
${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsPublic, True) }}:
Build_Debug:
_BuildConfig: Debug
_SignType: test
Expand All @@ -104,61 +98,32 @@ stages:
-configuration $(_BuildConfig)
-prepareMachine
$(_InternalBuildArgs)
$(_ValidateSdkArgs)
/p:Test=false
displayName: Windows Build / Publish
- publish: artifacts\bin
- publish: artifacts\packages

- powershell: eng\common\build.ps1
-configuration $(_BuildConfig)
-prepareMachine
-ci
-test
-projects $(Build.SourcesDirectory)/tests/UnitTests.proj
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix.binlog
displayName: Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: $(HelixApiAccessToken)

- powershell: eng\common\build.ps1
-configuration $(_BuildConfig)
-prepareMachine
-ci
-test
-projects $(Build.SourcesDirectory)/tests/UnitTests.proj
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix.binlog
/p:HelixBaseUri=https://helix.int-dot.net/
displayName: Run Helix Tests (Int)
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: $(HelixApiAccessToken)
enabled: false

- ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
- ${{ if eq(variables._RunAsPublic, True) }}:
- job: Linux
container: LinuxContainer
pool:
${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsPublic, True) }}:
name: NetCorePublic-Pool
queue: BuildPool.Ubuntu.1604.Amd64.Open
${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
${{ if eq(variables._RunAsInternal, True) }}:
name: NetCoreInternal-Pool
queue: BuildPool.Ubuntu.1604.Amd64
variables:
- HelixApiAccessToken: ''
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- ${{ if eq(variables._RunAsInternal, True) }}:
- group: DotNet-HelixApi-Access
strategy:
matrix:
Build_Debug:
_BuildConfig: Debug
_PublishType: none
_SignType: none
_DotNetPublishToBlobFeed : false
Build_Release:
_BuildConfig: Release
_PublishType: none
_SignType: none
_DotNetPublishToBlobFeed : false
steps:
- checkout: self
clean: true
Expand All @@ -167,6 +132,100 @@ stages:
--prepareMachine
/p:Test=false
displayName: Unix Build / Publish
- publish: artifacts/bin
artifact: Binaries_Linux
- publish: artifacts/packages
artifact: Packages_Linux

- ${{ if eq(variables._RunAsPublic, True) }}:
- stage: Test
dependsOn: Build
jobs:
- template: /eng/common/templates/jobs/jobs.yml
parameters:
enableTelemetry: true
enablePublishBuildArtifacts: true
helixRepo: dotnet/arcade
jobs:
- job: Windows_NT
timeoutInMinutes: 90
pool:
vmimage: windows-latest
strategy:
matrix:
Build_Release:
_BuildConfig: Release
Build_Debug:
_BuildConfig: Debug
steps:
- checkout: self
clean: true
- task: DownloadPipelineArtifact@2
inputs:
buildType: current
artifactName: Binaries_Windows_NT
patterns: $(_BuildConfig)/**
targetPath: artifacts\bin
- task: DownloadPipelineArtifact@2
inputs:
buildType: current
artifactName: Packages_Windows_NT
patterns: $(_BuildConfig)/**
targetPath: artifacts\packages
- powershell: |
. eng\common\tools.ps1 -ci -restore ; InitializeToolset
- script: dir .
- powershell: eng\common\build.ps1
-configuration $(_BuildConfig)
-prepareMachine
-ci
-test
-projects $(Build.SourcesDirectory)/tests/UnitTests.proj
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix.binlog
displayName: Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: ''
- powershell: eng\common\build.ps1
-configuration $(_BuildConfig)
-prepareMachine
-ci
-test
-projects $(Build.SourcesDirectory)/tests/UnitTests.proj
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix-int.binlog
/p:HelixBaseUri=https://helix.int-dot.net/
displayName: Run Helix Tests (Int)
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: ''
enabled: false
- job: Linux
container: LinuxContainer
pool:
vmimage: ubuntu-latest
strategy:
matrix:
Build_Debug:
_BuildConfig: Debug
Build_Release:
_BuildConfig: Release
steps:
- checkout: self
clean: true
- script: eng/common/tools.sh
- task: DownloadPipelineArtifact@2
inputs:
buildType: current
artifactName: Binaries_Linux
patterns: $(_BuildConfig)/**
targetPath: artifacts/bin
- task: DownloadPipelineArtifact@2
inputs:
buildType: current
artifactName: Packages_Linux
patterns: $(_BuildConfig)/**
targetPath: artifacts/packages
- script: source eng/common/tools.sh --ci --restore; InitializeToolset
- script: eng/common/build.sh
--configuration $(_BuildConfig)
--prepareMachine
Expand All @@ -177,9 +236,9 @@ stages:
displayName: Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: $(HelixApiAccessToken)
HelixAccessToken: ''

- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- ${{ if eq(variables._RunAsInternal, True) }}:
- template: eng\common\templates\post-build\post-build.yml
parameters:
# Symbol validation isn't being very reliable lately. This should be enabled back
Expand Down
20 changes: 20 additions & 0 deletions eng/common-variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
variables:
# Cannot use key:value syntax in root defined variables
- name: _TeamName
value: DotNetCore
- name: _PublishUsingPipelines
value: true
- name: _DotNetArtifactsCategory
value: .NETCore
- name: _DotNetValidationArtifactsCategory
value: .NETCoreValidation
- name: _RunAsPublic
value: True
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- name: _RunAsPublic
value: False
- name: _RunAsInternal
value: False
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- name: _RunAsInternal
value: True
5 changes: 5 additions & 0 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ function InitializeNativeTools() {
}

function InitializeToolset() {
Write-Host "InitializeToolset"
if (Test-Path variable:global:_ToolsetBuildProj) {
return $global:_ToolsetBuildProj
}
Expand All @@ -433,13 +434,16 @@ function InitializeToolset() {
$toolsetVersion = $GlobalJson.'msbuild-sdks'.'Microsoft.DotNet.Arcade.Sdk'
$toolsetLocationFile = Join-Path $ToolsetDir "$toolsetVersion.txt"

Write-Host "toolsetLocationFile: $toolsetLocationFile"

if (Test-Path $toolsetLocationFile) {
$path = Get-Content $toolsetLocationFile -TotalCount 1
if (Test-Path $path) {
return $global:_ToolsetBuildProj = $path
}
}

Write-Host "not restore"
if (-not $restore) {
Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Toolset version $toolsetVersion has not been restored."
ExitWithExitCode 1
Expand Down Expand Up @@ -576,5 +580,6 @@ Create-Directory $LogDir
Write-PipelineSetVariable -Name 'Artifacts' -Value $ArtifactsDir
Write-PipelineSetVariable -Name 'Artifacts.Toolset' -Value $ToolsetDir
Write-PipelineSetVariable -Name 'Artifacts.Log' -Value $LogDir
Write-PipelineSetVariable -Name 'AzureDevOps.Artifacts.Label' -Value "Windows_NT.$configuration.artifacts"
Write-PipelineSetVariable -Name 'TEMP' -Value $TempDir
Write-PipelineSetVariable -Name 'TMP' -Value $TempDir
1 change: 1 addition & 0 deletions eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,5 +386,6 @@ mkdir -p "$log_dir"
Write-PipelineSetVariable -name "Artifacts" -value "$artifacts_dir"
Write-PipelineSetVariable -name "Artifacts.Toolset" -value "$toolset_dir"
Write-PipelineSetVariable -name "Artifacts.Log" -value "$log_dir"
Write-PipelineSetVariable -name "AzureDevOps.Artifacts.Label" -value "Linux.$configuration.artifacts"
Write-PipelineSetVariable -name "Temp" -value "$temp_dir"
Write-PipelineSetVariable -name "TMP" -value "$temp_dir"
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dotnet": "3.0.100-preview6-012264"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19381.19",
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19406.6",
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19381.19"
}
}
4 changes: 2 additions & 2 deletions tests/UnitTests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

<!-- Use the locally built version of Helix Tasks temporaraily -->
<PropertyGroup>
<MicrosoftDotNetHelixSdkTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)../artifacts/bin/Microsoft.DotNet.Helix.Sdk/$(_BuildConfig)/netcoreapp2.1/publish/Microsoft.DotNet.Helix.Sdk.dll</MicrosoftDotNetHelixSdkTasksAssembly>
<MicrosoftDotNetHelixSdkTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)../artifacts/bin/Microsoft.DotNet.Helix.Sdk/$(_BuildConfig)/net472/publish/Microsoft.DotNet.Helix.Sdk.dll</MicrosoftDotNetHelixSdkTasksAssembly>
<MicrosoftDotNetHelixSdkTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)../artifacts/bin/Microsoft.DotNet.Helix.Sdk/$(Configuration)/netcoreapp2.1/publish/Microsoft.DotNet.Helix.Sdk.dll</MicrosoftDotNetHelixSdkTasksAssembly>
<MicrosoftDotNetHelixSdkTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)../artifacts/bin/Microsoft.DotNet.Helix.Sdk/$(Configuration)/net472/publish/Microsoft.DotNet.Helix.Sdk.dll</MicrosoftDotNetHelixSdkTasksAssembly>
</PropertyGroup>

<ItemGroup Condition=" '$(HelixAccessToken)' != '' ">
Expand Down

0 comments on commit 06665f6

Please sign in to comment.