Skip to content

Commit

Permalink
dev: unify pre-commit for backend and frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed Oct 14, 2024
1 parent 36d8d46 commit 19d01f8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 48 deletions.
46 changes: 19 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,32 @@ repos:
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/pycqa/isort
rev: 5.13.2
- repo: local
hooks:
- id: isort
args: ["--profile", "black"]
- id: frontend-lint
name: Frontend Lint
entry: bash -c 'cd frontend && npm run lint'
language: system
files: ^frontend/
pass_filenames: false

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: backend-lint
name: Backend Lint
entry: bash -c 'cd backend && poetry run ruff check .'
language: system
files: ^backend/
pass_filenames: false

- repo: local
hooks:
- id: pytest-check
name: pytest-check
- id: backend-test
name: Backend Test
entry: bash -c 'cd backend && poetry run pytest'
language: system
files: ^backend/
pass_filenames: false
always_run: false
files: ^(backend/|tests/)
types: [python]

- id: coverage-check
name: coverage-check
- id: backend-coverage
name: Backend Coverage
entry: bash -c 'cd backend && poetry run coverage erase && poetry run coverage run -m pytest && poetry run coverage report -m && poetry run coverage xml'
language: system
files: ^backend/
pass_filenames: false
always_run: false
files: ^(backend/|tests/)
types: [python]
76 changes: 57 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,29 @@ PandaETL is an open-source, no-code ETL (Extract, Transform, Load) tool designed

### 📋 Prerequisites

- Node.js
- yarn
- Python (for backend)
- Poetry (for Python dependency management)
- Node.js and npm (or yarn)
- Python 3.x
- Conda
- Poetry (Python package manager)

### 🖥️ Frontend Setup
### 🖥️ Project Setup

1. Clone the repository:

```bash
git clone https://github.com/yourusername/panda-etl.git
cd panda-etl/frontend/
cd panda-etl
```

2. Install dependencies:
### Frontend Setup

1. Navigate to the frontend directory:

```bash
cd frontend
```

2. Install dependencies (including Husky):

```bash
yarn install
Expand All @@ -44,47 +52,67 @@ PandaETL is an open-source, no-code ETL (Extract, Transform, Load) tool designed
NEXT_PUBLIC_STORAGE_URL=http://localhost:3000/api/assets
```

or

copy the `.env.example` file to `.env`
or copy the `.env.example` file to `.env`

4. Run the development server:

```bash
npm run dev
# or
yarn dev
```

5. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

### 🛠️ Backend Setup
### Backend Setup

1. Navigate to the backend directory:

```bash
cd ../backend
cd backend
```

2. Create an environment file from the example:
2. Create and activate a Conda environment:

```bash
cp .env.example .env
conda create -n pandaetl python=3.x
conda activate pandaetl
```

3. Install dependencies:
3. Install Poetry within the Conda environment:

```bash
conda install poetry
```

4. Install dependencies using Poetry (including pre-commit):

```bash
poetry install
```

4. Apply database migrations:
5. Set up pre-commit hooks:

```bash
poetry run pre-commit install
```

6. Create an environment file from the example:

```bash
make migrate
cp .env.example .env
```

5. Start the backend server:
7. Apply database migrations:

```bash
make run
poetry run make migrate
```

8. Start the backend server:

```bash
poetry run make run
```

## 📚 Usage
Expand Down Expand Up @@ -125,3 +153,13 @@ We would like to thank all the contributors and the open-source community for th
## 📞 Contact

For any questions or feedback, please open an issue on GitHub.

## Development Setup

This project uses pre-commit hooks in the backend and Husky in the frontend to ensure code quality and consistency.

### Frontend (Husky)

Husky is set up in the frontend to run linting checks before each commit.

To manually run the frontend linting:
7 changes: 5 additions & 2 deletions frontend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
cd frontend && npx lint-staged
cd ../backend && poetry run ruff check .
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Run pre-commit hooks
pre-commit run --hook-stage pre-commit --files $(git diff --cached --name-only)

0 comments on commit 19d01f8

Please sign in to comment.