Add initial llm-bridge project
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<#
|
||||
.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
|
||||
@@ -0,0 +1,45 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Run the browser end-to-end suite against the local fixture page.
|
||||
|
||||
.DESCRIPTION
|
||||
The suite needs a real Chromium-based browser; it is ignored by default so
|
||||
that "cargo test" stays usable without a browser. It drives a local static
|
||||
fake of the ChatGPT page (tests/fixtures/chatgpt_mock.html): full pipeline,
|
||||
streaming, conversation reuse, login, captcha, rate limit, error banner,
|
||||
first-token timeout, missing selector, mid-stream rewrite and attachments.
|
||||
|
||||
.EXAMPLE
|
||||
./scripts/e2e.ps1
|
||||
./scripts/e2e.ps1 -Test fixture_full_pipeline
|
||||
#>
|
||||
param(
|
||||
[string]$Test = ''
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
Push-Location $root
|
||||
|
||||
$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: the browser suite cannot run'
|
||||
Pop-Location
|
||||
exit 2
|
||||
}
|
||||
Write-Host "using $chrome" -ForegroundColor Cyan
|
||||
|
||||
$arguments = @('test', '--test', 'e2e_browser')
|
||||
if ($Test) { $arguments += $Test }
|
||||
$arguments += @('--', '--ignored', '--test-threads=1', '--nocapture')
|
||||
|
||||
& cargo @arguments
|
||||
$code = $LASTEXITCODE
|
||||
Pop-Location
|
||||
exit $code
|
||||
Reference in New Issue
Block a user