docs(ci): establish runner infrastructure governance
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m2s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m2s
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
$runnerRoot = 'C:\xiaoxia-ci\act_runner'
|
||||
$configPath = Join-Path $runnerRoot 'config.yaml'
|
||||
$runnerExe = Join-Path $runnerRoot 'act_runner.exe'
|
||||
$workDir = Join-Path $runnerRoot 'work'
|
||||
$logDir = Join-Path $runnerRoot 'logs'
|
||||
|
||||
$results = [ordered]@{
|
||||
runnerRootExists = Test-Path $runnerRoot
|
||||
runnerExeExists = Test-Path $runnerExe
|
||||
configExists = Test-Path $configPath
|
||||
workDirExists = Test-Path $workDir
|
||||
logDirExists = Test-Path $logDir
|
||||
}
|
||||
|
||||
$processes = Get-CimInstance Win32_Process -ErrorAction SilentlyContinue |
|
||||
Where-Object {
|
||||
$_.Name -match 'act_runner' -or
|
||||
$_.ExecutablePath -eq $runnerExe -or
|
||||
$_.CommandLine -match 'act_runner'
|
||||
} |
|
||||
Select-Object ProcessId, Name, ExecutablePath, CommandLine
|
||||
|
||||
$results['runnerProcessCount'] = @($processes).Count
|
||||
|
||||
$logSummary = @()
|
||||
if (Test-Path $logDir) {
|
||||
$logSummary = Get-ChildItem $logDir -File -ErrorAction SilentlyContinue |
|
||||
Sort-Object LastWriteTime -Descending |
|
||||
Select-Object -First 10 Name, LastWriteTime, Length
|
||||
}
|
||||
|
||||
Write-Host '=== Runner Files ==='
|
||||
$results.GetEnumerator() | ForEach-Object {
|
||||
Write-Host ("{0}: {1}" -f $_.Key, $_.Value)
|
||||
}
|
||||
|
||||
Write-Host "`n=== Runner Processes ==="
|
||||
if (@($processes).Count -eq 0) {
|
||||
Write-Host 'No runner process found.'
|
||||
} else {
|
||||
$processes | Format-Table -AutoSize
|
||||
}
|
||||
|
||||
Write-Host "`n=== Recent Logs ==="
|
||||
if (@($logSummary).Count -eq 0) {
|
||||
Write-Host 'No runner logs found.'
|
||||
} else {
|
||||
$logSummary | Format-Table -AutoSize
|
||||
}
|
||||
|
||||
if (-not $results['runnerExeExists'] -or -not $results['configExists']) {
|
||||
exit 2
|
||||
}
|
||||
|
||||
if (@($processes).Count -eq 0) {
|
||||
exit 3
|
||||
}
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,41 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$RunnerToken,
|
||||
|
||||
[string]$RunnerRoot = 'C:\xiaoxia-ci\act_runner',
|
||||
[string]$InstanceUrl = 'https://api.xiaoxiajianji.com/git',
|
||||
[string]$RunnerName = 'xiaoxia-windows-runner'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$runnerExe = Join-Path $RunnerRoot 'act_runner.exe'
|
||||
$configPath = Join-Path $RunnerRoot 'config.yaml'
|
||||
$workDir = Join-Path $RunnerRoot 'work'
|
||||
$logDir = Join-Path $RunnerRoot 'logs'
|
||||
$scriptDir = Join-Path $RunnerRoot 'scripts'
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $RunnerRoot, $workDir, $logDir, $scriptDir | Out-Null
|
||||
|
||||
if (-not (Test-Path $runnerExe)) {
|
||||
throw "Missing runner executable: $runnerExe"
|
||||
}
|
||||
|
||||
$config = @"
|
||||
instance:
|
||||
url: $InstanceUrl
|
||||
token: $RunnerToken
|
||||
|
||||
runner:
|
||||
name: $RunnerName
|
||||
labels:
|
||||
- windows
|
||||
- xiaoxia-ci
|
||||
- local
|
||||
workdir: $workDir
|
||||
"@
|
||||
|
||||
Set-Content -Path $configPath -Value $config -Encoding UTF8
|
||||
|
||||
Write-Host "Runner config written: $configPath"
|
||||
Write-Host "Next step: register/start runner with the official act_runner command for this binary version."
|
||||
@@ -0,0 +1,21 @@
|
||||
$runnerRoot = 'C:\xiaoxia-ci\act_runner'
|
||||
$runnerExe = Join-Path $runnerRoot 'act_runner.exe'
|
||||
$configPath = Join-Path $runnerRoot 'config.yaml'
|
||||
$stdoutLog = Join-Path $runnerRoot 'logs\runner.stdout.log'
|
||||
$stderrLog = Join-Path $runnerRoot 'logs\runner.stderr.log'
|
||||
|
||||
if (-not (Test-Path $runnerExe)) {
|
||||
throw "Missing runner executable: $runnerExe"
|
||||
}
|
||||
|
||||
if (-not (Test-Path $configPath)) {
|
||||
throw "Missing runner config: $configPath"
|
||||
}
|
||||
|
||||
Start-Process -FilePath $runnerExe `
|
||||
-ArgumentList "daemon --config `"$configPath`"" `
|
||||
-WorkingDirectory $runnerRoot `
|
||||
-RedirectStandardOutput $stdoutLog `
|
||||
-RedirectStandardError $stderrLog
|
||||
|
||||
Write-Host 'Runner start command issued.'
|
||||
@@ -0,0 +1,9 @@
|
||||
Get-CimInstance Win32_Process -ErrorAction SilentlyContinue |
|
||||
Where-Object {
|
||||
$_.Name -match 'act_runner' -or
|
||||
$_.CommandLine -match 'act_runner'
|
||||
} |
|
||||
ForEach-Object {
|
||||
Stop-Process -Id $_.ProcessId -Force
|
||||
Write-Host ("Stopped runner process: {0}" -f $_.ProcessId)
|
||||
}
|
||||
Reference in New Issue
Block a user