97 lines
1.7 KiB
Makefile
97 lines
1.7 KiB
Makefile
# =====CONFIG=====
|
|
PYTHON := python3
|
|
# This can't contain spaces (I think)
|
|
VENV := .venv
|
|
# Minimum % coverage for tests to succeed
|
|
MIN_COV := 0
|
|
# Directory name for the frontend
|
|
WEB_DIR := web
|
|
|
|
|
|
# By default, just create the venv when needed
|
|
all: venv
|
|
|
|
|
|
# =====BACKEND=====
|
|
## VENV
|
|
### Create the venv
|
|
$(VENV)/bin/activate: setup.py setup.cfg
|
|
@ '$(PYTHON)' -m venv '$(VENV)'
|
|
@ '$(VENV)'/bin/pip install -e .[develop]
|
|
|
|
|
|
### Convenient alias for the venv
|
|
venv: $(VENV)/bin/activate
|
|
.PHONY: venv
|
|
|
|
|
|
## Formatting & linting
|
|
### Format the codebase using black
|
|
format: venv
|
|
@ '$(VENV)'/bin/black setup.py app
|
|
.PHONY: format
|
|
|
|
### Lint using black & flake8
|
|
lint: venv
|
|
@ '$(VENV)'/bin/flake8 setup.py app
|
|
@ '$(VENV)'/bin/black --check setup.py app
|
|
.PHONY: lint
|
|
|
|
|
|
## Testing
|
|
test: venv
|
|
@ '$(VENV)'/bin/pytest --cov=app --cov-fail-under='$(MIN_COV)' tests/
|
|
.PHONY: test
|
|
|
|
|
|
## Cleaning
|
|
### Remove the venv
|
|
clean:
|
|
@ rm -rf '$(VENV)' '$(WEB_DIR)'/node_modules
|
|
.PHONY: clean
|
|
|
|
|
|
## Starting the server
|
|
### Run the Quart server
|
|
run: venv
|
|
@ '$(VENV)'/bin/python app
|
|
.PHONY: run
|
|
|
|
|
|
# =====BACKEND=====
|
|
## node_modules
|
|
### Install dependencies
|
|
$(WEB_DIR)/node_modules: $(WEB_DIR)/package.json $(WEB_DIR)/yarn.lock
|
|
@ yarn --cwd '$(WEB_DIR)' install
|
|
|
|
# Convenient alias
|
|
node_modules: | $(WEB_DIR)/node_modules
|
|
.PHONY: node_modules
|
|
|
|
|
|
## Formatting & linting
|
|
flint: node_modules
|
|
@ yarn --cwd '$(WEB_DIR)' run lint
|
|
.PHONY: flint
|
|
|
|
fformat: node_modules
|
|
@ yarn --cwd '$(WEB_DIR)' run format
|
|
.PHONY: fformat
|
|
|
|
|
|
## Testing
|
|
ftest: node_modules
|
|
@ yarn --cwd '$(WEB_DIR)' test
|
|
|
|
## Building
|
|
fbuild: node_modules
|
|
@ yarn --cwd '$(WEB_DIR)' build
|
|
.PHONY: fbuild
|
|
|
|
|
|
# =====DOCKER=====
|
|
## Build image
|
|
dbuild:
|
|
@ DOCKER_BUILDKIT=1 docker build -t chewingbever/jos:dev .
|
|
.PHONY: image
|