Skip to content

Bump CI images and enable tests on Apple M1 #1426

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 6 commits into from
Mar 18, 2021
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
20 changes: 11 additions & 9 deletions .vsts-ci/azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,35 @@ trigger:
- /LICENSE
- /CODE_OF_CONDUCT.md

# TODO: Setup matrix of image support.
jobs:
- job: 'PS51_Win10'
displayName: PowerShell 5.1 | Windows 10
pool:
# TODO: Update this image.
vmImage: 'vs2017-win2016'
steps:
- template: templates/ci-general.yml
parameters:
pwsh: false

- job: 'PS6_Win10'
displayName: PowerShell 6 | Windows 10
- job: 'PS7_Win10'
displayName: PowerShell 7 | Windows 10
pool:
vmImage: 'vs2017-win2016'
vmImage: 'windows-2019'
steps:
- template: templates/ci-general.yml

- job: 'PS6_macOS'
displayName: PowerShell 6 | macOS
- job: 'PS7_macOS'
displayName: PowerShell 7 | macOS
pool:
vmImage: 'macOS-10.14'
vmImage: 'macOS-10.15'
steps:
- template: templates/ci-general.yml

- job: 'PS6_Ubuntu'
displayName: PowerShell 6 | Ubuntu
- job: 'PS7_Ubuntu'
displayName: PowerShell 7 | Ubuntu
pool:
vmImage: 'ubuntu-16.04'
vmImage: 'ubuntu-20.04'
steps:
- template: templates/ci-general.yml
56 changes: 23 additions & 33 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ param(

#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}

$script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows
$script:IsNix = $IsLinux -or $IsMacOS
$script:IsRosetta = $IsMacOS -and (sysctl -n sysctl.proc_translated) -eq 1 # Mac M1
$script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs")
$script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props")
$script:IsPreview = [bool]($script:PsesCommonProps.Project.PropertyGroup.VersionSuffix)

$script:NetRuntime = @{
PS62 = 'netcoreapp2.1'
PS7 = 'netcoreapp3.1'
PS71 = 'net5.0'
PS72 = 'net6.0'
Desktop = 'net461'
Standard = 'netstandard2.0'
}

$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS62)/publish"
$script:HostCoreOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.PS7)/publish"
$script:HostDeskOutput = "$PSScriptRoot/src/PowerShellEditorServices.Hosting/bin/$Configuration/$($script:NetRuntime.Desktop)/publish"
$script:PsesOutput = "$PSScriptRoot/src/PowerShellEditorServices/bin/$Configuration/$($script:NetRuntime.Standard)/publish"
$script:VSCodeOutput = "$PSScriptRoot/src/PowerShellEditorServices.VSCode/bin/$Configuration/$($script:NetRuntime.Standard)/publish"
Expand Down Expand Up @@ -63,7 +63,7 @@ function Install-Dotnet {
Write-Host "Installing .NET channels $Channel" -ForegroundColor Green

# The install script is platform-specific
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" }
$installScriptExt = if ($script:IsNix) { "sh" } else { "ps1" }
$installScript = "dotnet-install.$installScriptExt"

# Download the official installation script and run it
Expand All @@ -75,11 +75,11 @@ function Install-Dotnet {
{
Write-Host "`n### Installing .NET CLI $Version...`n"

if ($script:IsUnix) {
if ($script:IsNix) {
chmod +x $installScriptPath
}

$params = if ($script:IsUnix)
$params = if ($script:IsNix)
{
@('-Channel', $dotnetChannel, '-InstallDir', $env:DOTNET_INSTALL_DIR, '-NoPath', '-Verbose')
}
Expand All @@ -103,13 +103,14 @@ function Install-Dotnet {
Write-Host '.NET installation complete' -ForegroundColor Green
}

task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E {
task SetupDotNet -Before Clean, Build, TestServerWinPS, TestServerPS7, TestServerPS72, TestE2E {

$dotnetPath = "$PSScriptRoot/.dotnet"
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
$dotnetExePath = if ($script:IsNix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }

if (!(Test-Path $dotnetExePath)) {
Install-Dotnet -Channel '2.1','3.1','release/5.0.1xx-preview6'
# TODO: Test .NET 5 with PowerShell 7.1, and add that channel here.
Install-Dotnet -Channel '3.1','release/6.0.1xx-preview2'
}

# This variable is used internally by 'dotnet' to know where it's installed
Expand Down Expand Up @@ -237,8 +238,8 @@ task SetupHelpForTests {

task Build BinClean,{
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS62 }
if (-not $script:IsUnix)
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 }
if (-not $script:IsNix)
{
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
}
Expand All @@ -254,50 +255,39 @@ function DotNetTestFilter {

task Test SetupHelpForTests,TestServer,TestE2E

task TestServer TestServerWinPS,TestServerPS7,TestServerPS71
task TestServer TestServerWinPS,TestServerPS7,TestServerPS72

task TestServerWinPS -If (-not $script:IsUnix) {
task TestServerWinPS -If (-not $script:IsNix) {
Set-Location .\test\PowerShellEditorServices.Test\
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.Desktop (DotNetTestFilter) }
}

task TestServerPS7 {
task TestServerPS7 -If (-not $script:IsRosetta) {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
}
}

task TestServerPS71 {
task TestServerPS72 {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS71 (DotNetTestFilter) }
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS72 (DotNetTestFilter) }
}
}

task TestHost {
Set-Location .\test\PowerShellEditorServices.Test.Host\

if (-not $script:IsUnix) {
exec { & $script:dotnetExe build -f $script:NetRuntime.Desktop }
exec { & $script:dotnetExe test -f $script:NetRuntime.Desktop (DotNetTestFilter) }
}

exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.PS62 }
exec { & $script:dotnetExe test -f $script:NetRuntime.PS62 (DotNetTestFilter) }
}

task TestE2E {
Set-Location .\test\PowerShellEditorServices.Test.E2E\

$env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" }
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) }
$NetRuntime = if ($IsRosetta) { $script:NetRuntime.PS72 } else { $script:NetRuntime.PS7 }
exec { & $script:dotnetExe test --logger trx -f $NetRuntime (DotNetTestFilter) }

# Run E2E tests in ConstrainedLanguage mode.
if (!$script:IsUnix) {
if (!$script:IsNix) {
try {
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine);
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) }
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
} finally {
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine);
}
Expand Down Expand Up @@ -352,7 +342,7 @@ task LayoutModule -After Build {
}

# PSES/bin/Desktop
if (-not $script:IsUnix)
if (-not $script:IsNix)
{
foreach ($hostComponent in Get-ChildItem $script:HostDeskOutput)
{
Expand Down
21 changes: 0 additions & 21 deletions PowerShellEditorServices.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E7
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{422E561A-8118-4BE7-A54F-9309E4F03AAE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Host", "test\PowerShellEditorServices.Test.Host\PowerShellEditorServices.Test.Host.csproj", "{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test", "test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj", "{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Shared", "test\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj", "{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}"
Expand Down Expand Up @@ -39,24 +37,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|Any CPU.Build.0 = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x64.ActiveCfg = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x64.Build.0 = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x86.ActiveCfg = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x86.Build.0 = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x64.ActiveCfg = Debug|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x64.Build.0 = Debug|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x86.ActiveCfg = Debug|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x86.Build.0 = Debug|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|Any CPU.Build.0 = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x64.ActiveCfg = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x64.Build.0 = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x86.ActiveCfg = Release|Any CPU
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x86.Build.0 = Release|Any CPU
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|Any CPU.Build.0 = Release|Any CPU
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|x64.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -170,7 +150,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
{3B38E8DA-8BFF-4264-AF16-47929E6398A3} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
<AssemblyName>Microsoft.PowerShell.EditorServices.Hosting</AssemblyName>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);CoreCLR</DefineConstants>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/PowerShellEditorServices/Utility/VersionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ internal static class VersionUtils
public static bool IsPS7OrGreater { get; } = PSVersion.Major >= 7;

/// <summary>
/// True if we are running in on Windows, false otherwise.
/// True if we are running on Windows, false otherwise.
/// </summary>
public static bool IsWindows { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

/// <summary>
/// True if we are running in on macOS, false otherwise.
/// True if we are running on macOS, false otherwise.
/// </summary>
public static bool IsMacOS { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

/// <summary>
/// True if we are running in on Linux, false otherwise.
/// True if we are running on Linux, false otherwise.
/// </summary>
public static bool IsLinux { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -31,6 +32,9 @@ namespace PowerShellEditorServices.Test.E2E
{
public class LanguageServerProtocolMessageTests : IClassFixture<LSPTestsFixture>, IDisposable
{
// Borrowed from `VersionUtils` which can't be used here due to an initialization problem.
private static bool IsLinux { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

private readonly static string s_binDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

Expand Down Expand Up @@ -924,9 +928,10 @@ await PsesLanguageClient
}

[Trait("Category", "LSP")]
[Fact]
[SkippableFact]
public async Task CanSendCompletionAndCompletionResolveRequestAsync()
{
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
string filePath = NewTestFile("Write-H");

CompletionList completionItems = await PsesLanguageClient.TextDocument.RequestCompletion(
Expand All @@ -950,9 +955,10 @@ public async Task CanSendCompletionAndCompletionResolveRequestAsync()
}

[Trait("Category", "LSP")]
[Fact]
[SkippableFact]
public async Task CanSendCompletionResolveWithModulePrefixRequestAsync()
{
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
await PsesLanguageClient
.SendRequest<EvaluateRequestArguments>(
"evaluate",
Expand Down Expand Up @@ -985,9 +991,10 @@ await PsesLanguageClient
}

[Trait("Category", "LSP")]
[Fact]
[SkippableFact]
public async Task CanSendHoverRequestAsync()
{
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
string filePath = NewTestFile("Write-Host");

Hover hover = await PsesLanguageClient.TextDocument.RequestHover(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
6 changes: 0 additions & 6 deletions test/PowerShellEditorServices.Test.Host/App.config

This file was deleted.

9 changes: 0 additions & 9 deletions test/PowerShellEditorServices.Test.Host/AssemblyInfo.cs

This file was deleted.

Loading