63 lines
3.3 KiB
PowerShell
63 lines
3.3 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
|
Set-Location $repoRoot
|
|
|
|
$gitBashCandidates = @(
|
|
(Join-Path (Split-Path (Get-Command git.exe).Source -Parent) "..\bin\bash.exe"),
|
|
"C:\Program Files\Git\bin\bash.exe"
|
|
)
|
|
$gitBash = $gitBashCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
|
if (-not $gitBash) {
|
|
throw "Git for Windows Bash is required to run scripts/version.sh. Install Git for Windows and retry."
|
|
}
|
|
|
|
$docker = (Get-Command docker.exe -ErrorAction Stop).Source
|
|
& $docker info *> $null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Docker Engine is unavailable through the Windows Docker CLI. Start Rancher Desktop or Docker Desktop and retry."
|
|
}
|
|
|
|
$version = (& $gitBash scripts/version.sh).Trim()
|
|
if ($LASTEXITCODE -ne 0 -or -not $version) {
|
|
throw "scripts/version.sh failed to calculate the plugin version."
|
|
}
|
|
|
|
$artifactDir = Join-Path $repoRoot "target\e2e-artifact"
|
|
$pluginJar = Join-Path $artifactDir "sonar-bifrost-plugin-$version.jar"
|
|
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
|
|
$env:BIFROST_PLUGIN_JAR = $pluginJar
|
|
$env:GITEA_TEST_USER = if ($env:GITEA_TEST_USER) { $env:GITEA_TEST_USER } else { "bifrost-e2e-admin" }
|
|
$env:GITEA_TEST_PASSWORD = if ($env:GITEA_TEST_PASSWORD) { $env:GITEA_TEST_PASSWORD } else { "bifrost-gitea-test-password" }
|
|
$env:SONAR_TEST_PASSWORD = if ($env:SONAR_TEST_PASSWORD) { $env:SONAR_TEST_PASSWORD } else { "Bifrost-Sonar-Test-2026-password" }
|
|
$compose = @("compose", "--project-name", "bifrost-e2e", "-f", "docker-compose.yml")
|
|
|
|
Write-Host "Building plugin version $version and exporting the test JAR."
|
|
& $docker build --build-arg "REVISION=$version" --target export --output "type=local,dest=$artifactDir" .
|
|
if ($LASTEXITCODE -ne 0) { throw "Docker plugin build/export failed with exit code $LASTEXITCODE." }
|
|
if (-not (Test-Path -LiteralPath $pluginJar)) { throw "Expected plugin JAR was not exported: $pluginJar" }
|
|
|
|
Write-Host "Resetting only the isolated bifrost-e2e Compose project and its volumes."
|
|
& $docker @compose down --volumes --remove-orphans
|
|
if ($LASTEXITCODE -ne 0) { throw "Could not reset the isolated E2E Compose project." }
|
|
|
|
Write-Host "Starting fresh PostgreSQL, Gitea, and SonarQube services."
|
|
& $docker @compose up --detach --wait --wait-timeout 360 postgres gitea sonarqube
|
|
if ($LASTEXITCODE -ne 0) { throw "The isolated Gitea/SonarQube stack failed to become healthy." }
|
|
|
|
Write-Host "Creating the disposable Gitea test administrator."
|
|
& $docker @compose exec --no-TTY --user git gitea gitea admin user create `
|
|
--username $env:GITEA_TEST_USER `
|
|
--password $env:GITEA_TEST_PASSWORD `
|
|
--email "$($env:GITEA_TEST_USER)@example.test" `
|
|
--admin `
|
|
--must-change-password=false
|
|
if ($LASTEXITCODE -ne 0) { throw "Could not create the disposable Gitea test administrator." }
|
|
|
|
Write-Host "Running the Chromium end-to-end test against the installed plugin."
|
|
& $docker @compose run --build --rm e2e
|
|
if ($LASTEXITCODE -ne 0) { throw "Bifrost end-to-end validation failed. The isolated stack remains available for diagnosis." }
|
|
|
|
Write-Host ""
|
|
Write-Host "End-to-end validation passed. The isolated stack remains available at http://localhost:9000 and http://localhost:3000."
|
|
Write-Host "Run 'docker compose --project-name bifrost-e2e down --volumes --remove-orphans' to remove only this test stack and its data."
|