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):
This commit is contained in:
Wanderson Pinto dos Santos 2025-04-24 00:25:33 -03:00 committed by GitHub
parent 19931cd9ed
commit 4e8fd73a20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 33 additions and 7 deletions

19
.pre-commit-config.yaml Normal file
View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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を起動する:

View File

@ -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)를 시작합니다:

View File

@ -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:

View File

@ -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

View File

@ -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