-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (88 loc) · 2.12 KB
/
Makefile
File metadata and controls
117 lines (88 loc) · 2.12 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
SHELL:=bash
PYTHON_MODULE=lizmap
QGIS_VERSION ?= 3.40
-include .localconfig.mk
#
# Configure
#
# Check if uv is available
$(eval UV_PATH=$(shell which uv))
ifdef UV_PATH
ifdef VIRTUAL_ENV
# Always prefer active environment
ACTIVE_VENV=--active
endif
UV_RUN=uv run $(ACTIVE_VENV)
endif
REQUIREMENTS_GROUPS= \
dev \
tests \
lint \
packaging \
$(NULL)
.PHONY: update-requirements
REQUIREMENTS=$(patsubst %, requirements/%.txt, $(REQUIREMENTS_GROUPS))
# Update only packaging dependencies
# Waiting for https://github.com/astral-sh/uv/issues/13705
update-packaging-dependencies::
uv lock -P qgis-plugin-package-ci -P qgis-plugin-transifex-ci
update-packaging-dependencies:: update-requirements
update-requirements: $(REQUIREMENTS)
# Require uv (https://docs.astral.sh/uv/) for extracting
# infos from project's dependency-groups
requirements/%.txt: uv.lock
@echo "Updating requirements for '$*'"; \
uv export --format requirements.txt \
--no-annotate \
--no-editable \
--no-hashes \
--only-group $* \
-q -o requirements/$*.txt;
#
# Static analysis
#
LINT_TARGETS=$(PYTHON_MODULE) tests $(EXTRA_LINT_TARGETS)
lint:
@ $(UV_RUN) ruff check --output-format=concise $(LINT_TARGETS)
lint-fix:
@ $(UV_RUN) ruff check --fix $(LINT_TARGETS)
format:
@ $(UV_RUN) ruff format $(LINT_TARGETS)
typecheck:
$(UV_RUN) mypy $(PYTHON_MODULE)
scan:
@ $(UV_RUN) bandit -r $(PYTHON_MODULE) $(SCAN_OPTS)
check-uv-install:
@which uv > /dev/null || { \
echo "You must install uv (https://docs.astral.sh/uv/)"; \
exit 1; \
}
#
# Tests
#
test:
$(UV_RUN) pytest -v tests/
#
# Test using docker image
#
QGIS_IMAGE_REPOSITORY ?= qgis/qgis
QGIS_IMAGE_TAG ?= $(QGIS_IMAGE_REPOSITORY):$(QGIS_VERSION)
export QGIS_VERSION
export QGIS_IMAGE_TAG
export UID=$(shell id -u)
export GID=$(shell id -g)
docker-test:
cd .docker && docker compose up \
--quiet-pull \
--abort-on-container-exit \
--exit-code-from qgis
cd .docker && docker compose down -v
#
# Code managment
#
# Display a summary of codes annotations
show-annotation-%:
@grep -nR --color=auto --include=*.py '# $*' lizmap/ || true
# Output variable
echo-variable-%:
@echo "$($*)"