From 4e8fd73a20e62ff23972ad4d4d9ec46d1c2a24b4 Mon Sep 17 00:00:00 2001 From: Wanderson Pinto dos Santos <85753826+wanpdsantos@users.noreply.github.com> Date: Thu, 24 Apr 2025 00:25:33 -0300 Subject: [PATCH] chore: adds pre-commit (#7242) ### What problem does this PR solve? Sometimes after we commit the code and open the PR the CI pipeline fails in Ruff checks. Including a pre-commit we can identify this problem early and avoid time loss. ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [X] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): --- .pre-commit-config.yaml | 19 +++++++++++++++++++ README.md | 3 ++- README_id.md | 3 ++- README_ja.md | 3 ++- README_ko.md | 3 ++- README_pt_br.md | 3 ++- README_tzh.md | 3 ++- README_zh.md | 3 ++- 8 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..8a8cb2d57 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-yaml + - id: check-json + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-case-conflict + - id: check-merge-conflict + - id: mixed-line-ending + - id: check-symlinks + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.6 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format diff --git a/README.md b/README.md index f8636c9c0..bc2513878 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly 1. Install uv, or skip this step if it is already installed: ```bash - pipx install uv + pipx install uv pre-commit ``` 2. Clone the source code and install Python dependencies: @@ -305,6 +305,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules + pre-commit install ``` 3. Launch the dependent services (MinIO, Elasticsearch, Redis, and MySQL) using Docker Compose: diff --git a/README_id.md b/README_id.md index 7734d59c9..65aaf01ef 100644 --- a/README_id.md +++ b/README_id.md @@ -262,7 +262,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly 1. Instal uv, atau lewati langkah ini jika sudah terinstal: ```bash - pipx install uv + pipx install uv pre-commit ``` 2. Clone kode sumber dan instal dependensi Python: @@ -271,6 +271,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules + pre-commit install ``` 3. Jalankan aplikasi yang diperlukan (MinIO, Elasticsearch, Redis, dan MySQL) menggunakan Docker Compose: diff --git a/README_ja.md b/README_ja.md index 0cb3447b7..28b8b3a47 100644 --- a/README_ja.md +++ b/README_ja.md @@ -258,7 +258,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly 1. uv をインストールする。すでにインストールされている場合は、このステップをスキップしてください: ```bash - pipx install uv + pipx install uv pre-commit ``` 2. ソースコードをクローンし、Python の依存関係をインストールする: @@ -267,6 +267,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules + pre-commit install ``` 3. Docker Compose を使用して依存サービス(MinIO、Elasticsearch、Redis、MySQL)を起動する: diff --git a/README_ko.md b/README_ko.md index 440350b1a..f501199dd 100644 --- a/README_ko.md +++ b/README_ko.md @@ -257,7 +257,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly 1. uv를 설치하거나 이미 설치된 경우 이 단계를 건너뜁니다: ```bash - pipx install uv + pipx install uv pre-commit ``` 2. 소스 코드를 클론하고 Python 의존성을 설치합니다: @@ -266,6 +266,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules + pre-commit install ``` 3. Docker Compose를 사용하여 의존 서비스(MinIO, Elasticsearch, Redis 및 MySQL)를 시작합니다: diff --git a/README_pt_br.md b/README_pt_br.md index 446d74578..7c72a5980 100644 --- a/README_pt_br.md +++ b/README_pt_br.md @@ -281,7 +281,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly 1. Instale o `uv`, ou pule esta etapa se ele já estiver instalado: ```bash - pipx install uv + pipx install uv pre-commit ``` 2. Clone o código-fonte e instale as dependências Python: @@ -290,6 +290,7 @@ docker build --platform linux/amd64 -f Dockerfile -t infiniflow/ragflow:nightly git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # instala os módulos Python dependentes do RAGFlow + pre-commit install ``` 3. Inicie os serviços dependentes (MinIO, Elasticsearch, Redis e MySQL) usando Docker Compose: diff --git a/README_tzh.md b/README_tzh.md index 878c11771..2daa2c8f1 100644 --- a/README_tzh.md +++ b/README_tzh.md @@ -269,7 +269,7 @@ docker build --platform linux/amd64 --build-arg NEED_MIRROR=1 -f Dockerfile -t i 1. 安裝 uv。如已安裝,可跳過此步驟: ```bash - pipx install uv + pipx install uv pre-commit export UV_INDEX=https://mirrors.aliyun.com/pypi/simple ``` @@ -279,6 +279,7 @@ docker build --platform linux/amd64 --build-arg NEED_MIRROR=1 -f Dockerfile -t i git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules + pre-commit install ``` 3. 透過 Docker Compose 啟動依賴的服務(MinIO, Elasticsearch, Redis, and MySQL): diff --git a/README_zh.md b/README_zh.md index 03a416a2f..6535042ac 100644 --- a/README_zh.md +++ b/README_zh.md @@ -270,7 +270,7 @@ docker build --platform linux/amd64 --build-arg NEED_MIRROR=1 -f Dockerfile -t i 1. 安装 uv。如已经安装,可跳过本步骤: ```bash - pipx install uv + pipx install uv pre-commit export UV_INDEX=https://mirrors.aliyun.com/pypi/simple ``` @@ -280,6 +280,7 @@ docker build --platform linux/amd64 --build-arg NEED_MIRROR=1 -f Dockerfile -t i git clone https://github.com/infiniflow/ragflow.git cd ragflow/ uv sync --python 3.10 --all-extras # install RAGFlow dependent python modules + pre-commit install ``` 3. 通过 Docker Compose 启动依赖的服务(MinIO, Elasticsearch, Redis, and MySQL):