From 8b67ce1178319a4d4ccc09d90ebe157f9ffa6364 Mon Sep 17 00:00:00 2001 From: "Aryan Singh K." <70511529+aryansk@users.noreply.github.com> Date: Fri, 14 Aug 2026 23:27:12 +0530 Subject: [PATCH 1/2] ci: upload coverage to Codecov and add the badge The test job already runs coverage and uploads .coverage artifacts, but no one aggregates or publishes the numbers. Emit coverage.xml in the test job and upload it with codecov/codecov-action (fail_ci_if_error: false so CI stays green until the Codecov token or app is configured), gitignore the generated file, and add the Codecov badge to the README next to the build badge. Fixes #64. --- .github/workflows/ci.yml | 6 ++++++ .gitignore | 1 + README.md | 1 + 3 files changed, 8 insertions(+) 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/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) From b6766d5f88803c5c49b61229da43633ee5983a23 Mon Sep 17 00:00:00 2001 From: "Aryan Singh K." <70511529+aryansk@users.noreply.github.com> Date: Fri, 14 Aug 2026 23:30:36 +0530 Subject: [PATCH 2/2] chore: add pre-commit config mirroring the CI lint job CI enforces ruff check/format and mypy, but there was no local hook, so contributors only learned about violations after pushing. Add a .pre-commit-config.yaml with local hooks that run the exact CI commands (uv run ruff check ., uv run ruff format --check ., uv run mypy gcode), add pre-commit to the dev extras, and document the one-line install in CONTRIBUTING. Fixes #58. --- .pre-commit-config.yaml | 23 +++++++++++++++++++++++ CONTRIBUTING.md | 15 +++++++++++++++ pyproject.toml | 1 + 3 files changed, 39 insertions(+) create mode 100644 .pre-commit-config.yaml 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/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", ]