From 3acffb7988c942fd1cd152405fdb552c1409609f Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Thu, 10 Sep 2026 21:17:29 -0700 Subject: [PATCH 1/2] fix: go checker running in parallel Signed-off-by: Emerson Knapp --- .pre-commit-hooks.yaml | 2 ++ polymath_code_standard/checkers/go/golangci.yml | 2 ++ tests/test_go.py | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 9ef299b..91ff7b4 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -43,6 +43,8 @@ Requires Go 1.23 or newer on PATH. entry: polymath_code_standard go types_or: [go, go-mod, go-sum] + # golangci-lint holds a file lock per run, so all files go to one process. + require_serial: true - <<: *python-hook id: polymath-javascript diff --git a/polymath_code_standard/checkers/go/golangci.yml b/polymath_code_standard/checkers/go/golangci.yml index 92d2c5b..d3707c6 100644 --- a/polymath_code_standard/checkers/go/golangci.yml +++ b/polymath_code_standard/checkers/go/golangci.yml @@ -3,6 +3,8 @@ version: '2' run: # Report paths relative to the module root the hook runs from. relative-path-mode: wd + # Tolerate another golangci-lint instance, such as an editor's. + allow-parallel-runners: true formatters: enable: - gofumpt diff --git a/tests/test_go.py b/tests/test_go.py index 50f09bf..b303e9c 100644 --- a/tests/test_go.py +++ b/tests/test_go.py @@ -15,6 +15,7 @@ from pathlib import Path import pytest +import yaml from polymath_code_standard import runner from polymath_code_standard.checker import Result @@ -92,6 +93,18 @@ def test_package_dirs_collapses_to_distinct_directories(): assert go_checker.package_dirs(relative) == ['.', './pkg', './pkg/sub'] +def test_hook_runs_as_a_single_process(): + """pre-commit passes every staged file to one process, since golangci-lint locks per run.""" + hooks = yaml.safe_load((_PROJECT_ROOT / '.pre-commit-hooks.yaml').read_text()) + go_hook = next(h for h in hooks if h['id'] == 'polymath-go') + assert go_hook['require_serial'] is True + + +def test_bundled_config_allows_parallel_runners(): + config = yaml.safe_load((go_checker.CONFIG_DIR / 'golangci.yml').read_text()) + assert config['run']['allow-parallel-runners'] is True + + def test_file_without_go_mod_fails(tmp_path, monkeypatch): monkeypatch.setattr(go_checker.shutil, 'which', lambda _: '/usr/bin/go') stray = tmp_path / 'stray.go' From a420a01153baaffa6e2eefd765d6a74ca0d4c07d Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Thu, 10 Sep 2026 21:18:42 -0700 Subject: [PATCH 2/2] patch bump Signed-off-by: Emerson Knapp --- CHANGELOG.md | 7 +++++++ README.md | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd37844..0a5dbfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project are documented in this file. Releases follow semantic versioning as described in [DEVELOPING.md](./DEVELOPING.md). +## 2.6.1 + +### Fixed + +- `polymath-go` no longer fails with "parallel golangci-lint is running" on commits with many Go files. + The hook runs as a single process, and golangci-lint tolerates other instances such as an editor's. + ## 2.6.0 New hooks for Go and the web stack. diff --git a/README.md b/README.md index 7ef8a99..217fea6 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Use only the hooks that apply to your project. --- repos: - repo: https://github.com/polymathrobotics/polymath_code_standard - rev: v2.6.0 + rev: v2.6.1 hooks: # File hygiene for all staged files - id: polymath-general diff --git a/pyproject.toml b/pyproject.toml index 4cd7674..b40fcd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "polymath-code-standard" -version = "2.6.0" +version = "2.6.1" description = "Polymath Code Standard pre-commit hooks" requires-python = ">=3.10" dependencies = [ diff --git a/uv.lock b/uv.lock index cf0fb7b..00d5b18 100644 --- a/uv.lock +++ b/uv.lock @@ -829,7 +829,7 @@ wheels = [ [[package]] name = "polymath-code-standard" -version = "2.6.0" +version = "2.6.1" source = { editable = "." } dependencies = [ { name = "ansible-lint" },