-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (95 loc) · 3.81 KB
/
Copy pathMakefile
File metadata and controls
122 lines (95 loc) · 3.81 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
# =============================================================================
# Makefile — lint, format, and typecheck for sm-vcf-annotation
# =============================================================================
# Install dev tools: pip install ruff mypy snakefmt shellcheck-py
#
# Quick reference:
# make lint — check everything (no changes)
# make format — auto-fix formatting
# make fix — auto-fix lint + formatting
# make typecheck — run mypy
# make test — run all tests
# make clean — remove caches
# =============================================================================
SHELL := /bin/bash
.DEFAULT_GOAL := help
# --- File sets ---------------------------------------------------------------
PY_FILES := workflow/rules/helpers.py scripts/generate_config.py
SMK_FILES := workflow/rules/*.smk workflow/Snakefile
SH_FILES := scripts/run_snakemake.sh
# =============================================================================
# Composite targets
# =============================================================================
.PHONY: lint
lint: lint-py lint-smk lint-sh typecheck ## Run all checks (no modifications)
.PHONY: format
format: format-py format-smk format-sh ## Auto-format all files
.PHONY: fix
fix: fix-py format-smk format-sh ## Auto-fix lint issues + format
.PHONY: check
check: lint ## Alias for lint
# =============================================================================
# Python (ruff + mypy)
# =============================================================================
.PHONY: lint-py
lint-py: ## Check Python: ruff lint + format check
ruff check $(PY_FILES)
ruff format --check $(PY_FILES)
.PHONY: format-py
format-py: ## Format Python files
ruff format $(PY_FILES)
.PHONY: fix-py
fix-py: ## Auto-fix Python lint issues + format
ruff check --fix $(PY_FILES)
ruff format $(PY_FILES)
.PHONY: typecheck
typecheck: ## Run mypy type checking
mypy $(PY_FILES)
# =============================================================================
# Snakemake (snakefmt)
# =============================================================================
.PHONY: lint-smk
lint-smk: ## Check Snakemake formatting
snakefmt --check $(SMK_FILES)
.PHONY: format-smk
format-smk: ## Format Snakemake files
snakefmt $(SMK_FILES)
# =============================================================================
# Shell (shellcheck)
# =============================================================================
.PHONY: lint-sh
lint-sh: ## Check shell scripts (shellcheck, warning level)
shellcheck -S warning $(SH_FILES)
.PHONY: format-sh
format-sh: ## Fix shell script line endings (LF)
@for f in $(SH_FILES); do \
sed -i 's/\r$$//' "$$f" && echo " LF: $$f"; \
done
# =============================================================================
# Tests (pytest)
# =============================================================================
.PHONY: test
test: ## Run all tests
pytest
.PHONY: test-unit
test-unit: ## Run unit tests (skip dry-run tests)
pytest -m "not dryrun"
.PHONY: test-dryrun
test-dryrun: ## Run dry-run tests only
pytest -m dryrun
.PHONY: test-cov
test-cov: ## Run tests with coverage report
pytest --cov=workflow/rules --cov-report=term-missing
# =============================================================================
# Utilities
# =============================================================================
.PHONY: install-dev
install-dev: ## Install dev linting tools
pip install ruff mypy snakefmt shellcheck-py
.PHONY: clean
clean: ## Remove tool caches
rm -rf .mypy_cache .ruff_cache __pycache__ workflow/rules/__pycache__
.PHONY: help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'