forked from samsledje/philharmonic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (95 loc) · 3.44 KB
/
Copy pathMakefile
File metadata and controls
111 lines (95 loc) · 3.44 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
#################################################################################
# GLOBALS #
#################################################################################
PROJECT_NAME = philharmonic
PYTHON_VERSION = 3.11
PYTHON_INTERPRETER = python
CURRENT_TAG := $(shell git describe --tags --abbrev=0)
NEXT_MAJOR := $(shell poetry version major --dry-run -s)
NEXT_MINOR := $(shell poetry version minor --dry-run -s)
NEXT_PATCH := $(shell poetry version patch --dry-run -s)
NEXT_DYNAMIC := $(shell dunamai from git --style pep440 --bump)
## Show the current version and the next versions
.PHONY: version
version:
@echo "Current version: $(CURRENT_TAG)"
@echo "Dynamic version: $(NEXT_DYNAMIC) (make install)"
@echo "Next major: $(NEXT_MAJOR) (make bump-major)"
@echo "Next minor: $(NEXT_MINOR) (make bump-minor)"
@echo "Next patch: $(NEXT_PATCH) (make bump-patch)"
## Bump major version
.PHONY: bump-major
bump-major:
@echo "Current version will be bumped to: $(NEXT_MAJOR)"
poetry version $(NEXT_MAJOR)
git add pyproject.toml
git commit -m "build: bump version to $(NEXT_MAJOR)"
git tag -a "v$(NEXT_MAJOR)" -m "Release version $(NEXT_MAJOR)"
## Bump minor version
.PHONY: bump-minor
bump-minor:
@echo "Current version will be bumped to: $(NEXT_MINOR)"
poetry version $(NEXT_MINOR)
git add pyproject.toml
git commit -m "build: bump version to $(NEXT_MINOR)"
git tag -a "v$(NEXT_MINOR)" -m "Release version $(NEXT_MINOR)"
## Bump patch version
.PHONY: bump-patch
bump-patch:
@echo "Current version will be bumped to: $(NEXT_PATCH)"
poetry version $(NEXT_PATCH)
git add pyproject.toml
git commit -m "build: bump version to $(NEXT_PATCH)"
git tag -a "v$(NEXT_PATCH)" -m "Release version $(NEXT_PATCH)"
## Bump the version using dunamai
.PHONY: bump-dynamic
bump-dynamic:
@echo "Current dynamic version is: $(NEXT_DYNAMIC)"
poetry version $(NEXT_DYNAMIC)
## Lock poetry dependencies
.PHONY: lock
lock:
@echo "Locking poetry dependencies"
export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring
poetry lock -v
## Install the project using poetry
.PHONY: install
install: pyproject.toml poetry.lock
export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring
poetry install
## Publish the project to PyPI
.PHONY: publish
publish: pyproject.toml poetry.lock
poetry publish --build
## Create Snakemake DAG figure for README
.PHONY: pipeline_figure
pipeline_figure: config.yml
touch sample_sequences.fasta;
snakemake --configfile config.yml --filegraph | dot -Tpng > img/pipeline.png;
snakemake --configfile config.yml --filegraph | dot -Tsvg > img/pipeline.svg;
rm sample_sequences.fasta;
## Run Ruff formatting and linting
.PHONY: format
format:
@echo "Formatting project with ruff"
poetry run ruff check --fix .
poetry run ruff format .
## Run type checking, testing, and coverage reports
.PHONY: test
test:
@echo "Running tests and type checks"
mypy philharmonic --ignore-missing-imports
pytest --cov=philharmonic --cov-report=term-missing tests
.DEFAULT_GOAL := help
define PRINT_HELP_PYSCRIPT
import re, sys; \
lines = '\n'.join([line for line in sys.stdin]); \
matches = re.findall(r'\n## (.*)\n[\s\S]+?\n([a-zA-Z_-]+):', lines); \
print(matches); \
print('Available rules:\n'); \
print('\n'.join(['{:25}{}'.format(*reversed(match)) for match in matches]))
endef
export PRINT_HELP_PYSCRIPT
## Show this help message
help:
@$(PYTHON_INTERPRETER) -c "${PRINT_HELP_PYSCRIPT}" < $(MAKEFILE_LIST)