From feaa3fca36d0701c89ca918092dd35c2411a0d68 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Sun, 5 Apr 2026 22:40:16 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=BC=98=E5=8C=96=20GitHub=20Actions=20?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 5 +++++ .github/workflows/lint.yml | 6 +++++- scripts/pre_commit.sh | 14 +++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3d150ac..015d263 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,9 +5,14 @@ *.sh text eol=lf *.py text eol=lf *.md text eol=lf +*.yml text eol=lf + Dockerfile text eol=lf .dockerignore text eol=lf +.gitignore text eol=lf +.gitattributes text eol=lf + # Windows scripts - use CRLF *.bat text eol=crlf *.cmd text eol=crlf diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6bcea63..8e8e655 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,4 +24,8 @@ jobs: - name: Check formatting with ruff run: | - ruff format --check . \ No newline at end of file + ruff format --check . + + - name: Check import sorting + run: | + ruff check . --select I \ No newline at end of file diff --git a/scripts/pre_commit.sh b/scripts/pre_commit.sh index 18e66af..7b266eb 100755 --- a/scripts/pre_commit.sh +++ b/scripts/pre_commit.sh @@ -60,13 +60,13 @@ run_lint() { fi } -# Run code style check (linter) -run_ruff_lint() { - print_info "Running code style check (ruff check)..." - if ruff check .; then - print_success "Code style check passed" +# Run code style check (linter - import sorting) +run_ruff_lint_import() { + print_info "Running import sorting check (ruff check --select I)..." + if ruff check . --select I; then + print_success "Import sorting check passed" else - print_error "Code style check failed. Please fix the issues above" + print_error "Import sorting check failed. Please run 'ruff check --select I --fix .' to fix import issues" exit 1 fi } @@ -138,7 +138,7 @@ main() { # Run code checks if [ "$SKIP_LINT" = false ]; then run_lint - run_ruff_lint + run_ruff_lint_import else print_info "Skipping code checks" fi