Skip to content

Commit 1957c55

Browse files
adityapatwardhanTravisEz13
authored andcommitted
Enable VSTS CI for PowerShell-Native repository (#12)
1 parent de522db commit 1957c55

File tree

6 files changed

+161
-5
lines changed

6 files changed

+161
-5
lines changed

.vsts-ci/linux.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
2+
3+
variables:
4+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
5+
POWERSHELL_TELEMETRY_OPTOUT: 1
6+
# Avoid expensive initialization of dotnet cli, see: http://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
7+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
8+
9+
resources:
10+
- repo: self
11+
clean: true
12+
phases:
13+
- phase: Build
14+
15+
queue:
16+
name: Hosted Ubuntu 1604
17+
parallel: 2
18+
matrix:
19+
Linux ARM Native:
20+
buildName: ubuntu.16.04
21+
Linux Native:
22+
buildName: centos.7
23+
24+
steps:
25+
- powershell: |
26+
tools/releaseBuild/vstsBuild.ps1 -Name $(buildName) -Verbose
27+
displayName: Start build - $(buildName)
28+
condition: succeededOrFailed()

.vsts-ci/mac.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
2+
3+
variables:
4+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
5+
POWERSHELL_TELEMETRY_OPTOUT: 1
6+
# Avoid expensive initialization of dotnet cli, see: http://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
7+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
8+
9+
resources:
10+
- repo: self
11+
clean: true
12+
phases:
13+
- phase: Build
14+
15+
queue:
16+
name: Hosted macOS
17+
steps:
18+
- powershell: |
19+
tools/releaseBuild/PowershellNative.ps1 -Arch osx -Configuration Release -RepoRoot $(Build.SourcesDirectory) -TargetLocation "$(System.ArtifactsDirectory)/Packages" -Verbose
20+
Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts]$(System.ArtifactsDirectory)/Packages/osx-symbols.zip"
21+
$testResultPath = Get-ChildItem -Recurse -Filter 'native-tests.xml'
22+
if($testResultPath -and (Test-Path $testResultPath)) { Write-Host "##vso[results.publish type=JUnit;mergeResults=true;runTitle=Native Test Results OSX;publishRunAttachments=true;resultFiles=$testResultPath;]"}
23+
displayName: Start build
24+
condition: succeededOrFailed()

.vsts-ci/windows.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
2+
3+
variables:
4+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
5+
POWERSHELL_TELEMETRY_OPTOUT: 1
6+
# Avoid expensive initialization of dotnet cli, see: http://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
7+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
8+
9+
resources:
10+
- repo: self
11+
clean: true
12+
phases:
13+
- phase: Build
14+
15+
queue:
16+
name: Hosted Windows Container
17+
parallel: 4
18+
matrix:
19+
Windows x86:
20+
buildName: x86
21+
Windows x64:
22+
buildName: x64
23+
Windows x64_arm:
24+
buildName: x64_arm
25+
Windows x64_arm64:
26+
buildName: x64_arm64
27+
28+
steps:
29+
- powershell: |
30+
choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System'
31+
displayName: Install cmake
32+
condition: succeededOrFailed()
33+
- powershell: |
34+
choco install windows-sdk-10.1
35+
displayName: Install Windows SDK 10.1
36+
condition: succeeded()
37+
- powershell: |
38+
Invoke-WebRequest "https://aka.ms/vs/15/release/vs_BuildTools.exe" -OutFile vs_BuildTools.exe -UseBasicParsing
39+
Start-Process -FilePath 'vs_BuildTools.exe' -ArgumentList '--quiet', '--norestart', '--locale en-US', '--add Microsoft.VisualStudio.Component.VC.Tools.ARM', '--add Microsoft.VisualStudio.Component.VC.Tools.ARM64', '--includeRecommended', '--add Microsoft.VisualStudio.Workload.VCTools', '--add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop.arm', '--add Microsoft.VisualStudio.Component.VC.ATL', '--add Microsoft.VisualStudio.Component.VC.ATLMFC', '--add Microsoft.VisualStudio.Component.VC.ATL.ARM', '--add Microsoft.VisualStudio.Component.VC.ATL.ARM64' -Wait
40+
Remove-Item .\vs_BuildTools.exe
41+
Remove-Item -Force -Recurse 'C:\Program Files (x86)\Microsoft Visual Studio\Installer'
42+
setx /M PATH $($Env:PATH + ';' + ${Env:ProgramFiles(x86)} + '\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin')
43+
displayName: Install Visual Studio 2017
44+
condition: succeeded()
45+
- powershell: |
46+
$cmakeBinPath = "$env:ProgramFiles\CMake\bin\"
47+
if(Test-Path $cmakeBinPath) { $env:Path = "$cmakeBinPath;$env:PATH" } else { throw "CMake not installed under $cmakeBinPath" }
48+
$(Build.SourcesDirectory)\tools\releaseBuild\PowerShellNative.ps1 -RepoRoot $(Build.SourcesDirectory) -TargetLocation "$(System.ArtifactsDirectory)\Packages" -Arch $(buildName) -Configuration Release -Symbols
49+
Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts]$(System.ArtifactsDirectory)\Packages\$(buildName)-symbols.zip"
50+
displayName: Start build - $(buildName)
51+
condition: succeeded()

build.psm1

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,39 @@ function Start-BuildNativeWindowsBinaries {
215215
if ($env:VS140COMNTOOLS -ne $null) {
216216
$vcPath = (Get-Item(Join-Path -Path "$env:VS140COMNTOOLS" -ChildPath '../../vc')).FullName
217217
}
218+
Write-Verbose -Verbose "VCPath: $vcPath"
218219

219-
$alternateVCPath = (Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017" -Filter "VC" -Directory -Recurse | Select-Object -First 1).FullName
220+
$alternateVCPath = (Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017" -Filter "VC" -Directory -Recurse).FullName
221+
Write-Verbose -Verbose "alternateVCPath: $alternateVCPath"
220222

221-
$atlMfcIncludePath = Join-Path -Path $vcPath -ChildPath 'atlmfc/include'
223+
$atlBaseFound = $false
224+
225+
if ($vcPath) {
226+
$atlMfcIncludePath = Join-Path -Path $vcPath -ChildPath 'atlmfc/include'
227+
if(Test-Path -Path "$atlMfcIncludePath\atlbase.h") {
228+
Write-Verbose -Verbose "ATLF MFC found under $atlMfcIncludePath\atlbase.h"
229+
$atlBaseFound = $true
230+
}
231+
} elseif ($alternateVCPath) {
232+
foreach($candidatePath in $alternateVCPath) {
233+
Write-Verbose -Verbose "Looking under $candidatePath"
234+
$atlMfcIncludePath = @(Get-ChildItem -Path $candidatePath -Recurse -Filter 'atlbase.h' -File)
235+
236+
$atlMfcIncludePath | ForEach-Object {
237+
if($_.FullName.EndsWith('atlmfc\include\atlbase.h')) {
238+
Write-Verbose -Verbose "ATLF MFC found under $($_.FullName)"
239+
$atlBaseFound = $true
240+
break
241+
}
242+
}
243+
}
244+
} else {
245+
Write-Verbose -Verbose "PATH: $env:PATH"
246+
throw "Visual Studio tools not found in PATH."
247+
}
222248

223249
# atlbase.h is included in the pwrshplugin project
224-
if ((Test-Path -Path $atlMfcIncludePath\atlbase.h) -eq $false) {
250+
if (-not $atlBaseFound) {
225251
throw "Could not find Visual Studio include file atlbase.h at $atlMfcIncludePath. Please ensure the optional feature 'Microsoft Foundation Classes for C++' is installed."
226252
}
227253

tools/releaseBuild/PowershellNative.ps1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,34 @@ param (
2525
)
2626

2727
end {
28-
28+
Write-Verbose -Verbose "Starting PowerShellNative.ps1 Arch: $Arch, Config: $Configuration, Repo: $RepoRoot, Target: $TargetLocation"
2929
Import-Module $RepoRoot/build.psm1 -Force
3030
#$binOut = New-Item -Path $TargetLocation/$Arch -ItemType Directory -Force
3131
$binOut = New-Item -Path $TargetLocation -ItemType Directory -Force
3232
Write-Verbose "Created output directory: $binOut" -Verbose
3333

3434
if ($Arch -eq 'linux-x64' -or $Arch -eq 'osx') {
35+
36+
Write-Verbose "Starting Build for: $Arch" -Verbose
37+
3538
Start-PSBootstrap
3639
Start-BuildNativeUnixBinaries
3740

3841
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
3942
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
43+
44+
$testResultPath = Join-Path $RepoRoot -ChildPath 'src/libpsl-native/test/native-tests.xml'
45+
46+
if (Test-Path $testResultPath) {
47+
if ($Arch -eq 'linux-x64') {
48+
$name = 'linux-x64-native-tests.xml'
49+
}
50+
else {
51+
$name = 'osx-native-tests.xml'
52+
}
53+
54+
Copy-Item $testResultPath -Destination "$TargetLocation/$name" -Verbose
55+
}
4056
}
4157
elseif ($Arch -eq 'linux-arm') {
4258
Start-PSBootstrap -BuildLinuxArm
@@ -46,9 +62,11 @@ end {
4662
Compress-Archive -Path $buildOutputPath/libpsl-native.* -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
4763
}
4864
else {
65+
Write-Verbose "Starting Start-PSBootstrap" -Verbose
4966
Start-PSBootstrap -BuildWindowsNative
67+
Write-Verbose "Starting Start-BuildNativeWindowsBinaries" -Verbose
5068
Start-BuildNativeWindowsBinaries -Configuration $Configuration -Arch $Arch -Clean
51-
69+
Write-Verbose "Completed Start-BuildNativeWindowsBinaries" -Verbose
5270
$buildOutputPath = Join-Path $RepoRoot "src/powershell-win-core"
5371
Compress-Archive -Path "$buildOutputPath/*.dll" -DestinationPath "$TargetLocation/$Arch-symbols.zip" -Verbose
5472

tools/releaseBuild/vstsBuild.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ end {
7575
Write-VstsError -Error $_
7676
}
7777
finally {
78+
$testResultPath = Get-ChildItem $env:AGENT_TEMPDIRECTORY -Recurse -Filter 'linux-x64-native-tests.xml'
79+
80+
if($testResultPath -and (Test-Path $testResultPath)) {
81+
Write-Host "##vso[results.publish type=JUnit;mergeResults=true;runTitle=Native Test Results;publishRunAttachments=true;resultFiles=$testResultPath;]"
82+
}
83+
else {
84+
Write-Verbose -Verbose "Test results file was not found."
85+
}
86+
7887
Write-VstsTaskState
7988
exit 0
8089
}

0 commit comments

Comments
 (0)