-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (88 loc) · 2.3 KB
/
Makefile
File metadata and controls
104 lines (88 loc) · 2.3 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
# Variables
PYTHON = poetry run ipython
PIP = pip3
POETRY = poetry
# Poetry Environment
.PHONY: install
install:
$(POETRY) install
# Update Dependencies
.PHONY: update
update:
$(POETRY) update
# Export Dependencies
.PHONY: export
export:
$(POETRY) export -f requirements.txt --output requirements.txt
# New Exercise Workspace
.PHONY: new-exercise
new-exercise:
git checkout -b $(USER)-exercise-$(shell date +%Y%m%d-%H%M)
# Solutions
.PHONY: solutions
solutions:
git checkout -b solutions
# Format Code
.PHONY: format
format:
$(POETRY) run black .
$(POETRY) run isort .
# Lint Code
.PHONY: lint
lint:
$(POETRY) run flake8 .
$(POETRY) run mypy .
$(POETRY) run pylint .
# Type Check
.PHONY: typecheck
typecheck:
$(POETRY) run mypy .
# Run Tests
.PHONY: test
test:
$(POETRY) run pytest tests/
# Run Single Test
.PHONY: test-file
test-file:
@echo "Usage: make test-file FILE=tests/test_file.py"
$(POETRY) run pytest $(FILE) -v
# Run Single Test Function
.PHONY: test-function
test-function:
@echo "Usage: make test-function FILE=tests/test_file.py::test_function"
$(POETRY) run pytest $(FILE) -v
# Run Interactive Shell
.PHONY: shell
shell:
$(PYTHON)
# Generate Data
.PHONY: data.txt
data.txt:
seq 10 > data.txt
# Clean Up
.PHONY: clean
clean:
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
find . -type f -name ".coverage" -delete
find . -type d -name ".pytest_cache" -delete
find . -type d -name ".mypy_cache" -delete
find . -type d -name ".coverage_cache" -delete
# Help
.PHONY: help
help:
@echo "Available commands:"
@echo " make install Install dependencies"
@echo " make update Update dependencies"
@echo " make export Export dependencies to requirements.txt"
@echo " make format Format code with black and isort"
@echo " make lint Lint the code"
@echo " make typecheck Run type checking"
@echo " make test Run all tests"
@echo " make test-file Run a specific test file (make test-file FILE=tests/test_file.py)"
@echo " make test-function Run a specific test function (make test-function FILE=tests/test_file.py::test_function)"
@echo " make shell Launch IPython shell"
@echo " make clean Clean up generated files"
@echo " make help Show this help message"
# Default Target
.DEFAULT_GOAL := help