From 162b2978cf4c0857ad4996c2ca8b2a1f35e3e554 Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Tue, 27 Oct 2026 11:57:32 +1100 Subject: [PATCH 01/10] Return invariant date strings from date conversion #942 Change ConvertTo-DateTime to return yyyy-MM-dd strings instead of DateTime objects, omitting time components. Update help, output metadata, and tests to reflect the culture-independent output. --- Evergreen/Private/ConvertTo-DateTime.ps1 | 9 ++--- tests/Private/ConvertTo-DateTime.Tests.ps1 | 38 ++++++++++------------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Evergreen/Private/ConvertTo-DateTime.ps1 b/Evergreen/Private/ConvertTo-DateTime.ps1 index 30e860ca..ced3d10b 100644 --- a/Evergreen/Private/ConvertTo-DateTime.ps1 +++ b/Evergreen/Private/ConvertTo-DateTime.ps1 @@ -10,13 +10,13 @@ function ConvertTo-DateTime { back to the specified pattern using invariant culture if automatic parsing fails. Ambiguous dates are interpreted as month/day/year when automatically detected. Use -AutoDetect:$false to parse only with the specified pattern. - The returned DateTime object is formatted according to the culture of its consumer. + Returns the parsed date as an invariant yyyy-MM-dd string. .EXAMPLE ConvertTo-DateTime -DateTime "December 31, 2024 11:45 PM" .EXAMPLE ConvertTo-DateTime -DateTime "31/12/2024 23:45" -Pattern "dd/MM/yyyy HH:mm" #> - [OutputType([System.DateTime])] + [OutputType([System.String])] [CmdletBinding(SupportsShouldProcess = $false)] param ( [Parameter(Mandatory = $true, Position = 0)] @@ -81,6 +81,7 @@ function ConvertTo-DateTime { } } - Write-Verbose -Message "$($MyInvocation.MyCommand): Returning DateTime: [$Output]." - Write-Output -InputObject $Output + $FormattedDate = $Output.ToString("yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture) + Write-Verbose -Message "$($MyInvocation.MyCommand): Returning date: [$FormattedDate]." + Write-Output -InputObject $FormattedDate } diff --git a/tests/Private/ConvertTo-DateTime.Tests.ps1 b/tests/Private/ConvertTo-DateTime.Tests.ps1 index 0320d329..8088fb95 100644 --- a/tests/Private/ConvertTo-DateTime.Tests.ps1 +++ b/tests/Private/ConvertTo-DateTime.Tests.ps1 @@ -13,13 +13,13 @@ BeforeAll { } Describe -Name "ConvertTo-DateTime" { - Context "Convert a date/time string to a DateTime object" { - It "Preserves the date and time from the provided format" { + Context "Convert a date/time string to a formatted date string" { + It "Formats the parsed date as yyyy-MM-dd" { InModuleScope -ModuleName "Evergreen" { $Result = ConvertTo-DateTime -DateTime "2000/14/2 16:35:42" -Pattern "yyyy/d/M HH:mm:ss" - $Result | Should -BeOfType [System.DateTime] - $Result | Should -Be ([System.DateTime]::new(2000, 2, 14, 16, 35, 42)) + $Result | Should -BeOfType [System.String] + $Result | Should -Be "2000-02-14" } } @@ -34,9 +34,8 @@ Describe -Name "ConvertTo-DateTime" { [System.Threading.Thread]::CurrentThread.CurrentUICulture = $LocalCulture $Result = ConvertTo-DateTime -DateTime "12/31/2024 11:45:32 PM" -Pattern "MM/dd/yyyy hh:mm:ss tt" - $Result | Should -BeOfType [System.DateTime] - $Result | Should -Be ([System.DateTime]::new(2024, 12, 31, 23, 45, 32)) - $Result.ToString("d", $LocalCulture) | Should -Be "31/12/2024" + $Result | Should -BeOfType [System.String] + $Result | Should -Be "2024-12-31" } finally { [System.Threading.Thread]::CurrentThread.CurrentCulture = $OriginalCulture @@ -58,10 +57,10 @@ Describe -Name "ConvertTo-DateTime" { InModuleScope -ModuleName "Evergreen" { $Result = ConvertTo-DateTime -DateTime "12/31/2024" - $Result | Should -BeOfType [System.DateTime] - $Result | Should -Be ([System.DateTime]::new(2024, 12, 31)) + $Result | Should -BeOfType [System.String] + $Result | Should -Be "2024-12-31" ConvertTo-DateTime -DateTime "December 31, 2024 11:45 PM" | - Should -Be ([System.DateTime]::new(2024, 12, 31, 23, 45, 0)) + Should -Be "2024-12-31" } } } @@ -90,9 +89,8 @@ Describe -Name "ConvertTo-DateTime" { InModuleScope -ModuleName "Evergreen" -Parameters @{ InputDate = $InputDate; Expected = $Expected } { $Result = ConvertTo-DateTime -DateTime $InputDate - $Result | Should -BeOfType [System.DateTime] - $Result.Ticks | Should -Be $Expected.Ticks - $Result.Kind | Should -Be $Expected.Kind + $Result | Should -BeOfType [System.String] + $Result | Should -Be $Expected.ToString("yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture) } } @@ -107,14 +105,14 @@ Describe -Name "ConvertTo-DateTime" { foreach ($InputDate in @("December 31, 2024 11:45 PM", "12/31/2024 23:45:00", "2024-12-31T23:45:00")) { $Result = ConvertTo-DateTime -DateTime $InputDate - $Result | Should -BeOfType [System.DateTime] - $Result | Should -Be ([System.DateTime]::new(2024, 12, 31, 23, 45, 0)) + $Result | Should -BeOfType [System.String] + $Result | Should -Be "2024-12-31" } $AmbiguousResult = ConvertTo-DateTime -DateTime "04/05/2024" - $AmbiguousResult | Should -Be ([System.DateTime]::new(2024, 4, 5)) + $AmbiguousResult | Should -Be "2024-04-05" foreach ($InputDate in @("04/05/2024 11:45 PM", "04/05/2024 11:45:00 PM", "04/05/2024 23:45:00")) { ConvertTo-DateTime -DateTime $InputDate | - Should -Be ([System.DateTime]::new(2024, 4, 5, 23, 45, 0)) + Should -Be "2024-04-05" } } finally { @@ -134,21 +132,21 @@ Describe -Name "ConvertTo-DateTime" { It "Prefers automatic parsing over an explicit pattern" { InModuleScope -ModuleName "Evergreen" { ConvertTo-DateTime -DateTime "04/05/2024" -Pattern "dd/MM/yyyy" | - Should -Be ([System.DateTime]::new(2024, 4, 5)) + Should -Be "2024-04-05" } } It "Falls back to an explicit pattern when automatic parsing fails" { InModuleScope -ModuleName "Evergreen" { ConvertTo-DateTime -DateTime "2024|31|12" -Pattern "yyyy|dd|MM" -AutoDetect | - Should -Be ([System.DateTime]::new(2024, 12, 31)) + Should -Be "2024-12-31" } } It "Allows automatic parsing to be explicitly disabled" { InModuleScope -ModuleName "Evergreen" { ConvertTo-DateTime -DateTime "04/05/2024" -Pattern "dd/MM/yyyy" -AutoDetect:$false | - Should -Be ([System.DateTime]::new(2024, 5, 4)) + Should -Be "2024-05-04" { ConvertTo-DateTime -DateTime "December 31, 2024" -AutoDetect:$false } | Should -Throw "*Failed to parse date*" } From 997a352604a30ddcfad7053bf19355ca97cbad2b Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Thu, 5 Nov 2026 08:34:31 +1100 Subject: [PATCH 02/10] Add test validating Date output format Adds a Pester test to Get-EvergreenApp.Tests.ps1 asserting that any optional Date property in app output is a string in yyyy-MM-dd format. The test is skipped when retrieval fails, no output is returned, or the app does not emit a Date property. Also suppresses PSAvoidUsingConvertToSecureStringWithPlainText for the test file. --- tests/Public/Get-EvergreenApp.Tests.ps1 | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Public/Get-EvergreenApp.Tests.ps1 b/tests/Public/Get-EvergreenApp.Tests.ps1 index bd4966a2..8338fc98 100644 --- a/tests/Public/Get-EvergreenApp.Tests.ps1 +++ b/tests/Public/Get-EvergreenApp.Tests.ps1 @@ -5,6 +5,7 @@ [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This is OK for the test files.")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification = "Outputs to log host.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { @@ -107,6 +108,31 @@ Describe -Tag "Get" -Name "Get-EvergreenApp works with supported application: should return Date values as yyyy-MM-dd strings" { + if ($null -ne $RetrievalError -or $null -eq $Output -or @($Output).Count -eq 0) { + Set-ItResult -Skipped -Because "Get-EvergreenApp did not return output for '$application'." + return + } + + $ItemsWithDates = @($Output | Where-Object { $null -ne $_.PSObject.Properties["Date"] }) + if ($ItemsWithDates.Count -eq 0) { + Set-ItResult -Skipped -Because "Output for '$application' does not include the optional Date property." + return + } + + foreach ($item in $ItemsWithDates) { + $item.Date | Should -BeOfType [System.String] + $ParsedDate = [System.DateTime]::MinValue + [System.DateTime]::TryParseExact( + $item.Date, + "yyyy-MM-dd", + [System.Globalization.CultureInfo]::InvariantCulture, + [System.Globalization.DateTimeStyles]::None, + [ref] $ParsedDate + ) | Should -BeTrue -Because "Date '$($item.Date)' must be a valid date in yyyy-MM-dd format" + } + } } } From 2edf43f6062e7e22fc4ffbe8da72c2b5ffe96fce Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Thu, 5 Nov 2026 08:34:47 +1100 Subject: [PATCH 03/10] Update analyzer profiles to PowerShell 7.4 Target PowerShell 7.4 and .NET 8 on Windows and Ubuntu 22.04, retaining Windows PowerShell 5.1 compatibility checks. --- .rules/PSScriptAnalyzerSettings.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.rules/PSScriptAnalyzerSettings.psd1 b/.rules/PSScriptAnalyzerSettings.psd1 index a5930ec1..59b7fd48 100644 --- a/.rules/PSScriptAnalyzerSettings.psd1 +++ b/.rules/PSScriptAnalyzerSettings.psd1 @@ -10,8 +10,8 @@ Enable = $true TargetProfiles = @( 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' - 'win-4_x64_10.0.18362.0_7.0.0_x64_3.1.2_core' - 'ubuntu_x64_18.04_7.0.0_x64_3.1.2_core' + 'win-4_x64_10.0.18362.0_7.4.0_x64_8.0.0_core' + 'ubuntu_x64_22.04_7.4.0_x64_8.0.0_core' ) } PSUseCompatibleSyntax = @{ From 2798800d936663df6ce2ab3f5c95e81cf2fd3adf Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Thu, 5 Nov 2026 08:35:01 +1100 Subject: [PATCH 04/10] Suppress plaintext SecureString warnings in tests Add test-only PSScriptAnalyzer suppressions for PSAvoidUsingConvertToSecureStringWithPlainText across seven test files. --- tests/Private/Invoke-RestMethodWrapper.Tests.ps1 | 1 + tests/Private/Invoke-WebRequestWrapper.Tests.ps1 | 1 + tests/Private/Remove-ProxyEnv.Tests.ps1 | 1 + tests/Private/Set-ProxyEnv.Tests.ps1 | 1 + tests/Public/Save-EvergreenApp.Tests.ps1 | 1 + tests/Public/Start-EvergreenLibraryUpdate.Tests.ps1 | 1 + tests/Public/Test-EvergreenApp.Tests.ps1 | 1 + 7 files changed, 7 insertions(+) diff --git a/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 b/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 index b8d230fe..d6f89a4f 100644 --- a/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 +++ b/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 @@ -4,6 +4,7 @@ #> [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This is OK for the test files.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { diff --git a/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 b/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 index 87e5290e..b9bf8eaf 100644 --- a/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 +++ b/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 @@ -4,6 +4,7 @@ #> [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This is OK for the test files.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { diff --git a/tests/Private/Remove-ProxyEnv.Tests.ps1 b/tests/Private/Remove-ProxyEnv.Tests.ps1 index a88f7523..c98e6597 100644 --- a/tests/Private/Remove-ProxyEnv.Tests.ps1 +++ b/tests/Private/Remove-ProxyEnv.Tests.ps1 @@ -4,6 +4,7 @@ #> [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This is OK for the test files.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { diff --git a/tests/Private/Set-ProxyEnv.Tests.ps1 b/tests/Private/Set-ProxyEnv.Tests.ps1 index ef5535d1..e1be2cb3 100644 --- a/tests/Private/Set-ProxyEnv.Tests.ps1 +++ b/tests/Private/Set-ProxyEnv.Tests.ps1 @@ -4,6 +4,7 @@ #> [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This is OK for the test files.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { diff --git a/tests/Public/Save-EvergreenApp.Tests.ps1 b/tests/Public/Save-EvergreenApp.Tests.ps1 index 44bda190..608e1e86 100644 --- a/tests/Public/Save-EvergreenApp.Tests.ps1 +++ b/tests/Public/Save-EvergreenApp.Tests.ps1 @@ -5,6 +5,7 @@ [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This is OK for the test files.")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification = "Outputs to log host.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { diff --git a/tests/Public/Start-EvergreenLibraryUpdate.Tests.ps1 b/tests/Public/Start-EvergreenLibraryUpdate.Tests.ps1 index 0ec5a677..3c9b5a9e 100644 --- a/tests/Public/Start-EvergreenLibraryUpdate.Tests.ps1 +++ b/tests/Public/Start-EvergreenLibraryUpdate.Tests.ps1 @@ -5,6 +5,7 @@ [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This OK for the tests files.")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification = "Outputs to log host.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { diff --git a/tests/Public/Test-EvergreenApp.Tests.ps1 b/tests/Public/Test-EvergreenApp.Tests.ps1 index 8d19d9fd..33cc592f 100644 --- a/tests/Public/Test-EvergreenApp.Tests.ps1 +++ b/tests/Public/Test-EvergreenApp.Tests.ps1 @@ -5,6 +5,7 @@ [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification="This is OK for the test files.")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification="Outputs to log host.")] +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "", Justification = "This is OK for tests.")] param () BeforeDiscovery { From 2de12fdba1b790e0a41992b410703c5184fe6592 Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Thu, 5 Nov 2026 08:36:13 +1100 Subject: [PATCH 05/10] Normalize PowerShell boolean literal casing Use lowercase `$true` and `$false` literals in the export script and tests for consistent PowerShell style. --- scripts/Export-EvergreenAppToFile.ps1 | 6 +++--- tests/Private/Invoke-RestMethodWrapper.Tests.ps1 | 2 +- tests/Private/Invoke-WebRequestWrapper.Tests.ps1 | 2 +- tests/Public/Save-EvergreenApp.Tests.ps1 | 2 +- tests/Public/Test-EvergreenLibrary.Tests.ps1 | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/Export-EvergreenAppToFile.ps1 b/scripts/Export-EvergreenAppToFile.ps1 index daa57b22..706977f2 100644 --- a/scripts/Export-EvergreenAppToFile.ps1 +++ b/scripts/Export-EvergreenAppToFile.ps1 @@ -4,10 +4,10 @@ Reads any existing JSON for that application, adds the new version content, sorts for unique versions, then outputs the new content back to the target JSON file. #> -[CmdletBinding(SupportsShouldProcess = $False)] +[CmdletBinding(SupportsShouldProcess = $false)] param ( [Parameter( - Mandatory = $False, + Mandatory = $false, Position = 0, ValueFromPipeline, HelpMessage = "An application name supported by Evergreen.")] @@ -15,7 +15,7 @@ param ( [System.String[]] $Name = "MicrosoftEdge", [Parameter( - Mandatory = $False, + Mandatory = $false, Position = 1, ValueFromPipelineByPropertyName, HelpMessage = "Specify a top-level directory path where the application JSON file will be saved into.", diff --git a/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 b/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 index d6f89a4f..fc8cac65 100644 --- a/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 +++ b/tests/Private/Invoke-RestMethodWrapper.Tests.ps1 @@ -193,7 +193,7 @@ InModuleScope -ModuleName "Evergreen" { ContentType = "application/vnd.github.v3+json" ErrorAction = "SilentlyContinue" Method = "Default" - SkipCertificateCheck = $True + SkipCertificateCheck = $true SslProtocol = "Tls12" UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Safari Uri = "https://api.github.com/rate_limit" diff --git a/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 b/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 index b9bf8eaf..cfbced68 100644 --- a/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 +++ b/tests/Private/Invoke-WebRequestWrapper.Tests.ps1 @@ -242,7 +242,7 @@ InModuleScope -ModuleName "Evergreen" { #Raw #ReturnObject = "Content" Method = "Default" - SkipCertificateCheck = $True + SkipCertificateCheck = $true SslProtocol = "Tls12" UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Safari Uri = "https://github.com" diff --git a/tests/Public/Save-EvergreenApp.Tests.ps1 b/tests/Public/Save-EvergreenApp.Tests.ps1 index 608e1e86..469070b6 100644 --- a/tests/Public/Save-EvergreenApp.Tests.ps1 +++ b/tests/Public/Save-EvergreenApp.Tests.ps1 @@ -53,7 +53,7 @@ Describe -Tag "Save", "Integration" -Name "Save-EvergreenApp" -ForEach $Installe # Test that the file downloaded into the path: "$Path/Stable/Enterprise//x64/MicrosoftEdgeEnterpriseX64.msi" It "Should save in the right path" { $File = [System.IO.Path]::Combine($Path, $installer.Channel, $installer.Release, $installer.Version, $installer.Architecture, $(Split-Path -Path $installer.URI -Leaf)) - Test-Path -Path $File -PathType "Leaf" | Should -Be $True + Test-Path -Path $File -PathType "Leaf" | Should -Be $true } It "Save-EvergreenApp should not throw with CustomPath" { diff --git a/tests/Public/Test-EvergreenLibrary.Tests.ps1 b/tests/Public/Test-EvergreenLibrary.Tests.ps1 index 46bba6e7..cdbc9caa 100644 --- a/tests/Public/Test-EvergreenLibrary.Tests.ps1 +++ b/tests/Public/Test-EvergreenLibrary.Tests.ps1 @@ -45,8 +45,8 @@ Describe -Tag "Library" -Name "Test Evergreen Library functions" { $params = @{ Path = "$env:GITHUB_WORKSPACE\tests\EvergreenLibrary.json" Destination = "$Path\EvergreenLibrary\EvergreenLibrary.json" - Force = $True - Confirm = $False + Force = $true + Confirm = $false } Copy-Item @params } @@ -61,8 +61,8 @@ Describe -Tag "Library" -Name "Test Evergreen Library functions" { $params = @{ Path = "$env:GITHUB_WORKSPACE\tests\EvergreenLibrary.json" Destination = "$Path\EvergreenLibrary\EvergreenLibrary.json" - Force = $True - Confirm = $False + Force = $true + Confirm = $false } Copy-Item @params } @@ -106,8 +106,8 @@ Describe -Tag "Library" -Name "Test Evergreen Library functions" { BeforeAll { $params = @{ FilePath = "$Path\EvergreenLibrary\EvergreenLibrary.json" - Force = $True - Confirm = $False + Force = $true + Confirm = $false } "nonsense" | Out-File @params } From 2faba5e7b45c6b9d618cd0ec3cceb7dd5329631c Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Fri, 6 Nov 2026 09:02:32 +1100 Subject: [PATCH 06/10] Support 24-hour dates without seconds Add dd/MM/yyyy HH:mm parsing to ConvertTo-DateTime with a matching test case. --- Evergreen/Private/ConvertTo-DateTime.ps1 | 1 + tests/Private/ConvertTo-DateTime.Tests.ps1 | 1 + 2 files changed, 2 insertions(+) diff --git a/Evergreen/Private/ConvertTo-DateTime.ps1 b/Evergreen/Private/ConvertTo-DateTime.ps1 index c12ccc02..ecd32e81 100644 --- a/Evergreen/Private/ConvertTo-DateTime.ps1 +++ b/Evergreen/Private/ConvertTo-DateTime.ps1 @@ -50,6 +50,7 @@ function ConvertTo-DateTime { "d/M/yyyy" "dd/MM/yyyy hh:mm tt" "dd/MM/yyyy hh:mm:ss tt" + "dd/MM/yyyy HH:mm" "dd/MM/yyyy HH:mm:ss" ) $Output = [System.DateTime]::MinValue diff --git a/tests/Private/ConvertTo-DateTime.Tests.ps1 b/tests/Private/ConvertTo-DateTime.Tests.ps1 index 8088fb95..769b59f7 100644 --- a/tests/Private/ConvertTo-DateTime.Tests.ps1 +++ b/tests/Private/ConvertTo-DateTime.Tests.ps1 @@ -78,6 +78,7 @@ Describe -Name "ConvertTo-DateTime" { @{ InputDate = "31/12/2024"; Expected = [System.DateTime]::new(2024, 12, 31) } @{ InputDate = "31/12/2024 11:45 PM"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 0) } @{ InputDate = "31/12/2024 11:45:32 PM"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32) } + @{ InputDate = "31/12/2024 23:45"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 0) } @{ InputDate = "31/12/2024 23:45:32"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32) } @{ InputDate = "2024-12-31"; Expected = [System.DateTime]::new(2024, 12, 31) } @{ InputDate = "2024-12-31T23:45:32"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32) } From 7ccf15f7da85ce138fa07c93752325e12f63a9dc Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Fri, 6 Nov 2026 10:30:34 +1100 Subject: [PATCH 07/10] Standardize date conversion in shared helpers Remove explicit date patterns from Codeberg, GitLab, JetBrains, and Oracle Java helpers. Normalize Microsoft fwlink dates through ConvertTo-DateTime. --- Evergreen/Shared/Get-CodebergRepoRelease.ps1 | 2 +- Evergreen/Shared/Get-GitLabRepoRelease.ps1 | 2 +- Evergreen/Shared/Get-JetBrainsApp.ps1 | 2 +- Evergreen/Shared/Get-OracleJava.ps1 | 2 +- Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Evergreen/Shared/Get-CodebergRepoRelease.ps1 b/Evergreen/Shared/Get-CodebergRepoRelease.ps1 index 13ab724f..bdc00ff3 100644 --- a/Evergreen/Shared/Get-CodebergRepoRelease.ps1 +++ b/Evergreen/Shared/Get-CodebergRepoRelease.ps1 @@ -116,7 +116,7 @@ function Get-CodebergRepoRelease { if ((Get-Platform -String $asset.browser_download_url) -eq "Windows") { $PSObject = [PSCustomObject] @{ Version = $Version - Date = ConvertTo-DateTime -DateTime $item.created_at -Pattern "MM/dd/yyyy HH:mm:ss" + Date = ConvertTo-DateTime -DateTime $item.created_at Size = $asset.size Architecture = Get-Architecture -String $(Split-Path -Path $asset.browser_download_url -Leaf) InstallerType = Get-InstallerType -String $(Split-Path -Path $asset.browser_download_url -Leaf) diff --git a/Evergreen/Shared/Get-GitLabRepoRelease.ps1 b/Evergreen/Shared/Get-GitLabRepoRelease.ps1 index 8fc9bd6a..ee2c50ec 100644 --- a/Evergreen/Shared/Get-GitLabRepoRelease.ps1 +++ b/Evergreen/Shared/Get-GitLabRepoRelease.ps1 @@ -152,7 +152,7 @@ function Get-GitLabRepoRelease { [PSCustomObject] @{ Version = $Version - Date = ConvertTo-DateTime -DateTime $dateValue -Pattern "MM/dd/yyyy HH:mm:ss" + Date = ConvertTo-DateTime -DateTime $dateValue Architecture = Get-Architecture -String $leafName InstallerType = Get-InstallerType -String $leafName Type = Get-FileType -File $leafName diff --git a/Evergreen/Shared/Get-JetBrainsApp.ps1 b/Evergreen/Shared/Get-JetBrainsApp.ps1 index 003e7289..a080ecd6 100644 --- a/Evergreen/Shared/Get-JetBrainsApp.ps1 +++ b/Evergreen/Shared/Get-JetBrainsApp.ps1 @@ -79,7 +79,7 @@ function Get-JetBrainsApp { Version = $Release.version Build = $Release.build Edition = $Edition.Key - Date = ConvertTo-DateTime -DateTime $Release.date -Pattern $Update.DatePattern + Date = ConvertTo-DateTime -DateTime $Release.date Sha256 = $Sha256 Size = $WindowsDownload.size Architecture = Get-Architecture -String $WindowsDownload.link diff --git a/Evergreen/Shared/Get-OracleJava.ps1 b/Evergreen/Shared/Get-OracleJava.ps1 index 21f7cda4..f5d44b3d 100644 --- a/Evergreen/Shared/Get-OracleJava.ps1 +++ b/Evergreen/Shared/Get-OracleJava.ps1 @@ -93,7 +93,7 @@ function Get-OracleJava { [PSCustomObject] @{ Version = $LatestVersion.version FullVersion = $LatestVersion.fullversion - Date = ConvertTo-DateTime -DateTime $LatestVersion.ga -Pattern $res.Get.Update.DateFormat + Date = ConvertTo-DateTime -DateTime $LatestVersion.ga Sha256 = $Sha256 Architecture = Get-Architecture -String $res.Get.Download.Uri[$Type.Key] Type = Get-FileType -File $res.Get.Download.Uri[$Type.Key] diff --git a/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 b/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 index 718298c0..16c7d0ba 100644 --- a/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 +++ b/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 @@ -68,7 +68,7 @@ function Resolve-MicrosoftFwLink { # Output a version object [PSCustomObject]@{ Version = $Version - Date = $Date + Date = ConvertTo-DateTime -Date $Date Size = $Size Language = "Unknown" Architecture = Get-Architecture -String $ResolvedUrl.ResponseUri.AbsoluteUri From b29037d7460eb0799bcfaeda5eb4a743886e29cf Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Fri, 6 Nov 2026 10:30:46 +1100 Subject: [PATCH 08/10] Assert normalized date strings in shared tests Verify Date values are yyyy-MM-dd strings across shared helpers, accounting for local timezone conversion where applicable. Update GitLab mocks and assert source timestamp conversion. --- tests/Shared/Get-AdoptiumTemurin.Tests.ps1 | 7 +++++-- tests/Shared/Get-GitHubRepoRelease.Tests.ps1 | 6 +++++- tests/Shared/Get-GitLabRepoRelease.Tests.ps1 | 10 ++++++++-- tests/Shared/Get-JetBrainsApp.Tests.ps1 | 4 ++++ tests/Shared/Get-OracleJava.Tests.ps1 | 4 ++++ tests/Shared/Resolve-MicrosoftFwLink.Tests.ps1 | 3 ++- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/Shared/Get-AdoptiumTemurin.Tests.ps1 b/tests/Shared/Get-AdoptiumTemurin.Tests.ps1 index 90dad672..11bec7de 100644 --- a/tests/Shared/Get-AdoptiumTemurin.Tests.ps1 +++ b/tests/Shared/Get-AdoptiumTemurin.Tests.ps1 @@ -60,9 +60,12 @@ InModuleScope -ModuleName "Evergreen" { $Results.Count | Should -Be 2 $Results[0].Version | Should -Be "17.0.1+1" - # $Results[0].Date | Should -Be "2025-01-01T00:00:00Z" - # $Results[1].Date | Should -Be "2025-01-03T00:00:00Z" + $ExpectedTimestamp = [System.DateTime]::new(2025, 1, 1, 0, 0, 0, [System.DateTimeKind]::Utc) + $ExpectedUpdatedAt = [System.DateTime]::new(2025, 1, 3, 0, 0, 0, [System.DateTimeKind]::Utc) + $Results[0].Date | Should -Be ($ExpectedTimestamp.ToLocalTime().ToString("yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture)) + $Results[1].Date | Should -Be ($ExpectedUpdatedAt.ToLocalTime().ToString("yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture)) foreach ($Result in $Results) { + $Result.Date | Should -BeOfType [System.String] $Result.PSObject.Properties.Name | Should -Contain "Checksum" $Result.PSObject.Properties.Name | Should -Contain "Size" $Result.PSObject.Properties.Name | Should -Contain "Date" diff --git a/tests/Shared/Get-GitHubRepoRelease.Tests.ps1 b/tests/Shared/Get-GitHubRepoRelease.Tests.ps1 index 5a036b77..60dc05a9 100644 --- a/tests/Shared/Get-GitHubRepoRelease.Tests.ps1 +++ b/tests/Shared/Get-GitHubRepoRelease.Tests.ps1 @@ -89,7 +89,11 @@ InModuleScope -ModuleName "Evergreen" { if ($Schema -ne "GitLab") { $Expected += "Size" } @($Result.PSObject.Properties.Name | Sort-Object) | Should -Be @($Expected | Sort-Object) $Result.Version | Should -Be "1.2.3" - $Result.Date | Should -BeOfType ([datetime]) + $SourceDate = if ($Schema -eq "GitLab") { $Response.released_at } else { $Response.created_at } + $ExpectedTimestamp = [System.DateTimeOffset]::Parse($SourceDate, [System.Globalization.CultureInfo]::InvariantCulture) + $ExpectedDate = $ExpectedTimestamp.ToLocalTime().ToString("yyyy-MM-dd", [System.Globalization.CultureInfo]::InvariantCulture) + $Result.Date | Should -BeOfType [System.String] + $Result.Date | Should -Be $ExpectedDate $Result.Architecture | Should -Be "x64" $Result.InstallerType | Should -Be "Default" $Result.Type | Should -Be "msi" diff --git a/tests/Shared/Get-GitLabRepoRelease.Tests.ps1 b/tests/Shared/Get-GitLabRepoRelease.Tests.ps1 index 1761fc68..05810bba 100644 --- a/tests/Shared/Get-GitLabRepoRelease.Tests.ps1 +++ b/tests/Shared/Get-GitLabRepoRelease.Tests.ps1 @@ -42,7 +42,7 @@ InModuleScope -ModuleName "Evergreen" { [System.String] $DateTime, [System.String] $Pattern ) - return "07/12/2026 12:00:00" + return "2026-07-12" } Mock -CommandName Get-Platform -MockWith { @@ -158,6 +158,8 @@ InModuleScope -ModuleName "Evergreen" { } $result = Get-GitLabRepoRelease -Uri "https://gitlab.com/api/v4/projects/123/releases" $result.URI | Should -Be "https://example.com/fallback-x64.msi" + $result.Date | Should -BeOfType [System.String] + $result.Date | Should -Be "2026-07-12" Should -Invoke ConvertTo-DateTime -Times 1 -Exactly -ParameterFilter { $DateTime -eq "2026-07-01T10:00:00Z" } @@ -191,11 +193,15 @@ InModuleScope -ModuleName "Evergreen" { $result = Get-GitLabRepoRelease @params | Select-Object -First 1 $result.Version | Should -Be "3.2.1" - $result.Date | Should -Not -BeNullOrEmpty + $result.Date | Should -BeOfType [System.String] + $result.Date | Should -Be "2026-07-12" $result.Architecture | Should -Be "x64" $result.InstallerType | Should -Be "MSI" $result.Type | Should -Be "msi" $result.URI | Should -Be "https://gitlab.example.com/downloads/tool-x64.msi" + Should -Invoke ConvertTo-DateTime -Times 1 -Exactly -ParameterFilter { + $DateTime -eq "2026-07-02T09:00:00Z" + } } } } diff --git a/tests/Shared/Get-JetBrainsApp.Tests.ps1 b/tests/Shared/Get-JetBrainsApp.Tests.ps1 index d8584a03..5de3dd3a 100644 --- a/tests/Shared/Get-JetBrainsApp.Tests.ps1 +++ b/tests/Shared/Get-JetBrainsApp.Tests.ps1 @@ -85,6 +85,10 @@ InModuleScope -ModuleName "Evergreen" { $Results[2].URI | Should -Be "https://download.example.com/pycharm-community-arm64.exe" $Results[3].URI | Should -Be "https://download.example.com/pycharm-community-arm64.zip" $Results[4].Sha256 | Should -BeNullOrEmpty + foreach ($Result in $Results) { + $Result.Date | Should -BeOfType [System.String] + $Result.Date | Should -Be "2025-04-01" + } } It "Replaces the edition placeholder literally" { diff --git a/tests/Shared/Get-OracleJava.Tests.ps1 b/tests/Shared/Get-OracleJava.Tests.ps1 index fb15a3df..66e8a018 100644 --- a/tests/Shared/Get-OracleJava.Tests.ps1 +++ b/tests/Shared/Get-OracleJava.Tests.ps1 @@ -54,6 +54,10 @@ InModuleScope -ModuleName "Evergreen" { $Result[1].Version | Should -Be "10.2.0" $Result[1].Sha256 | Should -BeNull $Result[1].URI | Should -Be "https://example.test/jdk-arm64.tar.gz" + foreach ($Item in $Result) { + $Item.Date | Should -BeOfType [System.String] + $Item.Date | Should -Be "2025-06-01" + } Should -Invoke Invoke-EvergreenWebRequest -Times 2 -Exactly } diff --git a/tests/Shared/Resolve-MicrosoftFwLink.Tests.ps1 b/tests/Shared/Resolve-MicrosoftFwLink.Tests.ps1 index 0548fbe0..88a558e1 100644 --- a/tests/Shared/Resolve-MicrosoftFwLink.Tests.ps1 +++ b/tests/Shared/Resolve-MicrosoftFwLink.Tests.ps1 @@ -26,7 +26,8 @@ InModuleScope -ModuleName "Evergreen" { $Result = Resolve-MicrosoftFwLink -Uri "https://go.microsoft.com/fwlink/?source=app&linkid=2248728" $Result.Version | Should -Be "1.2.3.4" - #$Result.Date | Should -Be "2024-03-05" + $Result.Date | Should -BeOfType [System.String] + $Result.Date | Should -Be "2024-03-05" $Result.Size | Should -Be 12345 $Result.URI | Should -Be "https://download.microsoft.com/files/Product-1.2.3.4-x64.msi?version=9.8.7" } From 04a987dc927d719678912793651df7a512bf290c Mon Sep 17 00:00:00 2001 From: Aaron Parker Date: Fri, 6 Nov 2026 12:07:10 +1100 Subject: [PATCH 09/10] Improve date parsing and preserve fwlink dates Add a Date alias and a two-digit 12-hour time format to ConvertTo-DateTime, with midnight test coverage. Return the resolved fwlink date directly instead of converting it. --- Evergreen/Private/ConvertTo-DateTime.ps1 | 2 ++ Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 | 2 +- tests/Private/ConvertTo-DateTime.Tests.ps1 | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Evergreen/Private/ConvertTo-DateTime.ps1 b/Evergreen/Private/ConvertTo-DateTime.ps1 index ecd32e81..7cea853b 100644 --- a/Evergreen/Private/ConvertTo-DateTime.ps1 +++ b/Evergreen/Private/ConvertTo-DateTime.ps1 @@ -21,6 +21,7 @@ function ConvertTo-DateTime { param ( [Parameter(Mandatory = $true, Position = 0)] [ValidateNotNullOrEmpty()] + [Alias("Date")] [System.String] $DateTime, [Parameter(Position = 1)] @@ -40,6 +41,7 @@ function ConvertTo-DateTime { "MM/dd/yyyy HH:mm:ss" "M/d/yyyy h:mm tt" "M/d/yyyy h:mm:ss tt" + "M/d/yyyy hh:mm:ss tt" "MM-dd-yyyy" "yyyy-MM-dd" "yyyy-MM-dd HH:mm:ss" diff --git a/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 b/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 index 16c7d0ba..718298c0 100644 --- a/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 +++ b/Evergreen/Shared/Resolve-MicrosoftFwLink.ps1 @@ -68,7 +68,7 @@ function Resolve-MicrosoftFwLink { # Output a version object [PSCustomObject]@{ Version = $Version - Date = ConvertTo-DateTime -Date $Date + Date = $Date Size = $Size Language = "Unknown" Architecture = Get-Architecture -String $ResolvedUrl.ResponseUri.AbsoluteUri diff --git a/tests/Private/ConvertTo-DateTime.Tests.ps1 b/tests/Private/ConvertTo-DateTime.Tests.ps1 index 769b59f7..0eb29929 100644 --- a/tests/Private/ConvertTo-DateTime.Tests.ps1 +++ b/tests/Private/ConvertTo-DateTime.Tests.ps1 @@ -71,6 +71,7 @@ Describe -Name "ConvertTo-DateTime" { @{ InputDate = "12/31/2024 23:45:32"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32) } @{ InputDate = "12/31/2024 11:45 PM"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 0) } @{ InputDate = "12/31/2024 11:45:32 PM"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32) } + @{ InputDate = "6/10/2026 12:00:00 AM"; Expected = [System.DateTime]::new(2026, 6, 10, 0, 0, 0) } @{ InputDate = "12-31-2024"; Expected = [System.DateTime]::new(2024, 12, 31) } @{ InputDate = "2024-12-31 23:45:32"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32) } @{ InputDate = "Tue, 31 Dec 2024 23:45:32 GMT"; Expected = [System.DateTime]::new(2024, 12, 31, 23, 45, 32, [System.DateTimeKind]::Utc).ToLocalTime() } From 11f62234fa3ac1ac8121207b9da94a88efbf9fcc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Nov 2026 02:01:08 +0000 Subject: [PATCH 10/10] Use bundled PSScriptAnalyzer compatibility profiles Co-authored-by: aaronparker <8227455+aaronparker@users.noreply.github.com> --- .rules/PSScriptAnalyzerSettings.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.rules/PSScriptAnalyzerSettings.psd1 b/.rules/PSScriptAnalyzerSettings.psd1 index 59b7fd48..a5930ec1 100644 --- a/.rules/PSScriptAnalyzerSettings.psd1 +++ b/.rules/PSScriptAnalyzerSettings.psd1 @@ -10,8 +10,8 @@ Enable = $true TargetProfiles = @( 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' - 'win-4_x64_10.0.18362.0_7.4.0_x64_8.0.0_core' - 'ubuntu_x64_22.04_7.4.0_x64_8.0.0_core' + 'win-4_x64_10.0.18362.0_7.0.0_x64_3.1.2_core' + 'ubuntu_x64_18.04_7.0.0_x64_3.1.2_core' ) } PSUseCompatibleSyntax = @{