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