-
Notifications
You must be signed in to change notification settings - Fork 91
/
Makefile
82 lines (68 loc) · 2.32 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
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-push.ocf.berkeley.edu/
DOCKER_REVISION ?= testing-$(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 mypy
$(BIN)/py.test -v tests/
$(BIN)/pre-commit run --all-files
.PHONY: mypy
mypy: venv
$(BIN)/mypy -p ocfweb
.PHONY: cook-image
cook-image:
$(eval OCFLIB_VERSION := ==$(shell curl https://pypi.org/pypi/ocflib/json | jq -r .info.version))
docker build --pull --build-arg ocflib_version=$(OCFLIB_VERSION) --target base .
docker build -t $(DOCKER_TAG_WEB) --target web .
docker build -t $(DOCKER_TAG_WORKER) --target worker .
docker build -t $(DOCKER_TAG_STATIC) --target static .
.PHONY: push-image
push-image:
docker push $(DOCKER_TAG_WEB)
docker push $(DOCKER_TAG_WORKER)
docker push $(DOCKER_TAG_STATIC)
.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
python3 ./vendor/venv-update venv= venv -ppython3.9 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)/pysassc "$<" "$@"
.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