-
-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathMakefile
More file actions
168 lines (141 loc) · 4.98 KB
/
Makefile
File metadata and controls
168 lines (141 loc) · 4.98 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# CNVkit Maintenance Commands
# This Makefile provides shortcuts for common development and release tasks
PYTHON := python3
PIP := pip3
TWINE := twine
DOCKER := docker
# Version for releases (use: make release_version=0.9.13 upload-pypi)
release_version ?= latest
# Docker image name
DOCKER_IMAGE := etal/cnvkit
.PHONY: help
help:
@echo "CNVkit Maintenance Commands"
@echo ""
@echo "Development:"
@echo " install-dev Install CNVkit in editable mode with dev dependencies"
@echo " install-test Install CNVkit in editable mode with test dependencies"
@echo " test Run pytest tests"
@echo " test-all Run full tox test suite"
@echo " lint Run ruff linting"
@echo " format Run ruff formatting"
@echo " security Run security checks (safety + bandit)"
@echo " pre-commit Install and run pre-commit hooks"
@echo ""
@echo "Building & Distribution:"
@echo " build Build wheel and sdist using modern build tools"
@echo " clean Remove build artifacts"
@echo ""
@echo "Docker:"
@echo " docker Build 'devel' image from current source"
@echo " docker-release Build versioned release image (set release_version=X.Y.Z)"
@echo " docker-push Push versioned images to Docker Hub"
@echo " docker-dev Build DevContainer image for VS Code"
@echo " docker-test Test the built Docker image"
@echo " Note: GHA automatically builds 'devel' on master, 'latest' on tags"
@echo ""
@echo "Release:"
@echo " upload-pypi Upload to PyPI (set release_version=X.Y.Z)"
@echo ""
# =============================================================================
# Development
# =============================================================================
.PHONY: install-dev
install-dev:
$(PIP) install -e '.[test]'
$(PIP) install -r requirements/dev.txt
.PHONY: install-test
install-test:
$(PIP) install -e '.[test]'
.PHONY: test
test:
pytest -v -n auto test/
.PHONY: test-all
test-all:
tox
.PHONY: lint
lint:
ruff check cnvlib skgenome
.PHONY: format
format:
ruff format cnvlib skgenome
ruff check --fix cnvlib skgenome
.PHONY: security
security:
safety check
bandit -r cnvlib skgenome -c pyproject.toml
.PHONY: pre-commit
pre-commit:
pre-commit install
pre-commit run --all-files
# =============================================================================
# Building & Distribution
# =============================================================================
.PHONY: build
build: clean
$(PYTHON) -m build
.PHONY: clean
clean:
rm -rf build dist *.egg-info
rm -rf .tox .pytest_cache .coverage htmlcov coverage.xml
rm -rf cnvlib/__pycache__ skgenome/__pycache__
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name '*.pyc' -delete
find . -type f -name '*.pyo' -delete
# =============================================================================
# Docker
# =============================================================================
.PHONY: docker
docker:
@echo "Building production Docker image (from source)..."
$(DOCKER) build -t $(DOCKER_IMAGE):devel -f Dockerfile .
.PHONY: docker-release
docker-release:
@if [ "$(release_version)" = "latest" ]; then \
echo "ERROR: Please specify release_version (e.g., make release_version=0.9.13 docker-release)"; \
exit 1; \
fi
@echo "Building production Docker image for version $(release_version)..."
$(DOCKER) build --build-arg CNVKIT_VERSION=$(release_version) \
-t $(DOCKER_IMAGE):$(release_version) \
-t $(DOCKER_IMAGE):latest \
-f Dockerfile .
.PHONY: docker-push
docker-push:
@if [ "$(release_version)" = "latest" ]; then \
echo "ERROR: Please specify release_version (e.g., make release_version=0.9.13 docker-push)"; \
exit 1; \
fi
@echo "Pushing Docker images for version $(release_version)..."
$(DOCKER) push $(DOCKER_IMAGE):$(release_version)
$(DOCKER) push $(DOCKER_IMAGE):latest
.PHONY: docker-dev
docker-dev:
@echo "Building development DevContainer image..."
$(DOCKER) build -t $(DOCKER_IMAGE):devcontainer -f .devcontainer/Dockerfile .
.PHONY: docker-test
docker-test:
@echo "Testing Docker image..."
$(DOCKER) run --rm $(DOCKER_IMAGE):devel cnvkit.py version
$(DOCKER) run --rm $(DOCKER_IMAGE):devel cnvkit.py --help
# =============================================================================
# Release
# =============================================================================
.PHONY: upload-pypi
upload-pypi: build
@if [ "$(release_version)" = "latest" ]; then \
echo "ERROR: Please specify release_version (e.g., make release_version=0.9.13 upload-pypi)"; \
exit 1; \
fi
@echo "Uploading version $(release_version) to PyPI..."
$(TWINE) upload dist/*
# =============================================================================
# Documentation
# =============================================================================
.PHONY: docs
docs:
tox -e doc
.PHONY: docs-serve
docs-serve: docs
@echo "Serving documentation at http://localhost:8000"
cd .tox/doc/html && $(PYTHON) -m http.server