Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (107 loc) · 4.53 KB
/
Copy pathMakefile
File metadata and controls
131 lines (107 loc) · 4.53 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Makefile for cffconvert repository maintenance
# Usage: make <target>
.PHONY: install dev-install test test-version test-marker \
test-local test-version-local test-marker-local \
lint lint-local precommit clean \
build build-local release-check help \
docker-build docker-run docker-smoke docker-test-build docker-dev-build
# Default Python interpreter (use venv python if available, else system python3)
PYTHON := $(shell command -v python3 2>/dev/null || echo python3)
# uv executable (use uv if available, fall back to python3 -m uv)
UV := $(shell command -v uv 2>/dev/null || echo "python3 -m uv")
## Install runtime dependencies only
install:
$(UV) pip install .
## Install with dev and testing dependencies (editable)
dev-install:
$(UV) pip install --editable .[dev,testing]
## Build the test Docker image (includes testing dependencies)
docker-test-build:
docker build --target test -t cffconvert-test .
## Build the development Docker image (includes dev and testing dependencies)
docker-dev-build:
docker build --target dev -t cffconvert-dev .
## Run the full test suite in Docker
test: docker-test-build
docker run --rm cffconvert-test
## Run version-consistency tests in Docker
test-version: docker-test-build
docker run --rm cffconvert-test pytest tests/test_consistent_versioning.py
## Run tests for a specific marker in Docker (e.g. make test-marker M=bibtex)
test-marker: docker-test-build
docker run --rm cffconvert-test pytest -m $(M)
## Run the full test suite locally (requires dev-install)
test-local:
pytest tests/
## Run version-consistency tests locally
test-version-local:
pytest tests/test_consistent_versioning.py
## Run tests for a specific marker locally (e.g. make test-marker-local M=bibtex)
test-marker-local:
pytest -m $(M)
## Run all linters in Docker (ruff, pyroma)
lint: docker-dev-build
docker run --rm cffconvert-dev ruff check --no-cache src/cffconvert tests
docker run --rm cffconvert-dev pyroma .
## Run all linters locally (requires dev-install)
lint-local:
ruff check src/cffconvert tests
pyroma .
## Run pre-commit hooks on all files
precommit:
pre-commit run --all-files
## Clean build artifacts, caches, and bytecode
clean:
rm -rf build/ dist/ .eggs/ *.egg-info src/*.egg-info .pytest_cache .mypy_cache .ruff_cache
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
## Build the production Docker image
docker-build:
docker build -t cffconvert .
## Run cffconvert in the production Docker image (pass args via ARGS)
## The image workdir is /work; the host directory is mounted at /work
docker-run:
docker run --rm -v $(PWD):/work cffconvert $(ARGS)
## Build and smoke-test the production Docker image
## Covers: --version; read-only /work stdout conversion; arbitrary-UID
## writable /work -o conversion; and a mount over /app cannot hide the
## absolute entrypoint. Uses a temp dir with trap cleanup; leaves no
## generated output in the repo.
docker-smoke: docker-build
@set -eu; \
TMP="$$(mktemp -d)"; \
trap 'rm -rf "$$TMP"' EXIT INT TERM; \
chmod 755 "$$TMP"; \
cp CITATION.cff "$$TMP/CITATION.cff"; \
chmod 644 "$$TMP/CITATION.cff"; \
mkdir "$$TMP/output"; \
chmod 777 "$$TMP/output"; \
echo "smoke: --version"; \
docker run --rm cffconvert --version; \
echo "smoke: read-only /work stdout conversion"; \
docker run --rm -v "$$TMP":/work:ro cffconvert -f bibtex | grep -q "@misc{"; \
echo "smoke: arbitrary UID writable /work -o conversion"; \
docker run --rm --user 4242 -v "$$TMP":/input:ro -v "$$TMP/output":/work cffconvert -i /input/CITATION.cff -o /work/out.bib -f bibtex; \
test -s "$$TMP/output/out.bib"; \
echo "smoke: /app mount cannot hide the executable"; \
echo decoy > "$$TMP/cffconvert"; \
docker run --rm -v "$$TMP":/app cffconvert --version; \
echo "smoke: OK"
## Build sdist and wheel distributions into dist/ using Docker
build: clean docker-dev-build
docker run --rm --user "$$(id -u):$$(id -g)" -e HOME=/tmp \
-v "$(PWD):/repo" -w /repo cffconvert-dev python -m build
## Build sdist and wheel distributions locally into dist/
build-local: clean
$(PYTHON) -m build
## Run the full containerized release validation gate (never publishes)
release-check: clean lint test test-version build
## Show available targets
help:
@awk '\
/^## / { description = description (description ? " " : "") substr($$0, 4); next } \
/^[[:alnum:]_.-]+:/ { \
target = $$1; sub(/:.*/, "", target); \
if (description) printf "%-24s %s\n", target, description; \
description = ""; \
}' $(MAKEFILE_LIST)