<# .SYNOPSIS Run the same gates as the CI workflow, on this machine. .DESCRIPTION Mirrors .github/workflows/ci.yml so a change can be checked before pushing: formatting, clippy with warnings as errors, the unit and integration tests (no browser, no network), the doc tests and a release build. The browser end-to-end suite needs a real Chromium and is opt-in: pass -E2e to add it after the other gates. .EXAMPLE ./scripts/ci.ps1 ./scripts/ci.ps1 -E2e ./scripts/ci.ps1 -SkipRelease #> param( [switch]$E2e, [switch]$SkipRelease ) $ErrorActionPreference = 'Stop' $root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) Push-Location $root $script:failed = @() function Invoke-Gate { param([string]$Name, [string[]]$Arguments) Write-Host "== $Name" -ForegroundColor Cyan Write-Host " cargo $($Arguments -join ' ')" -ForegroundColor DarkGray & cargo @Arguments if ($LASTEXITCODE -ne 0) { Write-Host " FAILED ($LASTEXITCODE)" -ForegroundColor Red $script:failed += $Name } else { Write-Host " ok" -ForegroundColor Green } } Invoke-Gate 'formatting' @('fmt', '--all', '--check') Invoke-Gate 'clippy' @('clippy', '--all-targets', '--locked', '--', '-D', 'warnings') Invoke-Gate 'tests' @('test', '--locked', '--all-targets') Invoke-Gate 'doc tests' @('test', '--locked', '--doc') if (-not $SkipRelease) { Invoke-Gate 'release build' @('build', '--locked', '--release') } if ($E2e) { # The browser suite is #[ignore]d by default and needs a real browser. $chrome = @( "$env:ProgramFiles\Google\Chrome\Application\chrome.exe", "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe", "$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe", "$env:LOCALAPPDATA\BraveSoftware\Brave-Browser\Application\brave.exe" ) | Where-Object { Test-Path $_ } | Select-Object -First 1 if (-not $chrome) { Write-Warning 'no Chromium-based browser found: skipping the browser suite' } else { $env:CHROME = $chrome Invoke-Gate 'browser e2e' @('test', '--test', 'e2e_browser', '--', '--ignored', '--test-threads=1') } } Pop-Location if ($script:failed.Count -gt 0) { Write-Host '' Write-Host "failed gates: $($script:failed -join ', ')" -ForegroundColor Red exit 1 } Write-Host '' Write-Host 'all gates passed' -ForegroundColor Green exit 0