Skip to content

Add PowerShell 7.3 to test matrix #1955

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 5 commits into from
Nov 10, 2022
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
3 changes: 3 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dotnet
uses: actions/setup-dotnet@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/emacs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dotnet
uses: actions/setup-dotnet@v3

- name: Build PSES
shell: pwsh
run: tools/azurePipelinesBuild.ps1
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/vim-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dotnet
uses: actions/setup-dotnet@v3

- name: Build PSES
shell: pwsh
run: tools/azurePipelinesBuild.ps1
Expand Down
9 changes: 8 additions & 1 deletion .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ steps:
pwsh: ${{ parameters.pwsh }}

- task: UseDotNet@2
displayName: Install .NET 6.0.x SDK
displayName: Install .NET 7.0.x SDK
inputs:
packageType: sdk
version: 7.0.x
performMultiLevelLookup: true

- task: UseDotNet@2
displayName: Install .NET 6.0.x runtime
inputs:
packageType: runtime
version: 6.0.x
performMultiLevelLookup: true

Expand Down
45 changes: 25 additions & 20 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditor
$script:NetRuntime = @{
PS7 = 'netcoreapp3.1'
PS72 = 'net6.0'
PS73 = 'net7.0'
Desktop = 'net462'
Standard = 'netstandard2.0'
}
Expand Down Expand Up @@ -73,24 +74,24 @@ Task FindDotNet {
}

Task BinClean {
Remove-Item $PSScriptRoot\.tmp -Recurse -Force -ErrorAction Ignore
Remove-Item $PSScriptRoot\module\PowerShellEditorServices\bin -Recurse -Force -ErrorAction Ignore
Remove-Item $PSScriptRoot\module\PowerShellEditorServices.VSCode\bin -Recurse -Force -ErrorAction Ignore
Remove-BuildItem $PSScriptRoot\.tmp
Remove-BuildItem $PSScriptRoot\module\PowerShellEditorServices\bin
Remove-BuildItem $PSScriptRoot\module\PowerShellEditorServices.VSCode\bin
}

Task Clean FindDotNet, BinClean, {
Exec { & dotnet clean $VerbosityArgs }
Get-ChildItem -Recurse $PSScriptRoot\src\*.nupkg | Remove-Item -Force -ErrorAction Ignore
Get-ChildItem $PSScriptRoot\PowerShellEditorServices*.zip | Remove-Item -Force -ErrorAction Ignore
Get-ChildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml | Remove-Item -Force -ErrorAction Ignore
Invoke-BuildExec { & dotnet clean $VerbosityArgs }
Get-ChildItem -Recurse $PSScriptRoot\src\*.nupkg | Remove-BuildItem
Get-ChildItem $PSScriptRoot\PowerShellEditorServices*.zip | Remove-BuildItem
Get-ChildItem $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US\*-help.xml | Remove-BuildItem

# Remove bundled component modules
$moduleJsonPath = "$PSScriptRoot\modules.json"
if (Test-Path $moduleJsonPath) {
Get-Content -Raw $moduleJsonPath |
ConvertFrom-Json |
ForEach-Object { $_.PSObject.Properties.Name } |
ForEach-Object { Remove-Item -Path "$PSScriptRoot/module/$_" -Recurse -Force -ErrorAction Ignore }
ForEach-Object { Remove-BuildItem -Path "$PSScriptRoot/module/$_" }
}
}

Expand Down Expand Up @@ -161,20 +162,20 @@ Task SetupHelpForTests {
}

Task Build FindDotNet, CreateBuildInfo, {
Exec { & dotnet restore $VerbosityArgs }
Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 }
Invoke-BuildExec { & dotnet restore $VerbosityArgs }
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script:NetRuntime.Standard }
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.PS7 }
if (-not $script:IsNix) {
Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script:NetRuntime.Desktop }
}

# Build PowerShellEditorServices.VSCode module
Exec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard }
Invoke-BuildExec { & dotnet publish $VerbosityArgs -c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script:NetRuntime.Standard }
}

Task Test TestServer, TestE2E

Task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
Task TestServer TestServerWinPS, TestServerPS7, TestServerPS72, TestServerPS73

# NOTE: While these can run under `pwsh.exe` we only want them to run under
# `powershell.exe` so that the CI time isn't doubled.
Expand All @@ -184,25 +185,29 @@ Task TestServerWinPS -If ($PSVersionTable.PSEdition -eq "Desktop") Build, SetupH
# that is debuggable! If architecture is added, the assembly path gets an
# additional folder, necesstiating fixes to find the commands definition
# file and test files.
Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.Desktop }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.Desktop }
}

Task TestServerPS7 -If ($PSVersionTable.PSEdition -eq "Core" -and -not $script:IsAppleM1 -and -not $script:IsArm64) Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS7 }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS7 }
}

Task TestServerPS72 -If ($PSVersionTable.PSEdition -eq "Core") Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 }
}

Task TestServerPS73 -If ($PSVersionTable.PSEdition -eq "Core") Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test\
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS73 }
}

Task TestE2E Build, SetupHelpForTests, {
Set-Location .\test\PowerShellEditorServices.Test.E2E\

$env:PWSH_EXE_NAME = if ($IsCoreCLR) { "pwsh" } else { "powershell" }
$NetRuntime = if ($IsAppleM1 -or $script:IsArm64) { $script:NetRuntime.PS72 } else { $script:NetRuntime.PS7 }
Exec { & dotnet $script:dotnetTestArgs $NetRuntime }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 }

if (!$script:IsNix) {
if (-not [Security.Principal.WindowsIdentity]::GetCurrent().Owner.IsWellKnown("BuiltInAdministratorsSid")) {
Expand All @@ -213,7 +218,7 @@ Task TestE2E Build, SetupHelpForTests, {
try {
Write-Host "Running end-to-end tests in Constrained Language Mode."
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", "0x80000007", [System.EnvironmentVariableTarget]::Machine);
Exec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS7 }
Invoke-BuildExec { & dotnet $script:dotnetTestArgs $script:NetRuntime.PS72 }
} finally {
[System.Environment]::SetEnvironmentVariable("__PSLockdownPolicy", $null, [System.EnvironmentVariableTarget]::Machine);
}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0",
"version": "7.0.100",
"rollForward": "latestFeature",
"allowPrerelease": true
}
Expand Down
4 changes: 3 additions & 1 deletion src/PowerShellEditorServices/Utility/FormatUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ internal static class FormatUtils

private const string Static = "static ";

private static HashSet<string>? usingNamespaces;

/// <summary>
/// Space, new line, carriage return and tab.
/// </summary>
Expand Down Expand Up @@ -164,9 +166,9 @@ private static string GetMethodDocumentation(ReadOnlySpan<char> toolTip, out Mar
{
kind = MarkupKind.Markdown;
StringBuilder text = new();
HashSet<string>? usingNamespaces = null;
while (true)
{
usingNamespaces = null;
toolTip = toolTip.TrimStart(s_whiteSpace.Span);
toolTip = ProcessMethod(toolTip, text, ref usingNamespaces);
if (toolTip.IsEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ internal class LoggingStream : Stream

public LoggingStream(Stream underlyingStream) => _underlyingStream = underlyingStream;

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_underlyingStream.Dispose();
}
}

public override bool CanRead => _underlyingStream.CanRead;

public override bool CanSeek => _underlyingStream.CanSeek;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net462</TargetFrameworks>
<AssemblyName>Microsoft.PowerShell.EditorServices.Test</AssemblyName>
<TargetPlatform>x64</TargetPlatform>
</PropertyGroup>
Expand All @@ -12,20 +12,30 @@
<ProjectReference Include="..\PowerShellEditorServices.Test.Shared\PowerShellEditorServices.Test.Shared.csproj" />
</ItemGroup>

<!-- This is for testing PowerShell 7.2 LTS -->
<!-- Latest PowerShell -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.3.0" />
</ItemGroup>

<!-- PowerShell LTS-Current -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.7" />
</ItemGroup>

<!-- This is for testing PowerShell 7.0 LTS and so needs to be 7.0.x -->
<!-- PowerShell LTS -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.13" />
</ItemGroup>

<!-- Windows PowerShell 5.1 -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' != 'net462' ">
<DefineConstants>$(DefineConstants);CoreCLR</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
Expand All @@ -48,7 +58,4 @@
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' != 'net462' ">
<DefineConstants>$(DefineConstants);CoreCLR</DefineConstants>
</PropertyGroup>
</Project>