-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (118 loc) · 5.62 KB
/
Makefile
File metadata and controls
153 lines (118 loc) · 5.62 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
ifneq (,)
.error This Makefile requires GNU Make.
endif
.PHONY: all autoformat lint-files lint-json lint-python-black lint-python-pycodestyle lint-python-pydocstyle _pull-files _pull-json _pull-python-black _pull-python-pycodestyle _pull-python-pydocstyle
# --------------------------------------------------------------------------------
# File-lint configuration
# --------------------------------------------------------------------------------
FL_VERSION = 0.2
FL_IGNORES = .git/,.github/,.idea/
# --------------------------------------------------------------------------------
# Jsonlin configuration
# --------------------------------------------------------------------------------
JL_VERSION = 1.6.0-0.4
JL_IGNORES = .idea/*
# --------------------------------------------------------------------------------
# Targets
# --------------------------------------------------------------------------------
help:
@echo "autoformat Autoformat Python files according to black"
@echo "lint-all Lint all targets below"
@echo "lint-files Lint and test all files"
@echo "lint-json Lint JSON files"
@echo "lint-python-pycodestyle Lint Python files against pycodestyleodestyle"
@echo "lint-python-pydocstyle Lint Python files against pydocstyleocstyle"
@echo "lint-python-black Lint Python files against black (code formatter)"
@echo "create-project-flask-mongo Creates a new project based on Flask and Mongo"
autoformat: _pull-python-black
docker run --rm -v ${PWD}:/data cytopia/black -l 100 .
lint-all:
@$(MAKE) --no-print-directory lint-files
@$(MAKE) --no-print-directory lint-json
@$(MAKE) --no-print-directory lint-python-pycodestyle
@$(MAKE) --no-print-directory lint-python-pydocstyle
@$(MAKE) --no-print-directory lint-python-black
lint-files: _pull-files
@echo "################################################################################"
@echo "# File lint"
@echo "################################################################################"
@docker run --rm -v ${PWD}:/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm -v ${PWD}:/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm -v ${PWD}:/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm -v ${PWD}:/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm -v ${PWD}:/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORES)' --path .
@docker run --rm -v ${PWD}:/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORES)' --path .
@echo
lint-json: _pull-json
@echo "################################################################################"
@echo "# JSON lint"
@echo "################################################################################"
@if docker run --rm -v "${PWD}:/data:ro" cytopia/jsonlint:$(JL_VERSION) \
-t ' ' -i '$(JL_IGNORES)' '*.json'; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi;
@echo
lint-python-black: _pull-python-black
@echo "################################################################################"
@echo "# Python code formatting (black)"
@echo "################################################################################"
@docker run --rm -v ${PWD}:/data cytopia/black --diff --check -l 100 .
@echo
lint-python-pycodestyle: _pull-python-pycodestyle
@echo "################################################################################"
@echo "# Python lint (pycodestyle)"
@echo "################################################################################"
@docker run --rm -v ${PWD}:/data cytopia/pycodestyle .
@echo
lint-python-pydocstyle: _pull-python-pydocstyle
@echo "################################################################################"
@echo "# Python lint (pydocstyle)"
@echo "################################################################################"
@docker run --rm -v ${PWD}:/data cytopia/pydocstyle .
@echo
# --------------------------------------------------------------------------------
# Test Targets
# --------------------------------------------------------------------------------
test-003:
ifeq ($(ARGS),cytopia)
else
ifeq ($(ARGS),maifz)
else
@$(error You must specify ARGS=cytopia or ARGS=maifz)
endif
endif
$(PWD)/tests/003.sh $(ARGS)
# --------------------------------------------------------------------------------
# Project Targets
# --------------------------------------------------------------------------------
#
create-project-flask-mongo:
@if [ "$(USER)" != "cytopia" ] && [ "$(USER)" != "maifz" ]; then \
echo "You must specify USER=cytopia or USER=maifz"; \
exit 1; \
fi;
@if [ -z "$(NUM)" ]; then \
echo "You must specify NUM, e.g.: NUM=005"; \
exit 1; \
fi;
@mkdir -p "$(NUM)/$(USER)"
@if [ ! -f $(NUM)/$(USER)/Makefile ]; then \
cp templates/makefiles/Makefile.flask-mongo $(NUM)/$(USER)/Makefile; \
cd $(NUM)/$(USER) && make init; \
fi
# --------------------------------------------------------------------------------
# Helper Targets
# --------------------------------------------------------------------------------
_pull-files:
@docker pull cytopia/file-lint:$(FL_VERSION) >/dev/null
_pull-json:
@docker pull cytopia/jsonlint:$(JL_VERSION) >/dev/null
_pull-python-black:
@docker pull cytopia/black:latest >/dev/null
_pull-python-pycodestyle:
@docker pull cytopia/pycodestyle:latest >/dev/null
_pull-python-pydocstyle:
@docker pull cytopia/pydocstyle:latest >/dev/null