Skip to content

Commit

Permalink
feat(common.mk): group linters in CI
Browse files Browse the repository at this point in the history
This adds ::group:: tags around linters if the CI environment variable
is set, which allows the linters to be collapsed in CI.
  • Loading branch information
lengau committed Dec 9, 2024
1 parent 0ffe5a7 commit a9abce3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,42 +84,90 @@ format-codespell: ##- Fix spelling issues with codespell

.PHONY: lint-ruff
lint-ruff: install-ruff ##- Lint with ruff
ifneq ($(CI),)
@echo ::group::$@
endif
ruff check $(SOURCES)
ruff format --diff $(SOURCES)
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-codespell
lint-codespell: ##- Check spelling with codespell
ifneq ($(CI),)
@echo ::group::$@
endif
uv run codespell --toml pyproject.toml $(SOURCES)
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-mypy
lint-mypy: ##- Check types with mypy
ifneq ($(CI),)
@echo ::group::$@
endif
uv run mypy --show-traceback --show-error-codes $(PROJECT)
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-pyright
lint-pyright: ##- Check types with pyright
ifneq ($(CI),)
@echo ::group::$@
endif
ifneq ($(shell which pyright),) # Prefer the system pyright
pyright --pythonpath .venv/bin/python
else
# Fix for a bug in npm
[ -d "/home/ubuntu/.npm/_cacache" ] && chown -R 1000:1000 "/home/ubuntu/.npm" || true
uv run pyright --pythonpath .venv/bin/python
endif
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-shellcheck
lint-shellcheck: ##- Lint shell scripts
ifneq ($(CI),)
@echo ::group::$@
endif
git ls-files | file --mime-type -Nnf- | grep shellscript | cut -f1 -d: | xargs -r shellcheck
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-yaml
lint-yaml: ##- Lint YAML files with yamllint
ifneq ($(CI),)
@echo ::group::$@
endif
uv run --extra lint yamllint .
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-docs
lint-docs: ##- Lint the documentation
ifneq ($(CI),)
@echo ::group::$@
endif
uv run --extra docs sphinx-lint --max-line-length 88 --enable all $(DOCS)
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: lint-twine
lint-twine: dist/* ##- Lint Python packages with twine
ifneq ($(CI),)
@echo ::group::$@
endif
uv tool run twine check dist/*
ifneq ($(CI),)
@echo ::endgroup::
endif

.PHONY: test
test: ## Run all tests
Expand Down

0 comments on commit a9abce3

Please sign in to comment.