Skip to content

Commit 176c5d6

Browse files
Merge pull request #1426 from PowerShell/andschwa/mac-mini
Bump CI images and enable tests on Apple M1
2 parents ec76cbd + bc2db5c commit 176c5d6

26 files changed

+54
-1890
lines changed

.vsts-ci/azure-pipelines-ci.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,35 @@ trigger:
3232
- /LICENSE
3333
- /CODE_OF_CONDUCT.md
3434

35+
# TODO: Setup matrix of image support.
3536
jobs:
3637
- job: 'PS51_Win10'
3738
displayName: PowerShell 5.1 | Windows 10
3839
pool:
40+
# TODO: Update this image.
3941
vmImage: 'vs2017-win2016'
4042
steps:
4143
- template: templates/ci-general.yml
4244
parameters:
4345
pwsh: false
4446

45-
- job: 'PS6_Win10'
46-
displayName: PowerShell 6 | Windows 10
47+
- job: 'PS7_Win10'
48+
displayName: PowerShell 7 | Windows 10
4749
pool:
48-
vmImage: 'vs2017-win2016'
50+
vmImage: 'windows-2019'
4951
steps:
5052
- template: templates/ci-general.yml
5153

52-
- job: 'PS6_macOS'
53-
displayName: PowerShell 6 | macOS
54+
- job: 'PS7_macOS'
55+
displayName: PowerShell 7 | macOS
5456
pool:
55-
vmImage: 'macOS-10.14'
57+
vmImage: 'macOS-10.15'
5658
steps:
5759
- template: templates/ci-general.yml
5860

59-
- job: 'PS6_Ubuntu'
60-
displayName: PowerShell 6 | Ubuntu
61+
- job: 'PS7_Ubuntu'
62+
displayName: PowerShell 7 | Ubuntu
6163
pool:
62-
vmImage: 'ubuntu-16.04'
64+
vmImage: 'ubuntu-20.04'
6365
steps:
6466
- template: templates/ci-general.yml

PowerShellEditorServices.build.ps1

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ param(
1818

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

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

2627
$script:NetRuntime = @{
27-
PS62 = 'netcoreapp2.1'
2828
PS7 = 'netcoreapp3.1'
29-
PS71 = 'net5.0'
29+
PS72 = 'net6.0'
3030
Desktop = 'net461'
3131
Standard = 'netstandard2.0'
3232
}
3333

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

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

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

78-
if ($script:IsUnix) {
78+
if ($script:IsNix) {
7979
chmod +x $installScriptPath
8080
}
8181

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

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

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

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

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

238239
task Build BinClean,{
239240
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
240-
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS62 }
241-
if (-not $script:IsUnix)
241+
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 }
242+
if (-not $script:IsNix)
242243
{
243244
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
244245
}
@@ -254,50 +255,39 @@ function DotNetTestFilter {
254255

255256
task Test SetupHelpForTests,TestServer,TestE2E
256257

257-
task TestServer TestServerWinPS,TestServerPS7,TestServerPS71
258+
task TestServer TestServerWinPS,TestServerPS7,TestServerPS72
258259

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

264-
task TestServerPS7 {
265+
task TestServerPS7 -If (-not $script:IsRosetta) {
265266
Set-Location .\test\PowerShellEditorServices.Test\
266267
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
267268
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
268269
}
269270
}
270271

271-
task TestServerPS71 {
272+
task TestServerPS72 {
272273
Set-Location .\test\PowerShellEditorServices.Test\
273274
Invoke-WithCreateDefaultHook -NewModulePath $script:PSCoreModulePath {
274-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS71 (DotNetTestFilter) }
275+
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS72 (DotNetTestFilter) }
275276
}
276277
}
277278

278-
task TestHost {
279-
Set-Location .\test\PowerShellEditorServices.Test.Host\
280-
281-
if (-not $script:IsUnix) {
282-
exec { & $script:dotnetExe build -f $script:NetRuntime.Desktop }
283-
exec { & $script:dotnetExe test -f $script:NetRuntime.Desktop (DotNetTestFilter) }
284-
}
285-
286-
exec { & $script:dotnetExe build -c $Configuration -f $script:NetRuntime.PS62 }
287-
exec { & $script:dotnetExe test -f $script:NetRuntime.PS62 (DotNetTestFilter) }
288-
}
289-
290279
task TestE2E {
291280
Set-Location .\test\PowerShellEditorServices.Test.E2E\
292281

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

296286
# Run E2E tests in ConstrainedLanguage mode.
297-
if (!$script:IsUnix) {
287+
if (!$script:IsNix) {
298288
try {
299289
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine);
300-
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS62 (DotNetTestFilter) }
290+
exec { & $script:dotnetExe test --logger trx -f $script:NetRuntime.PS7 (DotNetTestFilter) }
301291
} finally {
302292
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine);
303293
}
@@ -352,7 +342,7 @@ task LayoutModule -After Build {
352342
}
353343

354344
# PSES/bin/Desktop
355-
if (-not $script:IsUnix)
345+
if (-not $script:IsNix)
356346
{
357347
foreach ($hostComponent in Get-ChildItem $script:HostDeskOutput)
358348
{

PowerShellEditorServices.sln

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E7
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{422E561A-8118-4BE7-A54F-9309E4F03AAE}"
99
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Host", "test\PowerShellEditorServices.Test.Host\PowerShellEditorServices.Test.Host.csproj", "{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}"
11-
EndProject
1210
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test", "test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj", "{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}"
1311
EndProject
1412
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerShellEditorServices.Test.Shared", "test\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj", "{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA}"
@@ -39,24 +37,6 @@ Global
3937
Release|x86 = Release|x86
4038
EndGlobalSection
4139
GlobalSection(ProjectConfigurationPlatforms) = postSolution
42-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU
43-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|Any CPU.Build.0 = Release|Any CPU
44-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x64.ActiveCfg = Release|Any CPU
45-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x64.Build.0 = Release|Any CPU
46-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x86.ActiveCfg = Release|Any CPU
47-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.CoreCLR|x86.Build.0 = Release|Any CPU
48-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|Any CPU.Build.0 = Debug|Any CPU
50-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x64.ActiveCfg = Debug|Any CPU
51-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x64.Build.0 = Debug|Any CPU
52-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x86.ActiveCfg = Debug|Any CPU
53-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Debug|x86.Build.0 = Debug|Any CPU
54-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|Any CPU.ActiveCfg = Release|Any CPU
55-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|Any CPU.Build.0 = Release|Any CPU
56-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x64.ActiveCfg = Release|Any CPU
57-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x64.Build.0 = Release|Any CPU
58-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x86.ActiveCfg = Release|Any CPU
59-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028}.Release|x86.Build.0 = Release|Any CPU
6040
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|Any CPU.ActiveCfg = Release|Any CPU
6141
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|Any CPU.Build.0 = Release|Any CPU
6242
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3}.CoreCLR|x64.ActiveCfg = Release|Any CPU
@@ -170,7 +150,6 @@ Global
170150
HideSolutionNode = FALSE
171151
EndGlobalSection
172152
GlobalSection(NestedProjects) = preSolution
173-
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
174153
{8ED116F4-9DDF-4C49-AB96-AE462E3D64C3} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
175154
{6A20B9E9-DE66-456E-B4F5-ACFD1A95C3CA} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}
176155
{3B38E8DA-8BFF-4264-AF16-47929E6398A3} = {F594E7FD-1E72-4E51-A496-B019C2BA3180}

src/PowerShellEditorServices.Hosting/PowerShellEditorServices.Hosting.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
55
<AssemblyName>Microsoft.PowerShell.EditorServices.Hosting</AssemblyName>
66
<LangVersion>latest</LangVersion>
77
</PropertyGroup>
88

9-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
9+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
1010
<DefineConstants>$(DefineConstants);CoreCLR</DefineConstants>
1111
</PropertyGroup>
1212

src/PowerShellEditorServices/Utility/VersionUtils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ internal static class VersionUtils
5050
public static bool IsPS7OrGreater { get; } = PSVersion.Major >= 7;
5151

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

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

6262
/// <summary>
63-
/// True if we are running in on Linux, false otherwise.
63+
/// True if we are running on Linux, false otherwise.
6464
/// </summary>
6565
public static bool IsLinux { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
6666
}

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.IO;
1010
using System.Linq;
1111
using System.Reflection;
12+
using System.Runtime.InteropServices;
1213
using System.Text;
1314
using System.Threading;
1415
using System.Threading.Tasks;
@@ -31,6 +32,9 @@ namespace PowerShellEditorServices.Test.E2E
3132
{
3233
public class LanguageServerProtocolMessageTests : IClassFixture<LSPTestsFixture>, IDisposable
3334
{
35+
// Borrowed from `VersionUtils` which can't be used here due to an initialization problem.
36+
private static bool IsLinux { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
37+
3438
private readonly static string s_binDir =
3539
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
3640

@@ -924,9 +928,10 @@ await PsesLanguageClient
924928
}
925929

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

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

952957
[Trait("Category", "LSP")]
953-
[Fact]
958+
[SkippableFact]
954959
public async Task CanSendCompletionResolveWithModulePrefixRequestAsync()
955960
{
961+
Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
956962
await PsesLanguageClient
957963
.SendRequest<EvaluateRequestArguments>(
958964
"evaluate",
@@ -985,9 +991,10 @@ await PsesLanguageClient
985991
}
986992

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

9931000
Hover hover = await PsesLanguageClient.TextDocument.RequestHover(

test/PowerShellEditorServices.Test.E2E/PowerShellEditorServices.Test.E2E.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
5-
4+
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
65
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

test/PowerShellEditorServices.Test.Host/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/PowerShellEditorServices.Test.Host/AssemblyInfo.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)