2024-02-24 00:13:16 +00:00
|
|
|
MY_USER := $(shell id -u)
|
|
|
|
MY_GROUP := $(shell id -g)
|
|
|
|
ME := $(MY_USER):$(MY_GROUP)
|
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
SUDO ?= sudo
|
|
|
|
|
|
|
|
ARENA_CONTAINER ?= spiff-arena
|
|
|
|
ARENA_DEV_OVERLAY ?= dev.docker-compose.yml
|
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
BACKEND_CONTAINER ?= spiffworkflow-backend
|
|
|
|
BACKEND_DEV_OVERLAY ?= spiffworkflow-backend/dev.docker-compose.yml
|
|
|
|
|
2024-02-23 00:31:55 +00:00
|
|
|
FRONTEND_CONTAINER ?= spiffworkflow-frontend
|
|
|
|
FRONTEND_DEV_OVERLAY ?= spiffworkflow-frontend/dev.docker-compose.yml
|
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
DOCKER_COMPOSE ?= RUN_AS=$(ME) docker compose $(YML_FILES)
|
2024-02-27 14:13:02 +00:00
|
|
|
IN_ARENA ?= $(DOCKER_COMPOSE) run $(ARENA_CONTAINER)
|
2024-02-24 00:13:16 +00:00
|
|
|
IN_BACKEND ?= $(DOCKER_COMPOSE) run $(BACKEND_CONTAINER)
|
|
|
|
IN_FRONTEND ?= $(DOCKER_COMPOSE) run $(FRONTEND_CONTAINER)
|
|
|
|
|
2024-02-29 14:55:09 +00:00
|
|
|
SPIFFWORKFLOW_BACKEND_ENV ?= local_development
|
|
|
|
|
2024-03-26 14:56:24 +00:00
|
|
|
BACKEND_SQLITE_FILE ?= src/instance/db_$(SPIFFWORKFLOW_BACKEND_ENV).sqlite3
|
|
|
|
JUST ?=
|
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
YML_FILES := -f docker-compose.yml \
|
2024-02-27 14:13:02 +00:00
|
|
|
-f $(BACKEND_DEV_OVERLAY) \
|
|
|
|
-f $(FRONTEND_DEV_OVERLAY) \
|
|
|
|
-f $(ARENA_DEV_OVERLAY)
|
2024-02-24 00:13:16 +00:00
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
all: dev-env start-dev run-pyl
|
2024-02-24 00:13:16 +00:00
|
|
|
@/bin/true
|
|
|
|
|
|
|
|
build-images:
|
|
|
|
$(DOCKER_COMPOSE) build
|
|
|
|
|
2024-04-02 12:50:49 +00:00
|
|
|
dev-env: stop-dev build-images poetry-i be-poetry-i be-db-clean fe-npm-i
|
2024-02-24 00:13:16 +00:00
|
|
|
@/bin/true
|
2024-02-23 00:31:55 +00:00
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
start-dev: stop-dev
|
|
|
|
$(DOCKER_COMPOSE) up -d
|
2024-02-23 00:31:55 +00:00
|
|
|
|
|
|
|
stop-dev:
|
2024-02-24 00:13:16 +00:00
|
|
|
$(DOCKER_COMPOSE) down
|
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
be-clear-log-file:
|
|
|
|
$(IN_BACKEND) rm -f log/unit_testing.log
|
|
|
|
|
2024-04-02 12:50:49 +00:00
|
|
|
be-db-clean:
|
|
|
|
$(IN_BACKEND) ./bin/recreate_db clean
|
|
|
|
|
|
|
|
be-db-migrate:
|
|
|
|
$(IN_BACKEND) ./bin/recreate_db migrate
|
|
|
|
|
2024-02-27 23:17:14 +00:00
|
|
|
be-logs:
|
|
|
|
docker logs -f $(BACKEND_CONTAINER)
|
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
be-mypy:
|
|
|
|
$(IN_BACKEND) poetry run mypy src tests
|
|
|
|
|
2024-02-29 10:27:06 +00:00
|
|
|
be-poetry-i:
|
|
|
|
$(IN_BACKEND) poetry install
|
|
|
|
|
2024-03-08 18:00:51 +00:00
|
|
|
be-poetry-lock:
|
|
|
|
$(IN_BACKEND) poetry lock --no-update
|
|
|
|
|
|
|
|
be-poetry-rm:
|
|
|
|
@if [ -d "$(BACKEND_CONTAINER)/.venv" ]; then \
|
|
|
|
rm -rf "$(BACKEND_CONTAINER)/.venv"; \
|
|
|
|
fi
|
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
be-sh:
|
|
|
|
$(IN_BACKEND) /bin/bash
|
|
|
|
|
2024-02-29 14:55:09 +00:00
|
|
|
be-sqlite:
|
2024-03-26 14:56:24 +00:00
|
|
|
@if [ ! -f "$(BACKEND_CONTAINER)/$(BACKEND_SQLITE_FILE)" ]; then \
|
|
|
|
echo "SQLite database file does not exist: $(BACKEND_CONTAINER)/$(BACKEND_SQLITE_FILE)"; \
|
2024-02-29 14:55:09 +00:00
|
|
|
exit 1; \
|
|
|
|
fi
|
2024-03-26 14:56:24 +00:00
|
|
|
$(IN_BACKEND) sqlite3 $(BACKEND_SQLITE_FILE)
|
2024-02-29 14:55:09 +00:00
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
be-tests: be-clear-log-file
|
2024-03-26 14:56:24 +00:00
|
|
|
$(IN_BACKEND) poetry run pytest tests/spiffworkflow_backend/$(JUST)
|
2024-02-24 00:13:16 +00:00
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
be-tests-par: be-clear-log-file
|
2024-03-26 14:56:24 +00:00
|
|
|
$(IN_BACKEND) poetry run pytest -n auto -x --random-order tests/spiffworkflow_backend/$(JUST)
|
2024-02-23 00:31:55 +00:00
|
|
|
|
|
|
|
fe-lint-fix:
|
2024-02-24 00:13:16 +00:00
|
|
|
$(IN_FRONTEND) npm run lint:fix
|
|
|
|
|
2024-02-27 23:17:14 +00:00
|
|
|
fe-logs:
|
|
|
|
docker logs -f $(FRONTEND_CONTAINER)
|
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
fe-npm-i:
|
2024-02-28 14:49:45 +00:00
|
|
|
$(IN_FRONTEND) npm i && git checkout -- spiffworkflow-frontend/package-lock.json
|
2024-02-23 00:31:55 +00:00
|
|
|
|
|
|
|
fe-sh:
|
2024-02-24 00:13:16 +00:00
|
|
|
$(IN_FRONTEND) /bin/bash
|
|
|
|
|
2024-02-29 10:27:06 +00:00
|
|
|
poetry-i:
|
|
|
|
$(IN_ARENA) poetry install --no-root
|
|
|
|
|
2024-03-08 18:00:51 +00:00
|
|
|
poetry-rm:
|
|
|
|
@if [ -d ".venv" ]; then \
|
|
|
|
rm -rf ".venv"; \
|
|
|
|
fi
|
|
|
|
|
2024-02-27 14:13:02 +00:00
|
|
|
pre-commit:
|
|
|
|
$(IN_ARENA) poetry run pre-commit run --verbose --all-files
|
|
|
|
|
2024-03-08 18:00:51 +00:00
|
|
|
ruff:
|
|
|
|
$(IN_ARENA) poetry run ruff --fix spiffworkflow-backend
|
|
|
|
|
|
|
|
run-pyl: fe-lint-fix ruff pre-commit be-mypy be-tests-par
|
2024-02-27 14:13:02 +00:00
|
|
|
@/bin/true
|
|
|
|
|
|
|
|
sh:
|
|
|
|
$(IN_ARENA) /bin/bash
|
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
take-ownership:
|
2024-02-27 14:13:02 +00:00
|
|
|
$(SUDO) chown -R $(ME) .
|
2024-02-23 00:31:55 +00:00
|
|
|
|
2024-02-24 00:13:16 +00:00
|
|
|
.PHONY: build-images dev-env \
|
|
|
|
start-dev stop-dev \
|
2024-03-08 18:00:51 +00:00
|
|
|
be-clear-log-file be-logs be-mypy be-poetry-i be-poetry-lock be-poetry-rm \
|
2024-04-02 12:50:49 +00:00
|
|
|
be-db-clean be-db-migrate be-sh be-sqlite be-tests be-tests-par \
|
2024-02-27 23:17:14 +00:00
|
|
|
fe-lint-fix fe-logs fe-npm-i fe-sh \
|
2024-03-08 18:00:51 +00:00
|
|
|
poetry-i poetry-rm pre-commit ruff run-pyl \
|
2024-02-24 00:13:16 +00:00
|
|
|
take-ownership
|