Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions polymath_code_standard/checkers/go/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
13 changes: 13 additions & 0 deletions tests/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading