-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (41 loc) · 1.8 KB
/
Makefile
File metadata and controls
53 lines (41 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
ifneq ($(OS),Windows_NT)
SHELL := bash
endif
.PHONY: help setup format lint test coverage
.DEFAULT_GOAL := help
PYTEST_ARGS ?= --numprocesses=auto
define exec
@uv run --no-sync python -c "print('\033[1;36m$(1)\033[0m')"
@$(1)
endef
help:
@uv run --no-sync python -c "import re; lines=open('Makefile').read().splitlines(); print('\033[1;32mAvailable targets:\033[0m'); [print(f' \033[1;36m{m.group(1):<20s}\033[0m {m.group(2)}') for l in lines if (m:=re.match(r'^([a-zA-Z_-]+):.*?# (.+)$$',l))]"
setup: # Setup the development environment
$(call exec,uv sync)
lint: # Lint code
$(call exec,uv run ruff format --check)
$(call exec,uv run ruff check)
$(call exec,uv run ty check --no-progress)
$(call exec,uv run taplo fmt --check $(shell git ls-files "*.toml"))
$(call exec,uv run mdformat --check $(shell git ls-files "*.md"))
$(call exec,uv run yamlfix --check $(shell git ls-files "*.yml" "*.yaml"))
$(call exec,uv run typos)
format: # Format code
$(call exec,uv run ruff format)
$(call exec,uv run ruff check --fix)
$(call exec,uv run taplo fmt $(shell git ls-files "*.toml"))
$(call exec,uv run mdformat $(shell git ls-files "*.md"))
$(call exec,uv run yamlfix $(shell git ls-files "*.yml" "*.yaml"))
check_translate: update_translate
$(call exec,git diff --exit-code labelme/translate)
@if grep -r 'type="unfinished"' labelme/translate/*.ts; then \
echo "$(RED)Error: unfinished translations found$(NC)"; \
exit 1; \
fi
check: lint check_translate # Run checks
test: # Run tests
$(call exec,QT_QPA_PLATFORM=offscreen uv run pytest -v tests/ $(PYTEST_ARGS))
update_translate:
$(call exec,uv run --no-sync tools/update_translate.py)
coverage: # Run tests with coverage
$(call exec,QT_QPA_PLATFORM=offscreen uv run pytest -v tests/ --numprocesses=auto --cov=labelme --cov-report=term-missing)