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"