forked from fooof-tools/fooof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (83 loc) · 2.66 KB
/
Makefile
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
# Makefile for working with a Python module
##########################################################################
## REQUIREMENTS
#
# This file requires certain dependencies for full functionality.
#
# The following Python packages are required:
# pytest For running tests
# coverage For running test coverage
# pylint For running linting on code
# setuptools For creating distributions
#
# The following command line utilities are required:
# cloc For counting code
#
##########################################################################
## VARIABLES
MODULE = fooof
LINT_FILE = _lint.txt
##########################################################################
## CODE COUNTING
# Run all counts
run-counts:
@make count-size
@make count-module
@make count-tests
# Count the total number of lines in the module
count-size:
@printf "\n\nCHECK MODULE SIZE:"
@printf "\nNumber of lines of code & comments in the module: "
@find ./$(MODULE) -name "*.py" -type f -exec grep . {} \; | wc -l
# Count module code with CLOC, excluding test files
count-module:
@printf "\n\nCLOC OUTPUT - MODULE: \n"
@cloc $(MODULE) --exclude-dir='tests'
# Count test code, with CLOC
count-tests:
@printf "\n\nCLOC OUTPUT - TEST FILES: \n"
@cloc $(MODULE)/tests --exclude-dir='test_files'
##########################################################################
## CODE TESTING
# Run all tests
run-tests:
@make coverage
@make doctests
# Run tests
tests:
@printf "\n\nRUN TESTS: \n"
@pytest
# Run test coverage
coverage:
@printf "\n\nRUN TESTS: \n"
@coverage run --source $(MODULE) -m py.test
@printf "\n\nCHECK COVERAGE: \n"
@coverage report --omit="*/tests*"
# Run doctests
doctests:
@printf "\n\nCHECK DOCTEST EXAMPLES: \n"
@pytest --doctest-modules --ignore=$(MODULE)/tests $(MODULE)
##########################################################################
## CODE LINTING
# Run pylint and print summary
# Note: --exit-zero is because pylint throws an error when called
# from a Makefile. Unclear why, but this avoids it stopping.
run-lints:
@printf "\n\nRUN PYLINT ACROSS MODULE: \n"
@pylint $(MODULE) --ignore tests --exit-zero > $(LINT_FILE)
@tail -n4 $(LINT_FILE)
##########################################################################
## SUMMARY
# Run a summary of the module
summary:
@make run-counts
@make run-tests
@make run-lints
##########################################################################
## DISTRIBUTION
# Create a distribution build of the module
dist:
@python setup.py sdist bdist_wheel
# Clear out distribution files
clear-dist:
@rm -rf build dist $(MODULE).egg-info