forked from ocf/ocfweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (74 loc) · 2.61 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
BIN := venv/bin
PYTHON := $(BIN)/python
SHELL := /bin/bash
RANDOM_PORT := $(shell expr $$(( 8000 + (`id -u` % 1000) )))
LISTEN_IP := 0.0.0.0
DOCKER_REPO ?=
DOCKER_REVISION ?= testing-$(USER)
DOCKER_TAG_BASE = ocfweb-base-$(USER)
DOCKER_TAG_WEB = $(DOCKER_REPO)ocfweb-web:$(DOCKER_REVISION)
DOCKER_TAG_WORKER = $(DOCKER_REPO)ocfweb-worker:$(DOCKER_REVISION)
DOCKER_TAG_STATIC = $(DOCKER_REPO)ocfweb-static:$(DOCKER_REVISION)
.PHONY: test
test: export OCFWEB_TESTING ?= 1
test: venv
$(BIN)/coverage run -m py.test -v tests/
$(BIN)/coverage report
$(BIN)/pre-commit run --all-files
.PHONY: Dockerfile.%
Dockerfile.%: Dockerfile.%.in
sed 's/{tag}/$(DOCKER_TAG_BASE)/g' "$<" > "$@"
.PHONY: cook-image
cook-image: Dockerfile.web Dockerfile.worker Dockerfile.static
$(eval OCFLIB_VERSION := ==$(shell curl https://pypi.python.org/pypi/ocflib/json | jq -r .info.version))
docker build --pull --build-arg ocflib_version=$(OCFLIB_VERSION) -t $(DOCKER_TAG_BASE) .
docker build -t $(DOCKER_TAG_WEB) -f Dockerfile.web .
docker build -t $(DOCKER_TAG_WORKER) -f Dockerfile.worker .
docker build -t $(DOCKER_TAG_STATIC) -f Dockerfile.static .
.PHONY: push-image
push-image:
docker push $(DOCKER_TAG_WEB)
docker push $(DOCKER_TAG_WORKER)
docker push $(DOCKER_TAG_STATIC)
# first set COVERALLS_REPO_TOKEN=<repo token> environment variable
.PHONY: coveralls
coveralls: venv test
$(BIN)/coveralls
.PHONY: dev
dev: venv ocfweb/static/scss/site.scss.css
@echo -e "\e[1m\e[93mRunning on http://$(shell hostname -f ):$(RANDOM_PORT)/\e[0m"
$(PYTHON) ./manage.py runserver $(LISTEN_IP):$(RANDOM_PORT)
.PHONY: local-dev
local-dev: LISTEN_IP=127.0.0.1
local-dev: dev
venv: requirements.txt requirements-dev.txt
python ./vendor/venv-update venv= venv -ppython3 install= -r requirements.txt -r requirements-dev.txt
.PHONY: install-hooks
install-hooks: venv
$(BIN)/pre-commit install -f --install-hooks
.PHONY: lint
lint: venv
$(BIN)/pre-commit run --all-files
.PHONY: clean
clean:
rm -rf *.egg-info venv
# closer to prod
.PHONY: gunicorn
gunicorn: venv
@echo "Running on port $(RANDOM_PORT)"
$(BIN)/gunicorn -b 0.0.0.0:$(RANDOM_PORT) ocfweb.wsgi
# phony because it depends on other files, too many to express
.PHONY: ocfweb/static/scss/site.scss.css
ocfweb/static/scss/site.scss.css: ocfweb/static/scss/site.scss venv
$(BIN)/sassc "$<" "$@"
.PHONY: watch-scss
watch-scss: venv
while :; do \
make ocfweb/static/scss/site.scss.css; \
find ocfweb/static -type f -name '*.scss' | \
inotifywait --fromfile - -e modify; \
done
.PHONY: update-requirements
update-requirements: venv
$(BIN)/upgrade-requirements
sed -i 's/^ocflib==.*/ocflib/' requirements.txt