From eb2b9130a0357ed6023abac2470c6a13a8becd65 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Fri, 6 Feb 2026 19:24:05 +0800 Subject: [PATCH] chore: update workflows and documentation to replace pre-commit with prek Signed-off-by: Frost Ming --- .github/workflows/main.yml | 17 ++----- .github/workflows/on-release-main.yml | 10 ++--- AGENTS.md | 6 +-- CONTRIBUTING.md | 4 +- justfile | 8 ++-- pyproject.toml | 2 +- uv.lock | 65 ++++++++++----------------- 7 files changed, 42 insertions(+), 70 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 413f1840..7eed1032 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,18 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - uses: actions/cache@v4 - with: - path: ~/.cache/pre-commit - key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - - name: Set up the environment - uses: ./.github/actions/setup-python-env - - - name: Run checks - run: uv run just check + - uses: j178/prek-action@v1 tests-and-type-check: runs-on: ubuntu-latest @@ -36,7 +27,7 @@ jobs: shell: bash steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up the environment uses: ./.github/actions/setup-python-env @@ -55,7 +46,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up the environment uses: ./.github/actions/setup-python-env diff --git a/.github/workflows/on-release-main.yml b/.github/workflows/on-release-main.yml index 73545a5a..e79172ec 100644 --- a/.github/workflows/on-release-main.yml +++ b/.github/workflows/on-release-main.yml @@ -9,7 +9,7 @@ jobs: set-version: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Export tag id: vars @@ -24,7 +24,7 @@ jobs: if: ${{ github.event_name == 'release' }} - name: Upload updated pyproject.toml - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: pyproject-toml path: pyproject.toml @@ -34,13 +34,13 @@ jobs: needs: [set-version] steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up the environment uses: ./.github/actions/setup-python-env - name: Download updated pyproject.toml - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: pyproject-toml @@ -57,7 +57,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up the environment uses: ./.github/actions/setup-python-env diff --git a/AGENTS.md b/AGENTS.md index bf2f9e10..c50929ec 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,12 +4,12 @@ - **Test**: `uv run pytest --doctest-modules` or `just test` - **Test single**: `uv run pytest tests/test_specific.py::test_function` - **Test with coverage**: `uv run pytest --cov=src/bub` -- **Lint/Check**: `just check` (runs pre-commit, mypy, lock check) +- **Lint/Check**: `just check` (runs prek, mypy, lock check) - **Type check**: `uv run mypy` (targets `src/` only) - **Format**: `uv run ruff format .` and `uv run ruff check --fix .` - **Build**: `just build` (creates wheel with uvx pyproject-build) - **Docs**: `just docs` (serve) or `just docs-test` (build only) -- **Install dev**: `just install` (uv sync + pre-commit install) +- **Install dev**: `just install` (uv sync + prek install) - **Sync dependencies**: `uv sync` - **Add dependency**: `uv add package-name` or `uv add --dev package-name` - **Update lock**: `uv lock` @@ -135,7 +135,7 @@ uv sync - **Ignore `.pytest_cache/`**: Test cache directories ## Development Workflow -1. **Setup**: `just install` or `uv sync && pre-commit install` +1. **Setup**: `just install` or `uv sync && prek install` 2. **Add feature**: Create feature branch 3. **Code**: Follow style guidelines, add tests 4. **Check**: Run `just check` before committing diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0286f5b..8a115a1b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,10 +68,10 @@ Then, install and activate the environment with: uv sync ``` -4. Install pre-commit to run linters/formatters at commit time: +1. Install prek to run linters/formatters at commit time: ```bash -uv run pre-commit install +uv run prek install ``` 5. Create a branch for local development: diff --git a/justfile b/justfile index 44782b53..2f79c604 100644 --- a/justfile +++ b/justfile @@ -7,15 +7,15 @@ install: #!/usr/bin/env bash echo "🚀 Creating virtual environment using uv" uv sync - uv run pre-commit install + uv run prek install # Run code quality tools check: #!/usr/bin/env bash echo "🚀 Checking lock file consistency with 'pyproject.toml'" uv lock --locked - echo "🚀 Linting code: Running pre-commit" - uv run pre-commit run -a + echo "🚀 Linting code: Running prek" + uv run prek run -a echo "🚀 Static type checking: Running mypy" uv run mypy src @@ -23,7 +23,7 @@ check: vulture: #!/usr/bin/env bash echo "🚀 Checking for unused code with vulture" - uv run pre-commit run vulture --hook-stage manual --all-files + uv run prek run vulture --hook-stage manual --all-files # Test the code with pytest test: diff --git a/pyproject.toml b/pyproject.toml index e4c7545d..70a421e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,6 @@ bub = "bub.cli:app" [dependency-groups] dev = [ "pytest>=7.2.0", - "pre-commit>=2.20.0", "tox-uv>=1.11.3", "mypy>=0.991", "ruff>=0.11.5", @@ -43,6 +42,7 @@ dev = [ "mkdocs-terminal>=4.7.0", "mkdocstrings[python]>=0.26.1", "rust-just>=1.42.0", + "prek>=0.3.1", ] [build-system] diff --git a/uv.lock b/uv.lock index 861f251e..f98e0271 100644 --- a/uv.lock +++ b/uv.lock @@ -61,7 +61,7 @@ dev = [ { name = "mkdocs-terminal" }, { name = "mkdocstrings", extra = ["python"] }, { name = "mypy" }, - { name = "pre-commit" }, + { name = "prek" }, { name = "pytest" }, { name = "ruff" }, { name = "rust-just" }, @@ -84,7 +84,7 @@ dev = [ { name = "mkdocs-terminal", specifier = ">=4.7.0" }, { name = "mkdocstrings", extras = ["python"], specifier = ">=0.26.1" }, { name = "mypy", specifier = ">=0.991" }, - { name = "pre-commit", specifier = ">=2.20.0" }, + { name = "prek", specifier = ">=0.3.1" }, { name = "pytest", specifier = ">=7.2.0" }, { name = "ruff", specifier = ">=0.11.5" }, { name = "rust-just", specifier = ">=1.42.0" }, @@ -109,15 +109,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/4f/52/34c6cf5bb9285074dc3531c437b3919e825d976fde097a7a73f79e726d03/certifi-2025.7.14-py3-none-any.whl", hash = "sha256:6b31f564a415d79ee77df69d757bb49a5bb53bd9f756cbbe24394ffd6fc1f4b2", size = 162722, upload-time = "2025-07-14T03:29:26.863Z" }, ] -[[package]] -name = "cfgv" -version = "3.4.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/11/74/539e56497d9bd1d484fd863dd69cbbfa653cd2aa27abfe35653494d85e94/cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560", size = 7114, upload-time = "2023-08-12T20:38:17.776Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9", size = 7249, upload-time = "2023-08-12T20:38:16.269Z" }, -] - [[package]] name = "chardet" version = "5.2.0" @@ -236,15 +227,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, ] -[[package]] -name = "identify" -version = "2.6.12" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a2/88/d193a27416618628a5eea64e3223acd800b40749a96ffb322a9b55a49ed1/identify-2.6.12.tar.gz", hash = "sha256:d8de45749f1efb108badef65ee8386f0f7bb19a7f26185f74de6367bffbaf0e6", size = 99254, upload-time = "2025-05-23T20:37:53.3Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/7a/cd/18f8da995b658420625f7ef13f037be53ae04ec5ad33f9b718240dcfd48c/identify-2.6.12-py2.py3-none-any.whl", hash = "sha256:ad9672d5a72e0d2ff7c5c8809b62dfa60458626352fb0eb7b55e69bdc45334a2", size = 99145, upload-time = "2025-05-23T20:37:51.495Z" }, -] - [[package]] name = "idna" version = "3.10" @@ -539,15 +521,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, ] -[[package]] -name = "nodeenv" -version = "1.9.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437, upload-time = "2024-06-04T18:44:11.171Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, -] - [[package]] name = "openai" version = "2.16.0" @@ -616,19 +589,27 @@ wheels = [ ] [[package]] -name = "pre-commit" -version = "4.2.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "cfgv" }, - { name = "identify" }, - { name = "nodeenv" }, - { name = "pyyaml" }, - { name = "virtualenv" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/08/39/679ca9b26c7bb2999ff122d50faa301e49af82ca9c066ec061cfbc0c6784/pre_commit-4.2.0.tar.gz", hash = "sha256:601283b9757afd87d40c4c4a9b2b5de9637a8ea02eaff7adc2d0fb4e04841146", size = 193424, upload-time = "2025-03-18T21:35:20.987Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/88/74/a88bf1b1efeae488a0c0b7bdf71429c313722d1fc0f377537fbe554e6180/pre_commit-4.2.0-py2.py3-none-any.whl", hash = "sha256:a009ca7205f1eb497d10b845e52c838a98b6cdd2102a6c8e4540e94ee75c58bd", size = 220707, upload-time = "2025-03-18T21:35:19.343Z" }, +name = "prek" +version = "0.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/76/62/4b91c8a343e21fcefabc569a91d08cf8756c554332521af78294acef7c27/prek-0.3.1.tar.gz", hash = "sha256:45abc4ffd3cb2d39c478f47e92e88f050e5a4b7a20915d78e54b1a3d3619ebe4", size = 323141, upload-time = "2026-01-31T13:25:58.128Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ab/c1/e0e545048e4190245fb4ae375d67684108518f3c69b67b81d62e1cd855c6/prek-0.3.1-py3-none-linux_armv6l.whl", hash = "sha256:1f77d0845cc63cad9c447f7f7d554c1ad188d07dbe02741823d20d58c7312eaf", size = 4285460, upload-time = "2026-01-31T13:25:42.066Z" }, + { url = "https://files.pythonhosted.org/packages/10/fe/7636d10e2dafdf2a4a927c989f32ce3f08e99d62ebad7563f0272e74b7f4/prek-0.3.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e21142300d139e8c7f3970dd8aa66391cb43cd17c0c4ee65ff1af48856bb6a4b", size = 4287085, upload-time = "2026-01-31T13:25:40.193Z" }, + { url = "https://files.pythonhosted.org/packages/a3/7f/62ed57340071e04c02057d64276ec3986baca3ad4759523e2f433dc9be55/prek-0.3.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:c09391de7d1994f9402c46cb31671800ea309b1668d839614965706206da3655", size = 3936188, upload-time = "2026-01-31T13:25:47.314Z" }, + { url = "https://files.pythonhosted.org/packages/6b/17/cb24f462c255f76d130ca110f4fcec09b041c3c770e43960cc3fc9dcc9ce/prek-0.3.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:a0b0a012ef6ef28dee019cf81a95c5759b2c03287c32c1f2adcb5f5fb097138e", size = 4275214, upload-time = "2026-01-31T13:25:38.053Z" }, + { url = "https://files.pythonhosted.org/packages/f2/85/db155b59d73cf972c8467e4d95def635f9976d5fcbcc790a4bbe9d2e049a/prek-0.3.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f4a0e40785d39b8feae0d7ecf5534789811a2614114ab47f4e344a2ebd75ac10", size = 4197982, upload-time = "2026-01-31T13:25:50.034Z" }, + { url = "https://files.pythonhosted.org/packages/06/cf/d35c32436692928a9ca53eed3334e30148a60f0faa33c42e8d11b6028fa6/prek-0.3.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ac5c2f5e377e3cc5a5ea191deb8255a5823fbaa01b424417fe18ff12c7c800f3", size = 4458572, upload-time = "2026-01-31T13:25:51.46Z" }, + { url = "https://files.pythonhosted.org/packages/b4/c0/eb36fecb21fe30baa72fb87ccf3a791c32932786c287f95f8972402e9245/prek-0.3.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fe70e97f4dfca57ce142caecd77b90a435abd1c855f9e96041078415d80e89a", size = 4999230, upload-time = "2026-01-31T13:25:44.055Z" }, + { url = "https://files.pythonhosted.org/packages/e4/f3/ad1a25ea16320e6acd1fedd6bd96a0d22526f5132d9b5adc045996ccca4c/prek-0.3.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b28e921d893771bdd7533cd94d46a10e0cf2855c5e6bf6809b598b5e45baa73", size = 4510376, upload-time = "2026-01-31T13:25:48.563Z" }, + { url = "https://files.pythonhosted.org/packages/39/b7/91afdd24be808ccf3b9119f4cf2bd6d02e30683143a62a08f432a3435861/prek-0.3.1-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:555610a53c4541976f4fe8602177ecd7a86a931dcb90a89e5826cfc4a6c8f2cb", size = 4273229, upload-time = "2026-01-31T13:25:56.362Z" }, + { url = "https://files.pythonhosted.org/packages/5a/bb/636c77c5c9fc5eadcc2af975a95b48eeeff2dc833021e222b0e9479b9b47/prek-0.3.1-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:663a15a31b705db5d01a1c9eb28c6ea417628e6cb68de2dc7b3016ca2f959a99", size = 4301166, upload-time = "2026-01-31T13:25:36.281Z" }, + { url = "https://files.pythonhosted.org/packages/4e/cf/c928a36173e71b21b252943404a5b3d1ddc1f08c9e0f1d7282a2c62c7325/prek-0.3.1-py3-none-musllinux_1_1_armv7l.whl", hash = "sha256:1d03fb5fa37177dc37ccbe474252473adcbde63287a63e9fa3d5745470f95bd8", size = 4188473, upload-time = "2026-01-31T13:25:53.341Z" }, + { url = "https://files.pythonhosted.org/packages/98/4c/af8f6a40cb094e88225514b89e8ae05ac69fc479d6b500e4b984f9ef8ae3/prek-0.3.1-py3-none-musllinux_1_1_i686.whl", hash = "sha256:3e20a5b704c06944dca9555a39f1de3622edc8ed2becaf8b3564925d1b7c1c0d", size = 4342239, upload-time = "2026-01-31T13:25:55.179Z" }, + { url = "https://files.pythonhosted.org/packages/b7/ba/6b0f725c0cf96182ab9622b4d122a01f04de9b2b6e4a6516874390218510/prek-0.3.1-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:6889acf0c9b0dd7b9cd3510ec36af10a739826d2b9de1e2d021ae6a9f130959a", size = 4618674, upload-time = "2026-01-31T13:25:59.175Z" }, + { url = "https://files.pythonhosted.org/packages/d8/49/caa320893640c9e72ed3d3e2bab7959faba54cefeea09be18c33d5f75baf/prek-0.3.1-py3-none-win32.whl", hash = "sha256:cc62a4bff79ed835d448098f0667c1a91915cec9cfac6c6246b675f0da46eded", size = 3928699, upload-time = "2026-01-31T13:25:33.168Z" }, + { url = "https://files.pythonhosted.org/packages/59/19/15907abe245ae9a120abcebb0c50c6d456ba719eb640f7c57e4f5b2f00e3/prek-0.3.1-py3-none-win_amd64.whl", hash = "sha256:3515140def20bab85e53585b0beb90d894ff2915d2fdb4451b6a4588e16516d8", size = 4296106, upload-time = "2026-01-31T13:25:45.606Z" }, + { url = "https://files.pythonhosted.org/packages/a6/5e/9b994b5de36d6aa5caaf09a018d8fe4820db46e4da577c2fd7a1e176b56c/prek-0.3.1-py3-none-win_arm64.whl", hash = "sha256:cfa58365eb36753cff684dc3b00196c1163bb135fe72c6a1c6ebb1a179f5dbdf", size = 4021714, upload-time = "2026-01-31T13:25:34.993Z" }, ] [[package]]