From a8257e8cb221f31b558447258bb866e58b4c5800 Mon Sep 17 00:00:00 2001 From: Tunglies Date: Wed, 18 Jun 2025 01:11:33 +0800 Subject: [PATCH] fix: unexpected behavior while pulling resources (#3789) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: unexpected behavior while pulling resources 在 commit 25cfd162f6a4db3f9e772ffec9fe3db9e080624a 中引入新的 pnpm prepare 执行脚本指令,而 prepare 关键字与包管理器的生命周期脚本冲突。导致在运行 Workflow 的时候被执行两次资源拉取,并且被当做生命周期脚本的时候没有携带预期的 \`${{ matrix.target }}\`。这一行为进一步影响 macOS Intel X86 平台上的构建。 所影响的 issues: #3753, #3771 --- .github/workflows/alpha.yml | 14 ++++++-------- .github/workflows/autobuild.yml | 14 ++++++-------- .github/workflows/clippy.yml | 13 ++++++------- .github/workflows/cross_check.yaml | 5 ++--- .github/workflows/dev.yml | 5 ++--- .github/workflows/fmt.yml | 2 ++ .github/workflows/release.yml | 14 ++++++-------- CONTRIBUTING.md | 4 ++-- package.json | 2 +- scripts/{prepare.mjs => prebuild.mjs} | 2 -- src-tauri/src/cmd/profile.rs | 2 +- 11 files changed, 34 insertions(+), 43 deletions(-) rename scripts/{prepare.mjs => prebuild.mjs} (99%) diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index 0c5cfa3b..6c21bc22 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -286,8 +286,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true - cache-on-failure: true + save-if: false - name: Install dependencies (ubuntu only) if: matrix.os == 'ubuntu-22.04' @@ -308,7 +307,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} # - name: Release ${{ env.TAG_CHANNEL }} Version # run: pnpm release-version ${{ env.TAG_NAME }} @@ -363,7 +362,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true + save-if: false - name: Install Node uses: actions/setup-node@v4 @@ -378,7 +377,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} # - name: Release ${{ env.TAG_CHANNEL }} Version # run: pnpm release-version ${{ env.TAG_NAME }} @@ -491,8 +490,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true - cache-on-failure: true + save-if: false - name: Install Node uses: actions/setup-node@v4 @@ -507,7 +505,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} # - name: Release ${{ env.TAG_CHANNEL }} Version # run: pnpm release-version ${{ env.TAG_NAME }} diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 4658ff22..2acf2ba3 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -183,7 +183,7 @@ jobs: with: workspaces: src-tauri cache-all-crates: true - cache-on-failure: true + save-if: ${{ github.ref == 'refs/heads/dev' }} - name: Install dependencies (ubuntu only) if: matrix.os == 'ubuntu-22.04' @@ -201,13 +201,10 @@ jobs: with: run_install: false - - name: Debug matrix - run: echo "target=${{ matrix.target }}" - - name: Pnpm install and check run: | pnpm i - node scripts/prepare.js "${{ matrix.target }}" + pnpm run prebuild "${{ matrix.target }}" - name: Release ${{ env.TAG_CHANNEL }} Version run: pnpm release-version ${{ env.TAG_NAME }} @@ -263,6 +260,7 @@ jobs: with: workspaces: src-tauri cache-all-crates: true + save-if: ${{ github.ref == 'refs/heads/dev' }} - name: Install Node uses: actions/setup-node@v4 @@ -277,7 +275,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Release ${{ env.TAG_CHANNEL }} Version run: pnpm release-version ${{ env.TAG_NAME }} @@ -391,7 +389,7 @@ jobs: with: workspaces: src-tauri cache-all-crates: true - cache-on-failure: true + save-if: ${{ github.ref == 'refs/heads/dev' }} - name: Install Node uses: actions/setup-node@v4 @@ -406,7 +404,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Release ${{ env.TAG_CHANNEL }} Version run: pnpm release-version ${{ env.TAG_NAME }} diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index f805ce1a..64392ab3 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -27,12 +27,11 @@ jobs: - name: Add Rust Target run: rustup target add ${{ matrix.target }} - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # with: - # workspaces: src-tauri - # cache-all-crates: true - # cache-on-failure: true + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: src-tauri + save-if: false - name: Install dependencies (ubuntu only) if: matrix.os == 'ubuntu-22.04' @@ -53,7 +52,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Build Web Assets run: pnpm run web:build diff --git a/.github/workflows/cross_check.yaml b/.github/workflows/cross_check.yaml index eaf1b315..e00099c4 100644 --- a/.github/workflows/cross_check.yaml +++ b/.github/workflows/cross_check.yaml @@ -50,14 +50,13 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Rust Cache uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true - cache-on-failure: true + save-if: false - name: Cargo Check (deny warnings) working-directory: src-tauri diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 0ab6dd7e..53b771cc 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -42,8 +42,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true - cache-on-failure: true + save-if: false - name: Install Node uses: actions/setup-node@v4 @@ -58,7 +57,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Tauri build uses: tauri-apps/tauri-action@v0 diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index 1eef2560..51ecbba2 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -31,6 +31,8 @@ jobs: with: node-version: "lts/*" cache: "pnpm" + cache-dependency-path: | + pnpm-lock.yaml - run: pnpm i --frozen-lockfile - run: pnpm format:check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0dc19e60..e101675c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,8 +73,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true - cache-on-failure: true + save-if: false - name: Install dependencies (ubuntu only) if: matrix.os == 'ubuntu-22.04' @@ -95,7 +94,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Tauri build uses: tauri-apps/tauri-action@v0 @@ -144,7 +143,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true + save-if: false - name: Install Node uses: actions/setup-node@v4 @@ -159,7 +158,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: "Setup for linux" run: |- @@ -263,8 +262,7 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - cache-all-crates: true - cache-on-failure: true + save-if: false - name: Install Node uses: actions/setup-node@v4 @@ -279,7 +277,7 @@ jobs: - name: Pnpm install and check run: | pnpm i - pnpm prepare ${{ matrix.target }} + pnpm run prebuild ${{ matrix.target }} - name: Download WebView2 Runtime run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45a6c696..e4631313 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,9 +52,9 @@ You have two options for downloading the clash binary: - Automatically download it via the provided script: ```shell - pnpm run prepare + pnpm run prebuild # Use '--force' to force update to the latest version - # pnpm run prepare --force + # pnpm run prebuild --force ``` - Manually download it from the [Mihomo release](https://github.com/MetaCubeX/mihomo/releases). After downloading, rename the binary according to the [Tauri configuration](https://tauri.app/v1/api/config#bundleconfig.externalbin). diff --git a/package.json b/package.json index 00fd423c..20e1b61a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "web:dev": "vite", "web:build": "tsc --noEmit && vite build", "web:serve": "vite preview", - "prepare": "node scripts/prepare.mjs", + "prebuild": "node scripts/prebuild.mjs", "updater": "node scripts/updater.mjs", "updater-fixed-webview2": "node scripts/updater-fixed-webview2.mjs", "portable": "node scripts/portable.mjs", diff --git a/scripts/prepare.mjs b/scripts/prebuild.mjs similarity index 99% rename from scripts/prepare.mjs rename to scripts/prebuild.mjs index 2ad80b7c..fd7a9cd0 100644 --- a/scripts/prepare.mjs +++ b/scripts/prebuild.mjs @@ -1,5 +1,3 @@ -console.log('prepare.mjs argv:', process.argv) - import fs from "fs"; import fsp from "fs/promises"; import zlib from "zlib"; diff --git a/src-tauri/src/cmd/profile.rs b/src-tauri/src/cmd/profile.rs index 56f729e7..36de5997 100644 --- a/src-tauri/src/cmd/profile.rs +++ b/src-tauri/src/cmd/profile.rs @@ -83,7 +83,7 @@ pub async fn get_profiles() -> CmdResult { "所有获取配置策略都失败,尝试fallback" ); - match tokio::task::spawn_blocking(move || IProfiles::new()).await { + match tokio::task::spawn_blocking(IProfiles::new).await { Ok(profiles) => { logging!(info, Type::Cmd, true, "使用fallback配置成功"); Ok(profiles)