From 09e45573c89fc07f789a565be996cbc5fb28993e Mon Sep 17 00:00:00 2001 From: Wanderingss <1624155937@qq.com> Date: Fri, 2 Oct 2026 01:11:45 +0800 Subject: [PATCH] =?UTF-8?q?CI=EF=BC=9A=E4=BF=AE=E6=AD=A3=20workflow=20?= =?UTF-8?q?=E7=9A=84=20shell=20=E4=B8=BA=20powershell=EF=BC=88pwsh=20?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首次 CI 运行(run#1)两个 job 均失败于同一处: Cannot find: pwsh in PATH 根因:workflow 用 shell: pwsh(PowerShell 7,非 Windows 自带), 而 runner 所在机器只有 Windows PowerShell 5.1。 改为 shell: powershell(7 处)。已核验脚本无 PS7 独有语法 (无 ?? / ?: / && / || / -Parallel),PS 5.1 完全兼容。 workflow 头部补该坑说明,防止将来误改回 pwsh。 注:本次 CI 已验证 actions/checkout@v4 可从本实例正常拉取并 成功检出 v2-on-ui,action 拉取链路无需调整。 --- .gitea/workflows/ci.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 5c69c2f0..7edfe571 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -16,6 +16,14 @@ # # 触发:push(除纯文档路径外)与 pull_request。 # +# 🔴 shell 用 `powershell` 而非 `pwsh`(2026-10-02 实测修正): +# `pwsh` = PowerShell 7,**不是 Windows 自带**;本机 runner 只有 +# Windows PowerShell 5.1(`C:\Windows\System32\WindowsPowerShell\v1.0\`), +# 用 `shell: pwsh` 会直接报 `Cannot find: pwsh in PATH` → job 失败(跑不到任何业务逻辑)。 +# `shell: powershell` 在任意 Windows 上都存在,且本 workflow 的脚本 +# **刻意只用 PS 5.1 兼容语法**(无 `??`/`?:`/`&&`/`||`/`-Parallel`)。 +# ⚠️ 若将来要改回 `pwsh`,须先在所有 runner 上装 PowerShell 7。 +# # ⚠️ 前置(部署到 Gitea 时需确认): # - 该 Gitea 实例已启用 Actions:`[actions] ENABLED = true`(site admin 配置) # - 已注册一个 **Windows** runner(labels 含 `windows`),且装有: @@ -60,7 +68,7 @@ jobs: fetch-depth: 0 - name: 环境自检(Python / cppcheck / pre-commit) - shell: pwsh + shell: powershell run: | $ErrorActionPreference = 'Stop' $missing = @() @@ -88,12 +96,12 @@ jobs: Write-Host "runner 环境自检通过" - name: 安装 pre-commit 钩子到本仓库 - shell: pwsh + shell: powershell run: python -m pre_commit install --install-hooks - name: 决定跳过哪些钩子(Keil 依赖) id: skip - shell: pwsh + shell: powershell run: | # mem-numbers 的事实源是 Keil 构建产物 .map(已 gitignore)。 # 无 .map => 本 runner 不可能跑 L0 的该钩子 => 跳过(不是"通过",是"不适用")。 @@ -107,7 +115,7 @@ jobs: } - name: 运行 L0 门禁(--all-files) - shell: pwsh + shell: powershell env: SKIP: ${{ steps.skip.outputs.value }} run: | @@ -129,7 +137,7 @@ jobs: - name: 探测 MSVC(VS BuildTools / Community 等) id: msvc - shell: pwsh + shell: powershell run: | # 与 test/host/common/unit_test_harness.py 的 VS_ROOTS 保持一致 $roots = @( @@ -155,7 +163,7 @@ jobs: - name: 运行主机侧单测 if: steps.msvc.outputs.value == 'yes' - shell: pwsh + shell: powershell run: | # 遍历 test/host/*/run_unit_test.py(各模块自带运行器,统一走 common harness) $runners = Get-ChildItem -Path 'test/host' -Recurse -Filter 'run_unit_test.py' | @@ -179,7 +187,7 @@ jobs: - name: L0.5 跳过说明 if: steps.msvc.outputs.value == 'no' - shell: pwsh + shell: powershell run: | Write-Host "L0.5 未执行:runner 缺 MSVC。" Write-Host "本地等价命令:& '.venv\Scripts\python.exe' scripts/ci_local.py"