Skip to content
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
9 changes: 3 additions & 6 deletions .github/workflows/module.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: Module

# Tests the kit built as a PowerShell module, and packs it for the PowerShell
# Gallery. Nothing is published: the package is kept with the run. Before a
# release (a version's branch is release/X.Y or version/X.Y) it runs the whole
# harness on the module. On a published release, by hand, and on a pull request
# that changes the build, it runs the sections where loading can matter. Not a
# required check.
# Tests the kit as a module and packs it for the Gallery (kept with the run, not
# published): the whole harness on a push to a release/ or version/ branch, the
# module sections (-Section MODULE) on everything else.
on:
push:
branches: ['release/**', 'version/**']
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-asset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ permissions:
jobs:
attach:
name: Attach ParallelKit.ps1
# Windows, so the attached file has Windows (CRLF) line endings.
# Windows, for powershell.exe; the file's CRLF line endings come from
# .gitattributes.
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ permissions:
# Ctrl+C/window-close checks must run here: a skip counts as a failure.
env:
PK_HARNESS_NO_SKIP: '1'
# A harness with no new assertion for this many minutes is dumped and
# killed by its own watchdog (the longest quiet stretch is about 20 s), so
# a hang fails its step with a dump to upload, instead of running into the
# job's time limit with nothing.
# A run with no new assertion for this long is dumped and killed by its own
# watchdog, so a hang fails its step with a dump to upload.
PK_HARNESS_WATCHDOG_MINUTES: '2'

jobs:
Expand All @@ -27,8 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v7

# Windows PowerShell 5.1 (shell: powershell), the version the kit targets.
# A fresh powershell.exe so the kit's compiled types load clean.
# A fresh powershell.exe: a session keeps the C# types it compiled first.
- name: Run ParallelKit.Harness.ps1
timeout-minutes: 14
shell: powershell
Expand All @@ -48,12 +45,10 @@ jobs:
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\ParallelKit.Harness.ps1 -AsModule -Section MODULE
exit $LASTEXITCODE

# A section AH case that ran past its time limit leaves a full dump of
# its process there, for a debugger, and so does the harness itself
# when its watchdog finds it hung. Nothing is uploaded if none did.
# Cancelled too: a job that runs into its time limit is cancelled, not
# failed. The same in harness-pwsh below and both jobs of module.yml. The
# folder is set per step because a job's env can't use the runner context.
# Dumps of a harness case (section AH) or of the harness itself that hung,
# if any; also on a canceled (timed-out) job. The same in harness-pwsh and
# module.yml's jobs; the folder is set per step, as a job's env can't use
# the runner context.
- name: Upload the dumps of cases that hung
if: failure() || cancelled()
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -99,10 +94,8 @@ jobs:
if-no-files-found: ignore
retention-days: 7

# The C# in Source/: ParallelKit.ps1 carries the same code, and it compiles
# with no warnings as C# 5 with the .NET Framework's compiler (Add-Type's on
# Windows PowerShell 5.1), and with the .NET SDK for the .NET pwsh runs on,
# with the analyzer rules the script lists.
# Source/'s C# matches ParallelKit.ps1's copy and compiles warning-free as C# 5
# with both .NET Framework's compiler and the .NET SDK.
csharp:
name: C#
runs-on: windows-latest
Expand Down
15 changes: 8 additions & 7 deletions Build/New-ParallelKitModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ try {
$SourcePath = (Get-Item -LiteralPath $SourcePath).FullName
$OutputDirectory = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputDirectory)

# The .ps1 is ASCII, which 5.1 and 7 read alike without a BOM.
# The .ps1 must be ASCII: without a byte-order mark, 5.1 and 7 read other
# bytes differently.
$bytes = [System.IO.File]::ReadAllBytes($SourcePath)
for ($i = 0; $i -lt $bytes.Length; $i++) {
if ($bytes[$i] -gt 127) { Stop-PkBuild ("byte " + $i + " isn't ASCII. 5.1 and 7 would read the file differently.") }
Expand All @@ -80,7 +81,8 @@ try {
$lines = $source.TrimEnd("`n").Split("`n")
$sourceAst = Get-PkBuildAst -Text $source -What 'the file'

# The three lines, in their places.
# Each wrapper line once: New-Module right after Remove-Module, and the
# closing line last.
$removeAt = Get-PkBuildLineIndex -Lines $lines -Text $removeLine
$openAt = Get-PkBuildLineIndex -Lines $lines -Text $openLine
$closeAt = Get-PkBuildLineIndex -Lines $lines -Text $closeLine
Expand Down Expand Up @@ -131,11 +133,10 @@ try {
if ($header.Count -ne 1 -or $inCode.Count -ne 1) { Stop-PkBuild ("expected one '# Version X.Y' line and one `$version = [version]'X.Y' line, found " + $header.Count + " and " + $inCode.Count + ".") }
$version = $header[0].Groups[1].Value
if ($version -cne $inCode[0].Groups[1].Value) { Stop-PkBuild ("the header says version " + $version + " and Initialize-ParallelKit " + $inCode[0].Groups[1].Value + ".") }
# Three parts in the manifest. The package gets three whatever the manifest
# says, Windows PowerShell's built-in PowerShellGet installs into a folder
# named after the package's version, and PowerShell doesn't find a module
# whose version folder isn't its manifest's version. The harness works the
# same version out for its module folder (Get-HarnessModuleVersion).
# Three parts in the manifest: the package always gets three, Windows
# PowerShell's PowerShellGet installs it in a folder named after that, and
# PowerShell only finds a module whose folder name matches its manifest's
# version. The harness works it out the same way (Get-HarnessModuleVersion).
$moduleVersion = $version
if ($moduleVersion -notmatch '^\d+\.\d+\.\d+$') { $moduleVersion += '.0' }

Expand Down
11 changes: 6 additions & 5 deletions Build/Update-ParallelKitCSharp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ try {
if ($null -eq $dotnet) { throw "Update-ParallelKitCSharp: -Compile needs the .NET SDK (dotnet) on PATH." }
$runtime = (& $pwsh.Source -NoProfile -Command '[Environment]::Version.ToString(2)').Trim()
$targetFramework = 'net' + $runtime
# Analyzer rules checked on top of the compiler's own warnings: ones about
# real faults, all clean today. Left out on purpose: style rules, and ones
# this code breaks deliberately (catch-all handlers that report the
# failure; DllImport of kernel32, a KnownDLL; handles a catch block
# releases, which the dispose rule can't follow).
# Analyzer rules checked on top of the compiler's warnings: ones about real
# faults. Left out on purpose: style rules, and ones this code breaks
# deliberately: catch-all handlers that report the failure, DllImport
# without a search-path attribute (kernel32 is a KnownDLL, always loaded
# from System32), and handles a catch block releases, which the dispose rule
# can't follow.
$rules = @('CA1069', 'CA2002', 'CA2011', 'CA2013', 'CA2101', 'CA2200', 'CA2201', 'CA2208', 'CA2213', 'CA2216', 'CA2219', 'CA2241')
$config = @('is_global = true') + @($rules | ForEach-Object { 'dotnet_diagnostic.' + $_ + '.severity = warning' })
foreach ($source in $sources) {
Expand Down
Loading