Files
❤是纱雾酱哟~ 936764e6ce feat: Enable git hooks with husky (#4984)
* build(deps): Adds husky for Git hooks

- Integrates the husky package as a development dependency.
- Enables the configuration and enforcement of pre-commit and pre-push Git hooks.
- Improves code quality and consistency by automating checks before commits.

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>

* feat: Add Husky prepare hook

- Automatically installs Git hooks for developers
- Ensures consistent code quality checks before commits or pushes
- Streamlines the developer setup process

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>

* ci: Avoid installing Git Hooks on GitHub Workflows

- Adds `HUSKY: 0` environment variable to all workflow definitions.
- Prevents local development hooks from executing in CI, which can cause unnecessary failures or overhead.
- See https://typicode.github.io/husky/how-to.html#ci-server-and-docker

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>

---------

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>
2025-10-09 05:10:03 +08:00

93 lines
2.3 KiB
YAML

# Copyright 2019-2024 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
name: Check Formatting
on:
pull_request:
env:
HUSKY: 0
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Rust changes
id: check_rust
uses: dorny/paths-filter@v3
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
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Web changes
id: check_web
uses: dorny/paths-filter@v3
with:
filters: |
web:
- 'src/**'
- '**/*.js'
- '**/*.ts'
- '**/*.tsx'
- '**/*.css'
- '**/*.scss'
- '**/*.json'
- '**/*.md'
- '**/*.json'
- name: Skip if no Web changes
if: steps.check_web.outputs.web != 'true'
run: echo "No web changes, skipping prettier."
- uses: actions/setup-node@v4
if: steps.check_web.outputs.web == 'true'
with:
node-version: "lts/*"
- run: corepack enable
if: steps.check_web.outputs.web == 'true'
- run: pnpm install --frozen-lockfile
if: steps.check_web.outputs.web == 'true'
- run: pnpm format:check
if: steps.check_web.outputs.web == 'true'
# taplo:
# name: taplo (.toml files)
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: install Rust stable
# uses: dtolnay/rust-toolchain@stable
# - name: install taplo-cli
# uses: taiki-e/install-action@v2
# with:
# tool: taplo-cli
# - run: taplo fmt --check --diff