From 817ec3645b8dd0331d98f372d7207b109dd46668 Mon Sep 17 00:00:00 2001 From: jkooe <62494645+jkooe@users.noreply.github.com> Date: Wed, 7 Oct 2026 02:04:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20BOM=20=E5=AE=88=E5=8D=AB=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E6=94=B9=E7=94=A8=20shell:=20powershell=EF=BC=88cmd?= =?UTF-8?q?=20=E5=A5=97=20-Command=20=E5=A4=9A=E8=A1=8C=E5=BC=95=E5=8F=B7?= =?UTF-8?q?=E4=BC=9A=E5=85=A8=E4=B9=B1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 第一轮 CI 暴露:该步骤自身写法错,不是脚本错。shell: cmd + powershell -Command "..." 带多行/内层引号,经 cmd 转义后变成: Missing closing '}' / '$errs' is not recognized / -and was unexpected 全是指 step 自身,与被测 .ps1 无关。 修正:直接用 shell: powershell(runner 上的 powershell 就是 5.1,正是要测的目标)+ run: | 块, 与旁边已通过的 install 冒烟步骤同一形态。 --- .github/workflows/windows-e2e.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows-e2e.yml b/.github/workflows/windows-e2e.yml index 4c75744..420394b 100644 --- a/.github/workflows/windows-e2e.yml +++ b/.github/workflows/windows-e2e.yml @@ -64,17 +64,19 @@ jobs: # 整份脚本 ParseError(真机 2026-10-04 踩过:install.ps1 报「","后面缺少表达式」)。 # 之前的冒烟全用 pwsh(7+ 认无 BOM UTF-8),所以 CI 绿、真机炸。 # 这里只做「解析 + 首行 help」检查:5.1 能否读懂,就是真机的核心约束。 + # ⚠️ 必须用 shell: powershell(runner 上的 powershell 即 Windows PowerShell 5.1)。 + # 不要用 shell: cmd 再套 powershell -Command "..." —— 多行带引号经 cmd 转义会全乱 + # (实测:Missing closing '}' / '$errs' is not recognized,是步骤自身坏,不是脚本坏)。 - name: 冒烟 — 脚本可被 Windows PowerShell 5.1 解析(BOM 守卫) - shell: cmd - run: > - powershell -NoProfile -ExecutionPolicy Bypass -Command " - $ErrorActionPreference='Stop'; - foreach ($f in @('scripts\install.ps1','scripts\uninstall.ps1','scripts\rescue-network.ps1')) { - $errs = $null; - [void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path $f).Path, [ref]$null, [ref]$errs); + shell: powershell + run: | + $ErrorActionPreference = 'Stop' + foreach ($f in @('scripts\install.ps1', 'scripts\uninstall.ps1', 'scripts\rescue-network.ps1')) { + $errs = $null + [void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path $f).Path, [ref]$null, [ref]$errs) if ($errs -and $errs.Count -gt 0) { throw ('5.1 解析失败 ' + $f + ' -> ' + $errs[0].Message) } - Write-Host ('OK 5.1 parse: ' + $f); - }" + Write-Host ('OK 5.1 parse: ' + $f) + } - name: 冒烟 — install.ps1 安装链路 shell: powershell