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
63 changes: 57 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
# Do not add a global autocrlf rule for these paths.
package/docs/** linguist-documentation

# Owner-signed files (eight PowerShell files and the manifest); cr-at-eol because their working-tree line endings are CRLF.
# Frozen Windows PowerShell 5.1 fixtures of 2.2.0: byte-exact, never converted (their SHA-256 are listed in fixtures.sha256; the folder also carries its own .gitattributes).
tests/fixtures/** -text

# Owner-signed files (ten PowerShell files, the module manifest included, and the inventory manifest); cr-at-eol because their working-tree line endings are CRLF.
package/Invoke-PraRemoteMailbox.ps1 -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/PraRemoteMailbox.psd1 -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/PraRemoteMailbox.psm1 -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/module/PRA.Common.psm1 -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/module/PRA.Directory.psm1 -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/module/PRA.Backup.psm1 -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
Expand All @@ -22,19 +27,65 @@ package/README.md -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr
package/LICENSE -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/docs/PraRemoteMailbox-Guide.html -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/docs/PraRemoteMailbox-Guide.md -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/docs/images/console-apply.png -text
package/docs/images/console-preview.png -text
package/docs/images/gui-fluent.png -text
package/docs/PraRemoteMailbox-UserGuide.html -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/docs/PraRemoteMailbox-UserGuide.md -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
package/docs/images/console-next-cloud-light.png -text
package/docs/images/console-next-global-light.png -text
package/docs/images/console-next-light.png -text
package/docs/images/console-next-package-light.png -text
package/docs/images/console-next-rollback-light.png -text
package/docs/images/console-run-cloud-light.png -text
package/docs/images/console-run-early-light.png -text
package/docs/images/console-run-finished-dark.png -text
package/docs/images/console-run-finished-light.png -text
package/docs/images/console-run-grant-light.png -text
package/docs/images/console-run-package-light.png -text
package/docs/images/console-run-rollback-light.png -text
package/docs/images/console-run-waiting-light.png -text
package/docs/images/console-settings-light.png -text
package/docs/images/console-setup-dark.png -text
package/docs/images/console-setup-light.png -text
package/docs/images/console-setup-lights-light.png -text
package/docs/images/console-setup-next-light.png -text
package/docs/images/console-setup-red-light.png -text
package/docs/images/console-setup-red-lights-light.png -text
package/docs/images/console-task-ad-light.png -text
package/docs/images/console-task-check-light.png -text
package/docs/images/console-task-continue-light.png -text
package/docs/images/console-task-finalize-light.png -text
package/docs/images/console-task-identity-light.png -text
package/docs/images/console-task-light.png -text
package/docs/images/console-task-package-selected-light.png -text
package/docs/images/console-task-rollback-light.png -text
package/docs/images/console-task-rollback-selected-light.png -text
package/docs/images/console-task-scope-light.png -text
package/docs/images/console-verify-before-light.png -text
package/docs/images/console-verify-check-light.png -text
package/docs/images/console-verify-cloud-light.png -text
package/docs/images/console-verify-light.png -text
package/docs/images/console-verify-rollback-light.png -text
package/docs/images/console-verify-scope-light.png -text
package/docs/images/guide-dictionary-light.png -text
package/docs/images/readme-banner-dark.png -text
package/docs/images/readme-banner-light.png -text
package/docs/images/readme-flows-dark.png -text
package/docs/images/readme-flows-light.png -text
package/docs/images/readme-how-dark.png -text
package/docs/images/readme-how-light.png -text
package/docs/images/readme-path-dark.png -text
package/docs/images/readme-path-light.png -text
package/docs/images/readme-permissions-dark.png -text
package/docs/images/readme-permissions-light.png -text
package/docs/images/readme-principles-dark.png -text
package/docs/images/readme-principles-light.png -text
package/docs/images/report-warning.png -text
package/docs/images/report.png -text
package/docs/images/readme-rights-dark.png -text
package/docs/images/readme-rights-light.png -text
package/docs/images/readme-transfer-dark.png -text
package/docs/images/readme-transfer-light.png -text
package/docs/images/readme-why-dark.png -text
package/docs/images/readme-why-light.png -text
package/docs/images/report-global-light.png -text
package/docs/images/report-global-recover-light.png -text
package/docs/images/report-phase-light.png -text
package/docs/images/report-phase-warning-light.png -text
CHANGELOG.md -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol
4 changes: 3 additions & 1 deletion .github/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"tests/PraRemoteMailbox.Tests.ps1",
"tests/PraRemoteMailbox.Gui.Tests.ps1",
"tests/PackageIntegrity.Tests.ps1",
"tests/PraReport.Tests.ps1"
"tests/PraReport.Tests.ps1",
"tests/PraLegacyFixtures.Tests.ps1",
"tests/PraDocumentation.Tests.ps1"
],
"packageBuilder": "tools/New-PraPackage.ps1",
"packageEntry": "Invoke-PraRemoteMailbox.ps1"
Expand Down
51 changes: 51 additions & 0 deletions .github/scripts/Install-PowerShell.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#Requires -Version 5.1
<#
.SYNOPSIS
CI only. Makes sure that the pwsh used by the next steps is PowerShell 7.5 or later (the engine requires 7.5+).
.DESCRIPTION
The GitHub-hosted Windows images ship PowerShell 7.4. If pwsh on PATH is older than 7.5, the pinned release below is
downloaded from the official PowerShell release page, its SHA-256 is checked against the value pinned here (the same value
appears in the hashes.sha256 asset of the release), it is extracted under RUNNER_TEMP and put first on PATH for the
following steps. A full extracted copy keeps pwsh.exe inside $PSHOME, which the engine needs to start its child processes.
It does not connect to a lab or use publication credentials.
#>
[CmdletBinding()]
param(
[string]$Version = '7.5.13',
[string]$Sha256 = '120B8F0B04F3B3F6E8C351DDBE568BF596CDCA15EEB2ECB7E724060051A36D65'
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$minimum = [version]'7.5.0'

function Get-PwshVersion {
$command = Get-Command pwsh -ErrorAction SilentlyContinue
if (-not $command) { return $null }
$text = & $command.Source -NoProfile -NonInteractive -Command '$PSVersionTable.PSVersion.ToString()'
if ($LASTEXITCODE -ne 0) { return $null }
return [version](($text | Select-Object -First 1) -replace '[-+].*$', '')
}

$current = Get-PwshVersion
if ($current -and $current -ge $minimum) {
Write-Output ('pwsh {0} already satisfies PowerShell 7.5+.' -f $current)
return
}

$runnerTemp = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { [IO.Path]::GetTempPath() }
$zip = Join-Path $runnerTemp ('PowerShell-{0}-win-x64.zip' -f $Version)
$destination = Join-Path $runnerTemp ('pwsh-{0}' -f $Version)
$uri = 'https://github.com/PowerShell/PowerShell/releases/download/v{0}/PowerShell-{0}-win-x64.zip' -f $Version
Invoke-WebRequest -Uri $uri -OutFile $zip -UseBasicParsing
$actual = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash
if (-not [string]::Equals($actual, $Sha256, [StringComparison]::OrdinalIgnoreCase)) {
Remove-Item -LiteralPath $zip -Force
throw "The downloaded PowerShell archive does not match the pinned SHA-256 ($actual)."
}
if (Test-Path -LiteralPath $destination) { throw "The destination already exists and will not be overwritten: $destination" }
Expand-Archive -LiteralPath $zip -DestinationPath $destination
if (-not (Test-Path -LiteralPath (Join-Path $destination 'pwsh.exe') -PathType Leaf)) { throw 'The archive does not contain pwsh.exe.' }
if (-not $env:GITHUB_PATH) { throw 'The GitHub Actions path file is missing.' }
$destination | Out-File -LiteralPath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Output ('PowerShell {0} extracted to {1} and added to PATH for the next steps.' -f $Version, $destination)
24 changes: 10 additions & 14 deletions .github/scripts/Invoke-CI.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 5.1
#Requires -Version 7.5
[CmdletBinding()]
param(
[Parameter(Mandatory)][ValidateSet('Analyze', 'Test', 'Package')][string]$Stage,
Expand All @@ -8,11 +8,6 @@ param(

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if ($PSVersionTable.PSEdition -eq 'Desktop') {
foreach ($name in 'Microsoft.PowerShell.Utility', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Security') {
Import-Module (Join-Path $PSHOME ('Modules\{0}\{0}.psd1' -f $name)) -ErrorAction Stop
}
}
$root = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
$configuration = Get-Content -LiteralPath (Join-Path $root '.github\ci.json') -Raw | ConvertFrom-Json
$OutputDirectory = [IO.Path]::GetFullPath($OutputDirectory)
Expand All @@ -39,11 +34,14 @@ switch ($Stage) {
$tracked = @(git -C $root ls-files -- '*.ps1' '*.psm1' '*.psd1')
if ($LASTEXITCODE -ne 0) { throw 'Cannot enumerate the tracked PowerShell sources.' }
$runtime = [string]$configuration.runtimeRoot
$files = @($tracked | Where-Object {
$runtimeFiles = @($tracked | Where-Object {
($_ -notmatch '^(tests|tools|lib|\.github)/') -and
($runtime -eq '.' -or $_.StartsWith($runtime.TrimEnd('/') + '/', [StringComparison]::Ordinal))
})
if ($files.Count -eq 0) { throw 'No tracked runtime PowerShell sources were found.' }
if ($runtimeFiles.Count -eq 0) { throw 'No tracked runtime PowerShell sources were found.' }
# Tests and tools are analysed too (advisory, same policy as the runtime); they are not part of the package.
$supportFiles = @($tracked | Where-Object { $_ -match '^(tests|tools)/' })
$files = @($runtimeFiles) + @($supportFiles)
$parseFailures = @()
$findings = @(foreach ($relative in $files) {
$path = Resolve-RepositoryFile $relative
Expand All @@ -57,7 +55,7 @@ switch ($Stage) {
}
foreach ($finding in @(Invoke-ScriptAnalyzer -Path $path -ErrorAction Stop)) {
[pscustomobject]@{
File = $relative; Line = $finding.Line; Column = $finding.Column
File = $relative; Scope = $(if ($relative -in $runtimeFiles) { 'runtime' } else { 'tests-tools' }); Line = $finding.Line; Column = $finding.Column
Severity = [string]$finding.Severity; Rule = $finding.RuleName; Message = $finding.Message
}
}
Expand All @@ -67,7 +65,7 @@ switch ($Stage) {
ConvertTo-Json -InputObject $parseFailures -Depth 5 |
Out-File -LiteralPath (Join-Path $OutputDirectory 'syntax-errors.json') -Encoding utf8
$summary = [ordered]@{
Files = $files.Count; Analyzer = '1.25.0'; SyntaxErrors = $parseFailures.Count
Files = $files.Count; RuntimeFiles = $runtimeFiles.Count; TestAndToolFiles = $supportFiles.Count; Analyzer = '1.25.0'; SyntaxErrors = $parseFailures.Count
Errors = @($findings | Where-Object Severity -eq 'Error').Count
Warnings = @($findings | Where-Object Severity -eq 'Warning').Count
Informative = @($findings | Where-Object Severity -eq 'Information').Count
Expand All @@ -76,15 +74,13 @@ switch ($Stage) {
$summary | ConvertTo-Json |
Out-File -LiteralPath (Join-Path $OutputDirectory 'analysis-summary.json') -Encoding utf8
Write-Output ($summary | ConvertTo-Json -Compress)
if ($parseFailures.Count) { throw 'Runtime PowerShell sources contain syntax errors.' }
if ($parseFailures.Count) { throw 'PowerShell sources (runtime, tests or tools) contain syntax errors.' }
}
'Test' {
Import-Module Pester -RequiredVersion 6.1.0 -Force -ErrorAction Stop
if ($configuration.testMode -eq 'gate') {
$gate = Resolve-RepositoryFile $configuration.testEntry
$executable = if ($PSVersionTable.PSEdition -eq 'Desktop') {
Join-Path $PSHOME 'powershell.exe'
} else { Join-Path $PSHOME 'pwsh.exe' }
$executable = Join-Path $PSHOME 'pwsh.exe'
& $executable -NoProfile -NonInteractive -File $gate
if ($LASTEXITCODE -ne 0) { throw "The existing project test gate failed with exit code $LASTEXITCODE." }
} elseif ($configuration.testMode -eq 'runner') {
Expand Down
42 changes: 17 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,51 @@ jobs:
validate:
name: Validate (${{ matrix.engine }})
runs-on: windows-2022
timeout-minutes: 35
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
include: [{"engine":"Windows PowerShell 5.1","shell":"powershell","package":true}]
include: [{"engine":"PowerShell 7","shell":"pwsh","package":true}]
steps:
- name: Check out the tested revision
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false

- name: Ensure PowerShell 7.5 or later (the engine requires it; the image ships 7.4)
shell: pwsh
run: .\.github\scripts\Install-PowerShell.ps1

- name: Show the PowerShell that runs the next steps
shell: pwsh
run: |
$PSVersionTable.PSVersion.ToString()
$PSHOME
if ($PSVersionTable.PSVersion -lt [version]'7.5.0') { throw 'PowerShell 7.5+ is required.' }

- name: Load pinned analysis and test modules
shell: pwsh
run: .\.github\scripts\Initialize-CIModules.ps1 -Destination "$env:RUNNER_TEMP\ci-modules"

- name: Analyze PowerShell sources (PowerShell 7)
if: matrix.shell == 'pwsh'
- name: Analyze PowerShell sources (PowerShell 7.5)
shell: pwsh
run: .\.github\scripts\Invoke-CI.ps1 -Stage Analyze -OutputDirectory "$env:RUNNER_TEMP\ci-results"

- name: Analyze PowerShell sources (Windows PowerShell 5.1)
if: matrix.shell == 'powershell'
shell: powershell
run: .\.github\scripts\Invoke-CI.ps1 -Stage Analyze -OutputDirectory "$env:RUNNER_TEMP\ci-results"

- name: Run the existing project tests (PowerShell 7)
if: matrix.shell == 'pwsh'
- name: Run the existing project tests (PowerShell 7.5)
shell: pwsh
run: .\.github\scripts\Invoke-CI.ps1 -Stage Test -OutputDirectory "$env:RUNNER_TEMP\ci-results"

- name: Run the existing project tests (Windows PowerShell 5.1)
if: matrix.shell == 'powershell'
shell: powershell
run: .\.github\scripts\Invoke-CI.ps1 -Stage Test -OutputDirectory "$env:RUNNER_TEMP\ci-results"

- name: Build with the existing package tool (PowerShell 7)
if: matrix.package && matrix.shell == 'pwsh'
- name: Build with the existing package tool (PowerShell 7.5)
shell: pwsh
run: .\.github\scripts\Invoke-CI.ps1 -Stage Package -OutputDirectory "$env:RUNNER_TEMP\ci-results"

- name: Build with the existing package tool (Windows PowerShell 5.1)
if: matrix.package && matrix.shell == 'powershell'
shell: powershell
run: .\.github\scripts\Invoke-CI.ps1 -Stage Package -OutputDirectory "$env:RUNNER_TEMP\ci-results"

- name: Retain public CI evidence
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: ci-${{ matrix.engine }}
name: ci-powershell-7.5
path: |
${{ runner.temp }}/ci-results
artifacts/pester-results.xml
tests/evidence/gate
if-no-files-found: error
retention-days: 7
Loading
Loading