Skip to content

fix(ci): 修复 ootb 工作流长期失败的四处根因 #21

fix(ci): 修复 ootb 工作流长期失败的四处根因

fix(ci): 修复 ootb 工作流长期失败的四处根因 #21

Workflow file for this run

name: ootb
on:
push:
branches: [main, refactor/**]
pull_request:
branches: [main, refactor/**]
jobs:
smoke:
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.5'
- name: Install root deps
shell: pwsh
run: npm install --no-audit --no-fund
- name: Build all workspaces
shell: pwsh
run: npm run build --workspaces --if-present
- name: Populate configs/ from configs-default/
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path configs | Out-Null
Get-ChildItem -Path configs-default -Filter *.json | ForEach-Object {
$dest = Join-Path configs $_.Name
if (-not (Test-Path $dest)) { Copy-Item $_.FullName $dest }
}
- name: Run check-ootb
shell: pwsh
run: node tools/check-ootb.js
- name: Run smoke-modules (against temporary db-server)
shell: pwsh
run: |
$port = if ($env:DB_PORT) { $env:DB_PORT } else { '3001' }
if (Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue) {
Get-NetTCPConnection -LocalPort $port | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }
Start-Sleep -Seconds 2
}
$env:SFMC_ROOT = $PWD.Path
$db = Start-Process -FilePath node -ArgumentList "db-server/dist/index.js" -WorkingDirectory $PWD -WindowStyle Hidden -RedirectStandardOutput "db-server/_smoke.out" -RedirectStandardError "db-server/_smoke.err" -PassThru
try {
$ready = $false
for ($i=0; $i -lt 40; $i++) {
try {
$r = Invoke-WebRequest -UseBasicParsing "http://127.0.0.1:$port/api/health" -TimeoutSec 2
if ($r.StatusCode -eq 200) { $ready = $true; break }
} catch {}
Start-Sleep -Milliseconds 300
}
if (-not $ready) { throw "db-server not ready" }
node tools/smoke-modules.js
} finally {
Stop-Process -Id $db.Id -Force -ErrorAction SilentlyContinue
Remove-Item -Force db-server/_smoke.out,db-server/_smoke.err -ErrorAction SilentlyContinue
}