@@ -52,6 +52,39 @@ function Require-Command {
5252 return $command.Source
5353}
5454
55+ function Invoke-ProductionBrowserValidation {
56+ param (
57+ [object ]$Target ,
58+ [int ]$MaxAttempts = 3 ,
59+ [int ]$RetryDelaySeconds = 8
60+ )
61+
62+ for ($attempt = 1 ; $attempt -le $MaxAttempts ; $attempt ++ ) {
63+ $env: PUBLIC_PAGES_BASE_URL = $Target.publicBaseUrl
64+ $env: PUBLIC_PAGES_MODE = $Target.publicMode
65+ try {
66+ node scripts/ public- pages- check.mjs
67+ $validationExitCode = $LASTEXITCODE
68+ if ($validationExitCode -eq 0 ) {
69+ return
70+ }
71+
72+ throw " public-pages-check exited with code $validationExitCode "
73+ } catch {
74+ if ($attempt -ge $MaxAttempts ) {
75+ throw " Production browser validation failed for target $ ( $Target.name ) after $MaxAttempts attempts: $_ "
76+ }
77+
78+ Write-Warning " Production browser validation attempt $attempt /$MaxAttempts failed for target $ ( $Target.name ) : $_ "
79+ Start-Sleep - Seconds $RetryDelaySeconds
80+ } finally {
81+ Remove-Item Env:\PUBLIC_PAGES_BASE_URL - ErrorAction SilentlyContinue
82+ Remove-Item Env:\PUBLIC_PAGES_MODE - ErrorAction SilentlyContinue
83+ $global :LASTEXITCODE = 0
84+ }
85+ }
86+ }
87+
5588function Resolve-LocalPath {
5689 param ([string ]$Value )
5790
@@ -631,18 +664,7 @@ Run-Step "Production target browser validation" {
631664 }
632665
633666 Write-Host " Validating $ ( $target.name ) at $ ( $target.publicBaseUrl ) in $ ( $target.publicMode ) mode."
634- $env: PUBLIC_PAGES_BASE_URL = $target.publicBaseUrl
635- $env: PUBLIC_PAGES_MODE = $target.publicMode
636- try {
637- node scripts/ public- pages- check.mjs
638- $validationExitCode = $LASTEXITCODE
639- if ($validationExitCode -ne 0 ) {
640- throw " Production browser validation failed for target $ ( $target.name ) with exit code $validationExitCode ."
641- }
642- } finally {
643- Remove-Item Env:\PUBLIC_PAGES_BASE_URL - ErrorAction SilentlyContinue
644- Remove-Item Env:\PUBLIC_PAGES_MODE - ErrorAction SilentlyContinue
645- }
667+ Invoke-ProductionBrowserValidation - Target $target
646668 }
647669}
648670
0 commit comments