2021-04-02 13:49:40 +02:00
|
|
|
# =====CONFIG=====
|
2021-05-18 15:55:36 +02:00
|
|
|
PYTHON := python3
|
2021-04-02 13:49:40 +02:00
|
|
|
# This can't contain spaces (I think)
|
2021-05-18 15:55:36 +02:00
|
|
|
VENV := .venv
|
2021-05-18 08:57:40 +02:00
|
|
|
# Minimum % coverage for tests to succeed
|
2021-05-18 12:24:10 +02:00
|
|
|
MIN_COV := 0
|
2021-05-18 15:55:36 +02:00
|
|
|
# Directory name for the frontend
|
|
|
|
WEB_DIR := web
|
2021-04-02 13:49:40 +02:00
|
|
|
|
|
|
|
|
2021-05-18 22:06:37 +02:00
|
|
|
# =====GENERAL=====
|
|
|
|
## By default, create the venv
|
2021-04-02 13:49:40 +02:00
|
|
|
all: venv
|
2021-05-18 22:06:37 +02:00
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
|
|
|
|
## Remove any temporary files
|
|
|
|
clean:
|
|
|
|
@ rm -rf '$(VENV)' '$(WEB_DIR)'/node_modules
|
|
|
|
.PHONY: clean
|
2021-04-02 13:49:40 +02:00
|
|
|
|
|
|
|
|
2021-05-18 15:55:36 +02:00
|
|
|
# =====BACKEND=====
|
2021-05-18 08:57:40 +02:00
|
|
|
## VENV
|
|
|
|
### Create the venv
|
|
|
|
$(VENV)/bin/activate: setup.py setup.cfg
|
2021-04-02 13:49:40 +02:00
|
|
|
@ '$(PYTHON)' -m venv '$(VENV)'
|
2021-05-18 08:57:40 +02:00
|
|
|
@ '$(VENV)'/bin/pip install -e .[develop]
|
2021-04-02 13:49:40 +02:00
|
|
|
|
2021-05-18 08:57:40 +02:00
|
|
|
|
|
|
|
### Convenient alias for the venv
|
2021-04-02 13:49:40 +02:00
|
|
|
venv: $(VENV)/bin/activate
|
|
|
|
.PHONY: venv
|
|
|
|
|
|
|
|
|
2021-05-18 08:57:40 +02:00
|
|
|
## Formatting & linting
|
2021-05-18 09:04:41 +02:00
|
|
|
### Format the codebase using black
|
2021-05-18 08:57:40 +02:00
|
|
|
format: venv
|
2021-05-18 09:04:41 +02:00
|
|
|
@ '$(VENV)'/bin/black setup.py app
|
2021-05-18 08:57:40 +02:00
|
|
|
.PHONY: format
|
|
|
|
|
2021-05-18 09:04:41 +02:00
|
|
|
### Lint using black & flake8
|
2021-05-18 08:57:40 +02:00
|
|
|
lint: venv
|
2021-05-18 09:04:41 +02:00
|
|
|
@ '$(VENV)'/bin/flake8 setup.py app
|
|
|
|
@ '$(VENV)'/bin/black --check setup.py app
|
2021-05-18 08:57:40 +02:00
|
|
|
.PHONY: lint
|
|
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
test: venv
|
2021-05-18 09:04:41 +02:00
|
|
|
@ '$(VENV)'/bin/pytest --cov=app --cov-fail-under='$(MIN_COV)' tests/
|
2021-05-18 08:57:40 +02:00
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
|
2021-05-18 11:45:44 +02:00
|
|
|
## Starting the server
|
|
|
|
### Run the Quart server
|
2021-04-02 13:49:40 +02:00
|
|
|
run: venv
|
2021-05-18 11:45:44 +02:00
|
|
|
@ '$(VENV)'/bin/python app
|
2021-05-18 15:55:36 +02:00
|
|
|
.PHONY: run
|
|
|
|
|
|
|
|
|
|
|
|
# =====BACKEND=====
|
|
|
|
## node_modules
|
|
|
|
### Install dependencies
|
2021-05-18 17:28:57 +02:00
|
|
|
$(WEB_DIR)/node_modules: $(WEB_DIR)/package.json $(WEB_DIR)/yarn.lock
|
2021-05-18 18:29:20 +02:00
|
|
|
@ yarn --cwd '$(WEB_DIR)' install
|
2021-05-18 15:55:36 +02:00
|
|
|
|
|
|
|
# Convenient alias
|
2021-05-18 17:28:57 +02:00
|
|
|
node_modules: | $(WEB_DIR)/node_modules
|
|
|
|
.PHONY: node_modules
|
2021-05-18 15:55:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
## Formatting & linting
|
2021-05-18 17:28:57 +02:00
|
|
|
flint: node_modules
|
2021-05-18 18:29:20 +02:00
|
|
|
@ yarn --cwd '$(WEB_DIR)' run lint
|
2021-05-18 15:55:36 +02:00
|
|
|
.PHONY: flint
|
|
|
|
|
2021-05-18 17:28:57 +02:00
|
|
|
fformat: node_modules
|
2021-05-18 18:29:20 +02:00
|
|
|
@ yarn --cwd '$(WEB_DIR)' run format
|
2021-05-18 15:55:36 +02:00
|
|
|
.PHONY: fformat
|
|
|
|
|
|
|
|
|
|
|
|
## Testing
|
2021-05-18 18:29:20 +02:00
|
|
|
ftest: node_modules
|
|
|
|
@ yarn --cwd '$(WEB_DIR)' test
|
2021-05-18 22:06:37 +02:00
|
|
|
.PHONY: ftest
|
2021-05-18 15:55:36 +02:00
|
|
|
|
|
|
|
## Building
|
2021-05-18 17:28:57 +02:00
|
|
|
fbuild: node_modules
|
2021-05-18 18:29:20 +02:00
|
|
|
@ yarn --cwd '$(WEB_DIR)' build
|
2021-05-18 15:55:36 +02:00
|
|
|
.PHONY: fbuild
|
2021-05-18 21:46:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
# =====DOCKER=====
|
|
|
|
## Build image
|
|
|
|
dbuild:
|
|
|
|
@ DOCKER_BUILDKIT=1 docker build -t chewingbever/jos:dev .
|
|
|
|
.PHONY: image
|
2021-05-18 22:06:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
## Run image
|
|
|
|
drun: dbuild
|
|
|
|
@ docker run --rm -it -p 5000:5000 chewingbever/jos:dev
|
|
|
|
.PHONY: drun
|