-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
133 lines (100 loc) · 2.77 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
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
##
## ----------------
## General
## ----------------
##
all: help
help: # Display this message
@grep -E '(^[a-zA-Z0-9_\-\.]+:.*?#.*$$)|(^#)' Makefile | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m## /[33m/'
venv = venv
python_bin = python3
bin = ${venv}/bin/
pysources = server/ tests/ tools/
install: .env install-python # Install
.env:
cp -n .env.example .env
venv:
${python_bin} -m venv ${venv}
install-python: venv
${bin}pip install -U pip wheel
${bin}pip install -r requirements.txt
make messagesc
##
## ----------------
## Building
## ----------------
##
build: # Build assets
make pybuild
make messagesc
pybuild:
${bin}python -m tools.pybuild ./server/web/styles/styles.css --outdir ./server/web/static/css ${ARGS}
##
## ----------------
## Serving
## ----------------
##
start: # Run servers
make -j start-uvicorn start-assets
start-uvicorn:
PYTHONUNBUFFERED=1 ${bin}python -m server.main 2>&1 | ${bin}python -m tools.colorprefix blue [server]
start-assets:
PYTHONUNBUFFERED=1 make pybuild ARGS="--watch" 2>&1 | ${bin}python -m tools.colorprefix yellow [assets]
##
## ----------------
## Code quality
## ----------------
##
test: # Run the test suite
${bin}pytest
check: # Run code checks
${bin}black --check --diff ${pysources}
${bin}flake8 ${pysources}
${bin}mypy ${pysources}
${bin}isort --check --diff ${pysources}
${bin}python -m server.tools.mdformat --check
format: # Run automatic code formatting
${bin}autoflake --in-place --recursive ${pysources}
${bin}isort ${pysources}
${bin}black ${pysources}
${bin}python -m server.tools.mdformat
##
## ----------------
## Translations
## ----------------
##
locale/.init:
${bin}pybabel init -l fr_FR -i locale/base.pot -d locale
touch locale/.init
messages: locale/.init # Update translations
${bin}pybabel extract -F babel.cfg -o locale/base.pot ./server/
${bin}pybabel update -i locale/base.pot -d locale
messagesc: # Compile translations
${bin}pybabel compile --domain messages -d locale
##
## ----------------
## Tools
## ----------------
##
imgoptimize: # Optimize images
${bin}python -m server.tools.imgoptimize
##
## ----------------
## Deployment
## ----------------
##
install-deploy: # Install deployment dependencies
cd ansible && make install
ping: # Ping (args: env)
cd ansible && make ping env=${env}
provision: # Provision infrastructure (args: env)
cd ansible && make provision env=${env}
deploy: # Deploy (args: env)
cd ansible && make deploy env=${env}
vagrant = cd ansible/environments/vagrant && vagrant
vagrant-up: # Start the test Vagrant VM.
${vagrant} up
vagrant-halt: # Start the test Vagrant VM.
${vagrant} halt
vagrant-ssh: # SSH into the Vagrant VM, exposing its deployment on localhost:8080
${vagrant} ssh -- -L 8080:localhost:80