Skip to content

Fix Ubuntu build and runspace test #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/Engine/Helper.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Describe "Test Directed Graph" {
Context "Runspaces should be disposed" {
It "Running analyzer 100 times should only create a limited number of runspaces" -Skip:$($PSVersionTable.PSVersion.Major -le 4) {
$null = 1..100 | ForEach-Object { Invoke-ScriptAnalyzer -ScriptDefinition 'gci' }
(Get-Runspace).Count | Should -BeLessOrEqual 10 -Because 'Number of Runspaces should not exceed size of runspace pool cache in CommandInfoCache'
(Get-Runspace).Count | Should -BeLessOrEqual 11 -Because 'Number of Runspaces should not exceed size of runspace pool cache (10) plus the the default runspace pool (1) in CommandInfoCache'
}
}
}
36 changes: 31 additions & 5 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,38 @@ function Invoke-AppVeyorInstall {
Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion $platyPSVersion -Repository PSGallery
}

# the build script sorts out the problems of WMF4 and earlier versions of dotnet CLI
# Do not use 'build.ps1 -bootstrap' option for bootstraping the .Net SDK as it does not work well in CI with the AppVeyor Ubuntu image
Write-Verbose -Verbose "Installing required .Net CORE SDK"
Write-Verbose "& $buildScriptDir/build.ps1 -bootstrap"
$buildScriptDir = (Resolve-Path "$PSScriptRoot/..").Path
& "$buildScriptDir/build.ps1" -bootstrap
$Global:LASTEXITCODE = $LASTEXITCODE = 0 # needed to avoid a premature abortion of the AppVeyor Ubuntu build
# the legacy WMF4 image only has the old preview SDKs of dotnet
$globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json
$requiredDotNetCoreSDKVersion = $globalDotJson.sdk.version
if ($PSVersionTable.PSVersion.Major -gt 4) {
$requiredDotNetCoreSDKVersionPresent = (dotnet --list-sdks) -match $requiredDotNetCoreSDKVersion
}
else {
# WMF 4 image has old SDK that does not have --list-sdks parameter
$requiredDotNetCoreSDKVersionPresent = (dotnet --version).StartsWith($requiredDotNetCoreSDKVersion)
}
if (-not $requiredDotNetCoreSDKVersionPresent) {
Write-Verbose -Verbose "Installing required .Net CORE SDK $requiredDotNetCoreSDKVersion"
$originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
if ($IsLinux -or $isMacOS) {
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.sh' -OutFile dotnet-install.sh
bash dotnet-install.sh --version $requiredDotNetCoreSDKVersion
[System.Environment]::SetEnvironmentVariable('PATH', "/home/appveyor/.dotnet$([System.IO.Path]::PathSeparator)$PATH")
}
else {
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
.\dotnet-install.ps1 -Version $requiredDotNetCoreSDKVersion
}
}
finally {
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
Remove-Item .\dotnet-install.*
}
}
}

# Implements AppVeyor 'test_script' step
Expand Down