From 02e5e0e4a6bea90e9b7f5c61d54dd90806967893 Mon Sep 17 00:00:00 2001 From: Tunglies Date: Tue, 27 Oct 2026 16:36:49 +0800 Subject: [PATCH] ci: gate frontend and rust checks by changed paths (#8433) The paths-filter output in lint-clippy.yml only gated two echo steps; checkout, toolchain setup and clippy itself ran unconditionally, so frontend-only PRs still burned a 3-runner matrix on a full clippy build plus the logging-check tool install. - lint-clippy/rustfmt/frontend-check: move path filters to workflow level so irrelevant PRs spawn no runner at all - split contract-parity into its own workflow; its trigger set spans both sides and workflow paths cannot vary per job - clippy paths now cover crates/** and workspace Cargo files, which the old src-tauri/** filter missed dev has no required status checks, so path-filtered workflows cannot get stuck in "Expected". --- .github/workflows/contract-parity.yml | 80 +++++++++++++++++ .github/workflows/frontend-check.yml | 118 +++----------------------- .github/workflows/lint-clippy.yml | 31 ++----- .github/workflows/rustfmt.yml | 19 +---- scripts/contract-inputs.json | 2 +- 5 files changed, 107 insertions(+), 143 deletions(-) create mode 100644 .github/workflows/contract-parity.yml diff --git a/.github/workflows/contract-parity.yml b/.github/workflows/contract-parity.yml new file mode 100644 index 000000000..d83f437a9 --- /dev/null +++ b/.github/workflows/contract-parity.yml @@ -0,0 +1,80 @@ +name: Contract Parity + +on: + pull_request: + paths: + - "src-tauri/**/*.rs" + - "crates/**/*.rs" + - "Cargo.toml" + - "Cargo.lock" + - "src-tauri/Cargo.toml" + - "crates/**/Cargo.toml" + - "rust-toolchain.toml" + - "src-tauri/tauri.conf*.json" + - "src/services/bindings.ts" + - "scripts/gen-contract.mjs" + - "scripts/check-contract-changes.mjs" + - "biome.json" + - "biome.jsonc" + - "package.json" + - "pnpm-lock.yaml" + - "pnpm-workspace.yaml" + - "scripts/contract-inputs.json" + - ".github/workflows/contract-parity.yml" + - ".husky/pre-push" + workflow_dispatch: + +permissions: + contents: read + +env: + HUSKY: 0 + +jobs: + contract-parity: + runs-on: ubuntu-26.04 + steps: + - uses: actions/checkout@v7 + + - name: Install Rust Stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + with: + prefix-key: 'v1-rust' + key: 'rust-shared-stable-ubuntu-22.04-x86_64-unknown-linux-gnu-contract' + workspaces: | + . -> target + cache-all-crates: true + cache-workspace-crates: true + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf + + - name: Install pnpm + uses: pnpm/action-setup@v6 + with: + run_install: false + + - uses: actions/setup-node@v7 + with: + node-version: '24.22.1' + cache: 'pnpm' + + - run: pnpm install --frozen-lockfile + + - name: Provision sidecar placeholders for tauri-build + run: | + mkdir -p src-tauri/sidecar src-tauri/resources dist + touch dist/index.html + for bin in clash-verge-service clash-verge-service-install clash-verge-service-uninstall verge-mihomo verge-mihomo-alpha; do + touch "src-tauri/sidecar/${bin}-x86_64-unknown-linux-gnu" + done + + - name: Check generated contract without changing the checkout + run: pnpm gen:contract --check diff --git a/.github/workflows/frontend-check.yml b/.github/workflows/frontend-check.yml index 22b8333ac..d18b3993d 100644 --- a/.github/workflows/frontend-check.yml +++ b/.github/workflows/frontend-check.yml @@ -2,11 +2,23 @@ name: Frontend Check on: pull_request: + paths: + - "src/**" + - "**/*.js" + - "**/*.ts" + - "**/*.tsx" + - "**/*.css" + - "**/*.scss" + - "**/*.json" + - "**/*.md" + - "pnpm-lock.yaml" + - "pnpm-workspace.yaml" + - "vite.config.*" + - ".github/workflows/frontend-check.yml" workflow_dispatch: permissions: contents: read - pull-requests: read env: HUSKY: 0 @@ -17,46 +29,17 @@ jobs: steps: - uses: actions/checkout@v7 - - name: Check frontend changes - id: check_frontend - uses: dorny/paths-filter@v4 - with: - filters: | - frontend: - - 'src/**' - - '**/*.js' - - '**/*.ts' - - '**/*.tsx' - - '**/*.css' - - '**/*.scss' - - '**/*.json' - - '**/*.md' - - 'package.json' - - 'pnpm-lock.yaml' - - 'pnpm-workspace.yaml' - - 'knip.json' - - 'eslint.config.ts' - - 'tsconfig.json' - - 'vite.config.*' - - - name: Skip if no frontend changes - if: steps.check_frontend.outputs.frontend != 'true' - run: echo "No frontend changes, skipping frontend checks." - - name: Install pnpm - if: steps.check_frontend.outputs.frontend == 'true' uses: pnpm/action-setup@v6 with: run_install: false - uses: actions/setup-node@v7 - if: steps.check_frontend.outputs.frontend == 'true' with: node-version: '24.22.1' cache: 'pnpm' - name: Restore pnpm cache - if: steps.check_frontend.outputs.frontend == 'true' uses: actions/cache@v6 with: path: ~/.pnpm-store @@ -65,94 +48,21 @@ jobs: pnpm-shared-stable-${{ runner.os }}- - run: pnpm install --frozen-lockfile - if: steps.check_frontend.outputs.frontend == 'true' - name: Run Prettier check - if: steps.check_frontend.outputs.frontend == 'true' run: pnpm format:check - name: Run ESLint - if: steps.check_frontend.outputs.frontend == 'true' run: pnpm lint - - name: Run tsrs typecheck - if: steps.check_frontend.outputs.frontend == 'true' + - name: Run TypeScript typecheck run: pnpm typecheck - name: Run tests - if: steps.check_frontend.outputs.frontend == 'true' run: pnpm test - name: Run Knip - if: steps.check_frontend.outputs.frontend == 'true' run: pnpm knip:check - name: Architecture gates (listen/emit only in the event bus, invoke only in services) - if: steps.check_frontend.outputs.frontend == 'true' run: node scripts/check-architecture.mjs listen emit invoke - - contract-parity: - runs-on: ubuntu-26.04 - steps: - - uses: actions/checkout@v7 - - - name: Check contract inputs - id: check_inputs - uses: dorny/paths-filter@v4 - with: - filters: scripts/contract-inputs.json - - - name: Skip if contract inputs unchanged - if: steps.check_inputs.outputs.contract != 'true' - run: echo "No contract inputs changed, skipping parity check." - - - name: Install Rust Stable - if: steps.check_inputs.outputs.contract == 'true' - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - - - name: Rust Cache - if: steps.check_inputs.outputs.contract == 'true' - uses: Swatinem/rust-cache@v2 - with: - prefix-key: 'v1-rust' - key: 'rust-shared-stable-ubuntu-22.04-x86_64-unknown-linux-gnu-contract' - workspaces: | - . -> target - cache-all-crates: true - cache-workspace-crates: true - - - name: Install dependencies - if: steps.check_inputs.outputs.contract == 'true' - run: | - sudo apt-get update - sudo apt-get install -y libxslt1.1 libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf - - - name: Install pnpm - if: steps.check_inputs.outputs.contract == 'true' - uses: pnpm/action-setup@v6 - with: - run_install: false - - - uses: actions/setup-node@v7 - if: steps.check_inputs.outputs.contract == 'true' - with: - node-version: '24.22.1' - cache: 'pnpm' - - - run: pnpm install --frozen-lockfile - if: steps.check_inputs.outputs.contract == 'true' - - - name: Provision sidecar placeholders for tauri-build - if: steps.check_inputs.outputs.contract == 'true' - run: | - mkdir -p src-tauri/sidecar src-tauri/resources dist - touch dist/index.html - for bin in clash-verge-service clash-verge-service-install clash-verge-service-uninstall verge-mihomo verge-mihomo-alpha; do - touch "src-tauri/sidecar/${bin}-x86_64-unknown-linux-gnu" - done - - - name: Check generated contract without changing the checkout - if: steps.check_inputs.outputs.contract == 'true' - run: pnpm gen:contract --check diff --git a/.github/workflows/lint-clippy.yml b/.github/workflows/lint-clippy.yml index 37e75aab6..8a623f515 100644 --- a/.github/workflows/lint-clippy.yml +++ b/.github/workflows/lint-clippy.yml @@ -2,6 +2,13 @@ name: Clippy Lint on: pull_request: + paths: + - "src-tauri/**" + - "crates/**" + - "Cargo.toml" + - "Cargo.lock" + - "rust-toolchain.toml" + - ".github/workflows/lint-clippy.yml" workflow_dispatch: env: HUSKY: 0 @@ -23,28 +30,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Check src-tauri changes - if: github.event_name != 'workflow_dispatch' - id: check_changes - uses: dorny/paths-filter@v4 - with: - filters: | - rust: - - 'src-tauri/**' - - - name: Skip if src-tauri not changed - if: github.event_name != 'workflow_dispatch' && steps.check_changes.outputs.rust != 'true' - run: echo "No src-tauri changes, skipping clippy lint." - - - name: Continue if src-tauri changed - if: github.event_name != 'workflow_dispatch' && steps.check_changes.outputs.rust == 'true' - run: echo "src-tauri changed, running clippy lint." - - - name: Manual trigger - always run - if: github.event_name == 'workflow_dispatch' - run: | - echo "Manual trigger detected: skipping changes check and running clippy." - - name: Checkout Repository uses: actions/checkout@v7 @@ -79,7 +64,7 @@ jobs: run: cargo clippy-all - name: Run Windows security tests - if: matrix.os == 'windows-latest' && (github.event_name == 'workflow_dispatch' || steps.check_changes.outputs.rust == 'true') + if: matrix.os == 'windows-latest' working-directory: ./src-tauri run: cargo test --all-features --target ${{ matrix.target }} diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 28f86cb80..1ae6035dd 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -6,6 +6,10 @@ name: Check Formatting on: pull_request: + paths: + - "src-tauri/**" + - "**/*.rs" + - ".github/workflows/rustfmt.yml" permissions: contents: read @@ -19,25 +23,10 @@ jobs: steps: - uses: actions/checkout@v7 - - name: Check Rust changes - id: check_rust - uses: dorny/paths-filter@v4 - with: - filters: | - rust: - - 'src-tauri/**' - - '**/*.rs' - - - name: Skip if no Rust changes - if: steps.check_rust.outputs.rust != 'true' - run: echo "No Rust changes, skipping rustfmt." - - name: install Rust stable and rustfmt - if: steps.check_rust.outputs.rust == 'true' uses: dtolnay/rust-toolchain@stable with: components: rustfmt - name: run cargo fmt - if: steps.check_rust.outputs.rust == 'true' run: cargo fmt --manifest-path ./src-tauri/Cargo.toml --all -- --check diff --git a/scripts/contract-inputs.json b/scripts/contract-inputs.json index 4e9f93100..d89d8dd3c 100644 --- a/scripts/contract-inputs.json +++ b/scripts/contract-inputs.json @@ -17,7 +17,7 @@ "pnpm-lock.yaml", "pnpm-workspace.yaml", "scripts/contract-inputs.json", - ".github/workflows/frontend-check.yml", + ".github/workflows/contract-parity.yml", ".husky/pre-push" ] }