From 2002c28112107f85fb2b98a82189aa98abb41e4d Mon Sep 17 00:00:00 2001 From: Anfimov Dima Date: Mon, 5 May 2025 02:22:45 +0300 Subject: [PATCH 1/2] chore: better formatted Makefile --- Makefile | 60 +++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index a7ba53b..4c6aed0 100644 --- a/Makefile +++ b/Makefile @@ -1,44 +1,42 @@ args := $(wordlist 2, 100, $(MAKECMDGOALS)) -APPLICATION_NAME = ya_tracker_client +.DEFAULT: + @echo "No such command (or you pass two or many targets to ). List of possible commands: make help" -HELP_FUN = \ - %help; while(<>){push@{$$help{$$2//'options'}},[$$1,$$3] \ - if/^([\w-_]+)\s*:.*\#\#(?:@(\w+))?\s(.*)$$/}; \ - print"$$_:\n", map" $$_->[0]".(" "x(20-length($$_->[0])))."$$_->[1]\n",\ - @{$$help{$$_}},"\n" for keys %help; \ +.DEFAULT_GOAL := help -CODE = ya_tracker_client -TEST = uv run python3 -m pytest --verbosity=2 --showlocals --log-level=DEBUG +##@ Local development -ifndef args -MESSAGE = "No such command (or you pass two or many targets to ). List of possible commands: make help" -else -MESSAGE = "Done" -endif +.PHONY: help +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m \033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m %s\033[0m\n\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.PHONY: install +install: ## Install project requirements + @uv sync --all-extras -help: ##@Help Show this help - @echo -e "Usage: make [target] ...\n" - @perl -e '$(HELP_FUN)' $(MAKEFILE_LIST) +##@ Testing and formatting -install: ##@Setup Install project requirements - uv sync --all-extras +.PHONY: test +test: ## Test application with pytest + @pytest --verbosity=2 --showlocals --log-level=DEBUG -test: ##@Testing Test application with pytest - $(TEST) +.PHONY: test-cov +test-cov: ## Test application with pytest and create coverage report + @pytest --verbosity=2 --showlocals --log-level=DEBUG --cov=ya_tracker_client --cov-report html --cov-fail-under=85 --cov-config pyproject.toml -test-cov: ##@Testing Test application with pytest and create coverage report - $(TEST) --cov=$(APPLICATION_NAME) --cov-report html --cov-fail-under=85 --cov-config pyproject.toml +.PHONY: lint +lint: ## Check code with ruff + @ruff check ya_tracker_client examples tests -lint: ##@Code Check code with ruff - uv run python3 -m ruff check $(CODE) examples tests +.PHONY: format +format: ## Reformat code with ruff + @ruff format ya_tracker_client examples tests -format: ##@Code Reformat code with ruff - uv run python3 -m ruff check $(CODE) examples tests --fix +.PHONY: precommit +precommit: ## Check code with pre-commit hooks + @pre-commit run --all-files -precommit: # Code Check code with pre-commit hooks - pre-commit run --all-files - -clean: ##@Code Clean directory from garbage files - rm -fr *.egg-info dist +.PHONY: clean +clean: ## Clean directory from garbage files + @rm -fr *.egg-info dist From 0fedc57ddff4b3bf360fb2ca559e65763b237858 Mon Sep 17 00:00:00 2001 From: Anfimov Dima Date: Mon, 5 May 2025 02:30:49 +0300 Subject: [PATCH 2/2] ci: use uv before command in tests --- .github/workflows/code-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index a6a0f5e..846760d 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -15,7 +15,7 @@ jobs: if: steps.setup-uv.outputs.cache-hit != 'true' run: uv sync --all-extras - name: Run linters - run: make lint + run: uv run ruff check ya_tracker_client examples tests test: runs-on: ubuntu-latest name: Run tests @@ -43,4 +43,4 @@ jobs: run: uv pip install --prerelease=disallow "pydantic>=2.0.0,<3.0.0" - run: mkdir coverage - name: Test - run: make test + run: uv run pytest --verbosity=2 --showlocals --log-level=DEBUG