Skip to content

Commit f0c4c8b

Browse files
committed
WIP: Modernizing CI
1 parent ceaad10 commit f0c4c8b

File tree

13 files changed

+108
-54
lines changed

13 files changed

+108
-54
lines changed

.github/workflows/ci-test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
ci:
11+
name: dotnet
12+
strategy:
13+
matrix:
14+
os: [ windows-latest, macos-latest, ubuntu-latest ]
15+
runs-on: ${{ matrix.os }}
16+
env:
17+
DOTNET_NOLOGO: true
18+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install dotnet
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
cache: true
27+
cache-dependency-path: '**/*.csproj'
28+
global-json-file: ./global.json
29+
30+
- name: Install PSResources
31+
shell: pwsh
32+
run: ./tools/installPSResources.ps1
33+
34+
- name: Build, test, and package
35+
shell: pwsh
36+
run: Invoke-Build -Configuration Release -TestFramework net8.0 RunTests, ZipRelease
37+
38+
- name: Upload build artifacts
39+
if: always()
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: PSReadLine-module-${{ matrix.os }}
43+
path: bin/Release/PSReadLine.zip
44+
45+
- name: Upload test results
46+
uses: actions/upload-artifact@v4
47+
if: always()
48+
with:
49+
name: PSReadLine-test-results-${{ matrix.os }}
50+
path: test/TestResults/xUnitTestResults.en-US.xml

MockPSConsole/MockPSConsole.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<OutputType>Exe</OutputType>
55
<RootNamespace>MockPSConsole</RootNamespace>
66
<AssemblyName>MockPSConsole</AssemblyName>
7-
<TargetFrameworks>net472;net6.0</TargetFrameworks>
7+
<TargetFrameworks>net472;net8.0</TargetFrameworks>
88
<FileAlignment>512</FileAlignment>
99
<ApplicationManifest>Program.manifest</ApplicationManifest>
1010
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
@@ -14,8 +14,8 @@
1414
<PackageReference Include="PowerShellStandard.Library" version="5.1.0" />
1515
</ItemGroup>
1616

17-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
18-
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.2.24" />
17+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
18+
<PackageReference Include="Microsoft.PowerShell.SDK" version="7.4.11" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

PSReadLine.build.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ param(
1919
[ValidateSet("Debug", "Release")]
2020
[string]$Configuration = (property Configuration Release),
2121

22-
[ValidateSet("net472", "net6.0")]
22+
[ValidateSet("net472", "net8.0")]
2323
[string]$TestFramework,
2424

2525
[switch]$CheckHelpContent
@@ -31,7 +31,7 @@ Import-Module "$PSScriptRoot/tools/helper.psm1"
3131
$targetDir = "bin/$Configuration/PSReadLine"
3232

3333
if (-not $TestFramework) {
34-
$TestFramework = $IsWindows ? "net472" : "net6.0"
34+
$TestFramework = $IsWindows ? "net472" : "net8.0"
3535
}
3636

3737
function ConvertTo-CRLF([string] $text) {
@@ -58,7 +58,7 @@ Synopsis: Build the Polyfiller assembly
5858
#>
5959
task BuildPolyfiller @polyFillerParams {
6060
exec { dotnet publish -c $Configuration -f 'netstandard2.0' Polyfill }
61-
exec { dotnet publish -c $Configuration -f 'net6.0' Polyfill }
61+
exec { dotnet publish -c $Configuration -f 'net8.0' Polyfill }
6262
}
6363

6464
<#
@@ -123,7 +123,7 @@ task LayoutModule BuildPolyfiller, BuildMainModule, {
123123
}
124124

125125
Copy-Item "Polyfill/bin/$Configuration/netstandard2.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/netstd" -Force
126-
Copy-Item "Polyfill/bin/$Configuration/net6.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/net6plus" -Force
126+
Copy-Item "Polyfill/bin/$Configuration/net8.0/Microsoft.PowerShell.PSReadLine.Polyfiller.dll" "$targetDir/net6plus" -Force
127127

128128
$binPath = "PSReadLine/bin/$Configuration/netstandard2.0/publish"
129129
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine.dll $targetDir

Polyfill/Polyfill.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<PropertyGroup>
44
<AssemblyName>Microsoft.PowerShell.PSReadLine.Polyfiller</AssemblyName>
55
<AssemblyVersion>1.0.0.0</AssemblyVersion>
6-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
6+
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
77
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
88
</PropertyGroup>
99

1010
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
1111
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
1212
</ItemGroup>
1313

14-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
15-
<PackageReference Include="System.Management.Automation" Version="7.2.24" />
14+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
15+
<PackageReference Include="System.Management.Automation" Version="7.4.11" />
1616
</ItemGroup>
1717

1818
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ The build script `build.ps1` can be used to bootstrap, build and test the projec
160160
* Build: `./build.ps1 -Configuration Debug`
161161
* Test:
162162
* Targeting .NET 4.7.2 (Windows only): `./build.ps1 -Test -Configuration Debug -Framework net472`
163-
* Targeting .NET 6.0: `./build.ps1 -Test -Configuration Debug -Framework net6.0`
163+
* Targeting .NET 6.0: `./build.ps1 -Test -Configuration Debug -Framework net8.0`
164164

165165
After build, the produced artifacts can be found at `<your-local-repo-root>/bin/Debug`.
166166

appveyor.yml

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

build.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Build the main module with the default configuration (Debug) targeting 'netstandard2.0'.
1717
.EXAMPLE
1818
PS > .\build.ps1 -Test
19-
Run xUnit tests with the default configuration (Debug) and the default target framework (net472 on Windows or net6.0 otherwise).
19+
Run xUnit tests with the default configuration (Debug) and the default target framework (net472 on Windows or net8.0 otherwise).
2020
.PARAMETER Clean
2121
Clean the local repo, but keep untracked files.
2222
.PARAMETER Bootstrap
@@ -28,10 +28,10 @@
2828
.PARAMETER Framework
2929
The target framework when testing:
3030
- net472: run tests with .NET Framework
31-
- net6.0: run tests with .NET 6.0
31+
- net8.0: run tests with .NET 6.0
3232
When not specified, the target framework is determined by the current OS platform:
3333
- use 'net472' on Windows
34-
- use 'net6.0' on Unix platforms
34+
- use 'net8.0' on Unix platforms
3535
#>
3636
[CmdletBinding(DefaultParameterSetName = 'default')]
3737
param(
@@ -48,7 +48,7 @@ param(
4848
[switch] $CheckHelpContent,
4949

5050
[Parameter(ParameterSetName = 'test')]
51-
[ValidateSet("net472", "net6.0")]
51+
[ValidateSet("net472", "net8.0")]
5252
[string] $Framework,
5353

5454
[Parameter(ParameterSetName = 'default')]

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.405",
4+
"rollForward": "latestFeature",
5+
"allowPrerelease": false
6+
}
7+
}

nuget.config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
<configuration>
33
<packageSources>
44
<clear />
5-
<add key="PowerShell_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
5+
<add key="PowerShellCore_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
66
</packageSources>
7-
<disabledPackageSources>
8-
<clear />
9-
</disabledPackageSources>
107
</configuration>

test/ConsoleFixture.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ public static IEnumerable<string> GetKeyboardLayoutList()
5252

5353
public static string GetKeyboardLayout()
5454
{
55+
// In CI environments like GitHub Actions, keyboard layout detection can fail
56+
// or return incorrect results. Default to en-US in these cases.
57+
if (Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == "true" ||
58+
Environment.GetEnvironmentVariable("TF_BUILD") == "true" ||
59+
!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
60+
{
61+
return "en-US";
62+
}
63+
5564
var layout = GetKeyboardLayout(GetWindowThreadProcessId(GetForegroundWindow(), out var processId));
5665
return GetLayoutNameFromHKL(layout);
5766
}
@@ -100,4 +109,3 @@ public override string ToString()
100109
}
101110
}
102111
}
103-

0 commit comments

Comments
 (0)