From ac3d639d6b93e1ad3a04f0b4f4af3f1182e3eea1 Mon Sep 17 00:00:00 2001 From: sloray Date: Thu, 15 Oct 2026 22:44:05 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20Windows=20job=20=E4=BD=8E=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=80=A7=E9=80=82=E9=85=8D=20=E2=80=94=E2=80=94=20?= =?UTF-8?q?=E6=8A=8A=20CI=20=E7=9A=84"=E5=AE=B6=E7=9B=AE=E5=BD=95"?= =?UTF-8?q?=E6=8C=AA=E5=88=B0=20runner=20=E8=87=AA=E5=B7=B1=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 诊断步骤(在 job 里跑的写探测)给出了确定答案: whoami = timi\admin integrity = Mandatory Label\Low Mandatory Level S-1-16-4096 <-- 低完整性 FAIL: C:\Users\admin\.rustup\tmp\probe.txt Access denied FAIL: C:\Users\admin\.cargo\probe.txt Access denied FAIL: C:\Users\admin\.cargo\registry\probe.txt Access denied OK : C:\Users\admin\runner\windows OK : C:\Users\admin\runner\windows\cache OK : \ci-probe 不是 ACL 问题(SYSTEM / Administrators / timi\admin 全 F,没有 Deny),是 Windows 的 "低完整性不能写中完整性"。同一个账户在交互式会话(Medium,实测 S-1-16-8192)里往 ~/.rustup、~/.cargo 写得进去,job 里就全被拒。于是前面几个看起来毫不相干的错误都是 同一个原因:Git Bash /tmp 被拒(TEMP 不可写时它退回 \tmp)、rustup 建不了临时 文件。%TEMP%、%LOCALAPPDATA% 也一样中招。 处置(Windows job 内): * env 增加 RUSTUP_HOME / CARGO_HOME / npm_config_cache / npm_config_store_dir / RUNNER_TOOL_CACHE,全部指向 C:\Users\admin\runner\windows\cache\ci-*(探测过可写) * pnpm/action-setup 的 dest 从默认 ~/setup-pnpm 改到同一个 cache 下 * TEMP/TMP/TMPDIR 上一版已经指到 workspace 同级的 ci-tmp 文件头第 5 条写清了这个坑、表现、以及从根上的解法(让 gitea-runner 以中完整性启动)。 临时诊断步骤暂时保留,等 Windows 真编出包来再删。 --- .github/workflows/build-client.yml | 34 ++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index 34b8c2b..c95263f 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -56,8 +56,7 @@ # ~/.cargo/git/db # key: ${{ runner.os }}-cargo-registry-${{ hashFiles('protocol/Cargo.lock', 'desktop/core/Cargo.lock', 'desktop/src-tauri/Cargo.lock') }} # restore-keys: ${{ runner.os }}-cargo-registry- -# 4. 平台开关只用 github.event.inputs,**不用仓库变量**。2026-10-15 那次 Windows -# runner 明明在线、job 也确实派给了它(它自己的日志里写着 +# 4. 平台开关只用 github.event.inputs,**不用仓库变量**。2026-10-15 那次 Windows# runner 明明在线、job 也确实派给了它(它自己的日志里写着 # "Runner labels: windows-latest, windows-2025, windows-2022"),产物却一直是 # skipped —— 卡在 job 级 if 的 `vars.ENABLE_WINDOWS == 'true'` 上:Gitea 的 # runner 在 job 级 if 里拿不到(或拿不对)vars 上下文,而这个条件写反的代价是 @@ -69,6 +68,22 @@ # * macOS:`github.event.inputs.macos == 'true'` → 默认不跑,等有机器了改成 # 上一种形式即可 # runs-on 里的 vars(RUNNER_*)不受影响,标签不匹配时用那个覆盖。 +# 5. Windows runner 的 job 跑在**低完整性**上(实测 Mandatory Label\Low Mandatory +# Level, S-1-16-4096),而 Windows 不允许低完整性往中完整性写:用户目录 +# (~/.rustup、~/.cargo、%TEMP%、%LOCALAPPDATA%)统统 Access denied (os error 5) +# —— ACL 是干净的(SYSTEM / Administrators / 本人 全 F,没有任何 Deny),拦它的是 +# 完整性级别,所以"放宽权限"一点用都没有。表现是一串看着毫不相干的错误: +# * Git Bash 的 mktemp 写 /tmp 被拒(它的 /tmp 跟着 TEMP 走;TEMP 不可写时退回 +# \tmp,那个目录普通权限进不去); +# * rustup: could not create temp file C:\Users\admin\.rustup\tmp\xxx_file +# 处置:Windows job 把能重定向的都指到 runner 自己的工作目录 +# (C:\Users\admin\runner\windows\cache,job 内写探测实测可写)—— +# RUSTUP_HOME / CARGO_HOME / npm_config_cache / npm_config_store_dir / +# RUNNER_TOOL_CACHE,加上 TEMP/TMP/TMPDIR 与 pnpm/action-setup 的 dest。 +# 想从根上解决:让 gitea-runner 以**中完整性**启动(在普通终端里跑 +# run-runner.ps1,而不是从被沙箱化的低完整性 shell 里拉起来),那样这些重定向 +# 就都可以撤掉。这台机器上 runner 由计划任务 GiteaRunner-Windows(admin / +# Limited)拉起,但进程链上的完整性已经落到了 Low。 # # ── 三个平台都显式写 --target,这不是啰嗦 ──────────────────────────────────── # desktop/.cargo/config.toml 里钉着 `target = "aarch64-apple-darwin"`(本机开发用; @@ -333,6 +348,17 @@ jobs: env: TARGET: x86_64-pc-windows-msvc CARGO_BUILD_TARGET: x86_64-pc-windows-msvc + # 见文件头第 5 条:这台 runner 的 job 跑在**低完整性**(Low Mandatory Level, + # S-1-16-4096)上,而 Windows 不允许低完整性往中完整性写 —— 用户目录全中招: + # ~/.rustup、~/.cargo、%TEMP%、%LOCALAPPDATA% 下新建任何东西都是 + # "Access denied (os error 5)",ACL 再宽松也没用(没有 Deny ACE,是完整性 + # 级别拦的)。所以 CI 用到的每个"家目录"都挪到 runner 自己的工作目录下, + # 那几处在 job 内的写探测里实测可写。换一台 Windows runner 时改这几行。 + RUSTUP_HOME: C:\Users\admin\runner\windows\cache\ci-rustup + CARGO_HOME: C:\Users\admin\runner\windows\cache\ci-cargo + npm_config_cache: C:\Users\admin\runner\windows\cache\ci-npm + npm_config_store_dir: C:\Users\admin\runner\windows\cache\ci-pnpm-store + RUNNER_TOOL_CACHE: C:\Users\admin\runner\windows\cache\ci-toolcache steps: - uses: actions/checkout@v4 @@ -349,6 +375,8 @@ jobs: "TEMP / TMP = [$env:TEMP] / [$env:TMP]" "TMPDIR = [$env:TMPDIR]" "RUSTUP_HOME = [$env:RUSTUP_HOME] CARGO_HOME = [$env:CARGO_HOME]" + "TOOL_CACHE = [$env:RUNNER_TOOL_CACHE]" + "npm_config_* = store=[$env:npm_config_store_dir] cache=[$env:npm_config_cache]" "user-level TEMP = $([Environment]::GetEnvironmentVariable('TEMP','User'))" $targets = @( "$env:USERPROFILE\.rustup\tmp", @@ -416,6 +444,8 @@ jobs: uses: pnpm/action-setup@v4 with: version: ${{ env.PNPM_VERSION }} + # 默认 dest 是 ~/setup-pnpm,而 ~ 是中完整性的,低完整性写不进去。 + dest: C:\Users\admin\runner\windows\cache\ci-pnpm - name: 装 Node uses: actions/setup-node@v4