chore: import upstream snapshot with attribution
FreeBSD Smoke / FreeBSD Smoke (x86_64) (push) Has been cancelled
CI / Quality Guardrails (push) Has been cancelled
CI / Build & Test (macos-latest) (push) Has been cancelled
CI / Build & Test (ubuntu-latest) (push) Has been cancelled
CI / Build & Test (windows-latest) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / PowerShell Syntax (push) Has been cancelled
CI / Windows Cross-Target Check (Linux) (push) Has been cancelled
FreeBSD Smoke / FreeBSD Smoke (x86_64) (push) Has been cancelled
CI / Quality Guardrails (push) Has been cancelled
CI / Build & Test (macos-latest) (push) Has been cancelled
CI / Build & Test (ubuntu-latest) (push) Has been cancelled
CI / Build & Test (windows-latest) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / PowerShell Syntax (push) Has been cancelled
CI / Windows Cross-Target Check (Linux) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Run a command with a hard timeout and readable diagnostics."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
def _usage() -> int:
|
||||
print(
|
||||
"usage: run_with_timeout.py <timeout-seconds> <command> [args...]",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 2
|
||||
|
||||
|
||||
def _kill_process_group(proc: subprocess.Popen[bytes]) -> None:
|
||||
try:
|
||||
pgid = os.getpgid(proc.pid)
|
||||
except ProcessLookupError:
|
||||
return
|
||||
try:
|
||||
os.killpg(pgid, signal.SIGTERM)
|
||||
except ProcessLookupError:
|
||||
return
|
||||
|
||||
|
||||
def main(argv: Sequence[str]) -> int:
|
||||
if len(argv) < 3:
|
||||
return _usage()
|
||||
|
||||
try:
|
||||
timeout_seconds = int(argv[1])
|
||||
except ValueError:
|
||||
print(f"invalid timeout: {argv[1]!r}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
command = list(argv[2:])
|
||||
print(f"==> Running with timeout {timeout_seconds}s: {' '.join(command)}")
|
||||
proc = subprocess.Popen(command, start_new_session=True)
|
||||
try:
|
||||
return proc.wait(timeout=timeout_seconds)
|
||||
except subprocess.TimeoutExpired:
|
||||
print(
|
||||
f"::error::Command exceeded timeout after {timeout_seconds}s: {' '.join(command)}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
_kill_process_group(proc)
|
||||
try:
|
||||
proc.wait(timeout=30)
|
||||
return 124
|
||||
except subprocess.TimeoutExpired:
|
||||
try:
|
||||
os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
return 124
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main(sys.argv))
|
||||
@@ -0,0 +1,64 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$ArtifactExePath,
|
||||
[Parameter(Mandatory = $true)][string]$Version
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$resolvedArtifact = (Resolve-Path -LiteralPath $ArtifactExePath).Path
|
||||
$tempRoot = Join-Path $env:RUNNER_TEMP ("jcode-windows-install-verify-" + [guid]::NewGuid().ToString('N'))
|
||||
$localAppData = Join-Path $tempRoot 'localappdata'
|
||||
$appData = Join-Path $tempRoot 'appdata'
|
||||
$userProfile = Join-Path $tempRoot 'userprofile'
|
||||
$jcodeHome = Join-Path $tempRoot '.jcode'
|
||||
$installDir = Join-Path $localAppData 'jcode\bin'
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $localAppData, $appData, $userProfile, $jcodeHome | Out-Null
|
||||
|
||||
$env:LOCALAPPDATA = $localAppData
|
||||
$env:APPDATA = $appData
|
||||
$env:USERPROFILE = $userProfile
|
||||
$env:JCODE_HOME = $jcodeHome
|
||||
|
||||
$installScript = Join-Path $repoRoot 'scripts\install.ps1'
|
||||
|
||||
& $installScript `
|
||||
-InstallDir $installDir `
|
||||
-Version $Version `
|
||||
-ArtifactExePath $resolvedArtifact `
|
||||
-SkipAlacrittySetup `
|
||||
-SkipHotkeySetup
|
||||
|
||||
$launcherPath = Join-Path $installDir 'jcode.exe'
|
||||
$versionDir = Join-Path $localAppData ('jcode\builds\versions\' + $Version.TrimStart('v') + '\jcode.exe')
|
||||
$stablePath = Join-Path $localAppData 'jcode\builds\stable\jcode.exe'
|
||||
|
||||
foreach ($path in @($launcherPath, $versionDir, $stablePath)) {
|
||||
if (-not (Test-Path -LiteralPath $path)) {
|
||||
throw "Expected installed file missing: $path"
|
||||
}
|
||||
}
|
||||
|
||||
$versionOutput = & $launcherPath --version
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Installed launcher failed to run --version"
|
||||
}
|
||||
|
||||
if ($versionOutput -notmatch 'jcode') {
|
||||
throw "Installed launcher returned unexpected version output: $versionOutput"
|
||||
}
|
||||
|
||||
& $installScript `
|
||||
-InstallDir $installDir `
|
||||
-Version $Version `
|
||||
-ArtifactExePath $resolvedArtifact `
|
||||
-SkipAlacrittySetup `
|
||||
-SkipHotkeySetup
|
||||
|
||||
if (-not (Test-Path -LiteralPath $launcherPath)) {
|
||||
throw "Launcher missing after reinstall: $launcherPath"
|
||||
}
|
||||
|
||||
Write-Host "Windows install verification passed for $Version" -ForegroundColor Green
|
||||
Reference in New Issue
Block a user