diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 309e07d..59eda22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,7 @@ jobs: uv run coverage erase uv run coverage run -m pytest uv run coverage report + uv run coverage xml - name: Upload coverage data if: always() uses: actions/upload-artifact@v7 @@ -66,6 +67,11 @@ jobs: include-hidden-files: true if-no-files-found: error retention-days: 7 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v6 + with: + files: coverage.xml + fail_ci_if_error: false build: name: Build & audit package diff --git a/.gitignore b/.gitignore index f61d98c..2148e53 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ build/ .pytest_cache/ .tox/ .coverage +coverage.xml htmlcov/ .mypy_cache/ .ruff_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..066661e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +# Mirrors the lint job in .github/workflows/ci.yml (ruff check, ruff format, +# mypy) so contributors get the same checks locally before pushing. +repos: + - repo: local + hooks: + - id: ruff-check + name: ruff check + entry: uv run ruff check . + language: system + types: [python] + pass_filenames: false + - id: ruff-format + name: ruff format + entry: uv run ruff format --check . + language: system + types: [python] + pass_filenames: false + - id: mypy + name: mypy type check + entry: uv run mypy gcode + language: system + types: [python] + pass_filenames: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 773c79d..c6a8875 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,6 +46,21 @@ Look for issues labeled [`good first issue`](https://github.com/shauryagangrade/ - Write clean, readable code with descriptive variable names. - Ensure all tests pass before opening a PR. +## Pre-commit Hooks + +Install the hooks once so lint, formatting, and type checks run before every +commit (they mirror the CI lint job): + +```bash +uv run pre-commit install +``` + +Run them on the whole tree any time with: + +```bash +uv run pre-commit run --all-files +``` + --- ## PR Guidelines diff --git a/README.md b/README.md index 907536a..6efe1f4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # GCode ![Build](https://github.com/shauryagangrade/GCode/actions/workflows/ci.yml/badge.svg) +[![codecov](https://codecov.io/gh/shauryagangrade/GCode/branch/main/graph/badge.svg)](https://codecov.io/gh/shauryagangrade/GCode) [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) [![PyPI version](https://img.shields.io/pypi/v/gcode.svg)](https://pypi.org/project/gcode/) [![Stars](https://img.shields.io/github/stars/shauryagangrade/GCode?style=social)](https://github.com/shauryagangrade/GCode) diff --git a/pyproject.toml b/pyproject.toml index 05e3ebc..53edb71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ dev = [ "coverage>=7", "mypy>=1.13", "pip-audit>=2.7", + "pre-commit>=4.0", "pytest>=8", "ruff>=0.9", ]