move pre-commit into scripts

Signed-off-by: leohoare <leo@insight.co>
This commit is contained in:
leohoare 2025-06-24 07:24:38 +08:00
parent a17a10cccf
commit fad89de749
4 changed files with 19 additions and 27 deletions

View File

@ -66,7 +66,7 @@ jobs:
run: uv sync --extra dev run: uv sync --extra dev
- name: Run pre-commit - name: Run pre-commit
run: uv run pre-commit run --all-files run: uv run precommit
sast: sast:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -16,10 +16,6 @@ We use [uv](https://github.com/astral-sh/uv) for fast Python package management
To install uv, follow the [installation guide](https://docs.astral.sh/uv/getting-started/installation/). To install uv, follow the [installation guide](https://docs.astral.sh/uv/getting-started/installation/).
You will also need to set up the `pre-commit` hooks.
Run `pre-commit install` in the root directory of the repository.
If you don't have `pre-commit` installed, you can install it with `uv run pip install pre-commit`.
### Setup Development Environment ### Setup Development Environment
1. **Clone the repository:** 1. **Clone the repository:**
@ -35,40 +31,30 @@ If you don't have `pre-commit` installed, you can install it with `uv run pip in
### Testing ### Testing
Run tests with `uv run pytest tests`. Run tests:
```bash
We use `pytest` for our unit testing, making use of `parametrized` to inject cases at scale. uv run test
```
### Coverage ### Coverage
Run coverage tests with: Run tests with a coverage report:
```bash ```bash
uv run coverage run -m pytest tests/ uv run cov
# Generate coverage report
``` ```
### End-to-End Tests ### End-to-End Tests
Run e2e tests with behave: Run e2e tests with behave:
```bash ```bash
# Update git submodules and run behave tests uv run e2e
git submodule update --init --recursive
cp spec/specification/assets/gherkin/* tests/features/
uv run behave tests/features/
rm tests/features/*.feature
``` ```
### Code Quality ### Pre-commit
**Linting and Formatting:** Run pre-commit hooks
```bash ```bash
uv run ruff check . # Lint code uv run precommit
uv run ruff format . # Format code
```
**Type Checking:**
```bash
uv run mypy openfeature/
``` ```
@ -105,7 +91,7 @@ git remote add fork https://github.com/YOUR_GITHUB_USERNAME/python-sdk.git
Ensure your development environment is all set up by building and testing Ensure your development environment is all set up by building and testing
```bash ```bash
uv run pytest tests/ uv run test
``` ```
To start working on a new feature or bugfix, create a new branch and start working on it. To start working on a new feature or bugfix, create a new branch and start working on it.

View File

@ -125,3 +125,4 @@ test-cov = "scripts.scripts:test_cov"
cov-report = "scripts.scripts:cov_report" cov-report = "scripts.scripts:cov_report"
cov = "scripts.scripts:cov" cov = "scripts.scripts:cov"
e2e = "scripts.scripts:e2e" e2e = "scripts.scripts:e2e"
precommit = "scripts.scripts:precommit"

View File

@ -31,3 +31,8 @@ def e2e():
) )
subprocess.run("behave tests/features/", shell=True, check=True) subprocess.run("behave tests/features/", shell=True, check=True)
subprocess.run("rm tests/features/*.feature", shell=True, check=True) subprocess.run("rm tests/features/*.feature", shell=True, check=True)
def precommit():
"""Run pre-commit hooks."""
subprocess.run("uv run pre-commit run --all-files", shell=True, check=True)