|
1 | 1 | # SPDX-FileCopyrightText: 2024 Deutsche Telekom AG |
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: CC0-1.0 |
4 | | -.PHONY: install test clean |
| 4 | +# Requires uv (https://docs.astral.sh/uv/). First-time: run 'make lock' then 'make install'. |
| 5 | +.PHONY: install test clean build lock lint documentation reuse-lint |
5 | 6 | SRC_DIR = ./wurzel |
6 | | -TEST_DIR= ./tests |
| 7 | +TEST_DIR = ./tests |
7 | 8 | VENV = .venv |
8 | | -SYSTEM_PYTHON?= python3.12 |
9 | 9 | SHELL := bash |
10 | 10 |
|
| 11 | +$(VENV)/.venv_created: |
| 12 | + @uv venv $(VENV) |
| 13 | + @touch $(VENV)/.venv_created |
11 | 14 |
|
12 | | -ifeq ($(OS),Windows_NT) |
13 | | - PY ?= $(VENV)/Scripts/python.exe |
14 | | - PIP ?= $(VENV)/Scripts/pip.exe |
15 | | - UV ?= $(VENV)/Scripts/uv.exe |
16 | | -else |
17 | | - PY ?= $(VENV)/bin/python |
18 | | - PIP ?= $(VENV)/bin/pip |
19 | | - UV ?= $(VENV)/bin/uv |
20 | | -endif |
21 | | - |
| 15 | +install: $(VENV)/.venv_created |
| 16 | + uv sync --all-extras |
| 17 | + uv run pre-commit install |
22 | 18 |
|
23 | 19 | build: install |
24 | | - $(UV) pip install build |
25 | | - $(PY) -m build . |
26 | | - |
27 | | -$(VENV)/touchfile: pyproject.toml $(UV) |
28 | | - $(UV) --no-progress pip install -r pyproject.toml --all-extras |
29 | | - @$(shell if [ "$(OS)" = "Windows_NT" ]; then echo type nul > $(VENV)\\touchfile; else echo touch $(VENV)/touchfile; fi) |
30 | | -$(PY): |
31 | | - $(SYSTEM_PYTHON) -m venv $(VENV) |
32 | | - |
33 | | -$(UV): $(PY) |
34 | | - $(PIP) install --upgrade pip |
35 | | - $(PIP) install uv |
36 | | - |
37 | | -install: $(VENV)/touchfile |
38 | | - $(UV) run pre-commit install |
39 | | - |
40 | | -UNAME_S := $(shell uname) |
| 20 | + uv build |
41 | 21 |
|
42 | 22 | test: install |
43 | 23 | @echo "🧪 Running tests..." |
44 | | -ifeq ($(UNAME_S),Darwin) |
45 | | -ifneq ($(GITHUB_ACTIONS),) |
46 | | - @echo "Running tests on MacOS in GitHub pipeline" |
47 | | - @echo "Skipping coverage check" |
48 | | -# https://github.com/actions/runner-images/issues/9918 |
49 | | -# Docling coverage is not working when tests are skipped on MacOS |
50 | | - $(UV) run pytest $(TEST_DIR) --cov-branch --cov-report term --cov-report html:reports --cov=$(SRC_DIR) |
51 | | -else |
52 | | - $(UV) run pytest $(TEST_DIR) --cov-branch --cov-report term --cov-report html:reports --cov-fail-under=90 --cov=$(SRC_DIR) |
53 | | -endif |
54 | | -else |
55 | | - $(UV) run pytest $(TEST_DIR) --cov-branch --cov-report term --cov-report html:reports --cov-fail-under=90 --cov=$(SRC_DIR) |
56 | | -endif |
| 24 | + @UNAME_S=$$(uname); \ |
| 25 | + if [ "$$UNAME_S" = "Darwin" ] && [ -n "$$GITHUB_ACTIONS" ]; then \ |
| 26 | + echo "Running tests on MacOS in GitHub pipeline"; \ |
| 27 | + echo "Skipping coverage check"; \ |
| 28 | + uv run pytest $(TEST_DIR) --cov-branch --cov-report term --cov-report html:reports --cov=$(SRC_DIR); \ |
| 29 | + elif [ "$$UNAME_S" = "Darwin" ]; then \ |
| 30 | + uv run pytest $(TEST_DIR) --cov-branch --cov-report term --cov-report html:reports --cov-fail-under=90 --cov=$(SRC_DIR); \ |
| 31 | + else \ |
| 32 | + uv run pytest $(TEST_DIR) --cov-branch --cov-report term --cov-report html:reports --cov-fail-under=90 --cov=$(SRC_DIR); \ |
| 33 | + fi |
57 | 34 |
|
58 | 35 | lint: install |
59 | 36 | @echo "🔍 Running lint checks..." |
60 | | - $(UV) run pre-commit run --all-files |
| 37 | + uv run pre-commit run --all-files |
61 | 38 |
|
62 | 39 | clean: |
63 | 40 | @echo "🧹 Cleaning up..." |
64 | 41 | @rm -rf __pycache__ ${SRC_DIR}/*.egg-info **/__pycache__ .pytest_cache |
65 | | - @rm -rf .coverage reports dist |
| 42 | + @rm -rf .coverage reports dist $(VENV) |
66 | 43 |
|
67 | 44 | documentation: install |
68 | 45 | @echo "📚 Serving documentation..." |
69 | | - $(UV) run mkdocs serve |
| 46 | + uv run mkdocs serve |
70 | 47 |
|
71 | | -.PHONY: reuse-lint |
72 | 48 | reuse-lint: |
73 | | - $(UV) run reuse lint |
| 49 | + uv run reuse lint |
0 commit comments