This repository has been archived on 2021-12-24. You can view files and clone it, but cannot push or open issues/pull-requests.
jos/Makefile

105 lines
1.8 KiB
Makefile
Raw Normal View History

# =====CONFIG=====
PYTHON := python3
# This can't contain spaces (I think)
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
# Directory name for the frontend
WEB_DIR := web
2021-05-18 22:06:37 +02:00
# =====GENERAL=====
## By default, create the venv
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
# =====BACKEND=====
2021-05-18 08:57:40 +02:00
## VENV
### Create the venv
$(VENV)/bin/activate: setup.py setup.cfg
@ '$(PYTHON)' -m venv '$(VENV)'
2021-05-18 08:57:40 +02:00
@ '$(VENV)'/bin/pip install -e .[develop]
2021-05-18 08:57:40 +02:00
### Convenient alias for the venv
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
run: venv
2021-05-18 11:45:44 +02:00
@ '$(VENV)'/bin/python app
.PHONY: run
# =====BACKEND=====
## node_modules
### Install dependencies
$(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
# Convenient alias
node_modules: | $(WEB_DIR)/node_modules
.PHONY: node_modules
## Formatting & linting
flint: node_modules
2021-05-18 18:29:20 +02:00
@ yarn --cwd '$(WEB_DIR)' run lint
.PHONY: flint
fformat: node_modules
2021-05-18 18:29:20 +02:00
@ yarn --cwd '$(WEB_DIR)' run format
.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
## Building
fbuild: node_modules
2021-05-18 18:29:20 +02:00
@ yarn --cwd '$(WEB_DIR)' build
.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