2024-05-31 19:10:01 +00:00
|
|
|
USER_ID ?= $(shell id -u)
|
|
|
|
USER_NAME ?= $(shell id -un)
|
|
|
|
GROUP_ID ?= $(shell id -g)
|
|
|
|
GROUP_NAME ?= $(shell id -gn)
|
|
|
|
ME ?= $(USER_ID):$(GROUP_ID)
|
2024-02-24 00:13:16 +00:00
|
|
|
|
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-05-24 18:04:41 +00:00
|
|
|
IN_ARENA ?= $(DOCKER_COMPOSE) run --rm $(ARENA_CONTAINER)
|
|
|
|
IN_BACKEND ?= $(DOCKER_COMPOSE) run --rm $(BACKEND_CONTAINER)
|
|
|
|
IN_FRONTEND ?= $(DOCKER_COMPOSE) run --rm $(FRONTEND_CONTAINER)
|
2024-02-24 00:13:16 +00:00
|
|
|
|
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
|
2024-04-17 18:04:07 +00:00
|
|
|
NODE_MODULES_DIR ?= spiffworkflow-frontend/node_modules
|
2024-03-26 14:56:24 +00:00
|
|
|
JUST ?=
|
2024-06-24 12:01:08 +00:00
|
|
|
ARGS ?=
|
2024-03-26 14:56:24 +00:00
|
|
|
|
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-04-08 16:00:44 +00:00
|
|
|
@true
|
2024-02-24 00:13:16 +00:00
|
|
|
|
|
|
|
build-images:
|
2024-05-31 19:10:01 +00:00
|
|
|
$(DOCKER_COMPOSE) build \
|
|
|
|
--build-arg USER_ID=$(USER_ID) \
|
|
|
|
--build-arg USER_NAME=$(USER_NAME) \
|
|
|
|
--build-arg GROUP_ID=$(GROUP_ID) \
|
|
|
|
--build-arg GROUP_NAME=$(GROUP_NAME) \
|
|
|
|
$(JUST)
|
2024-02-24 00:13:16 +00:00
|
|
|
|
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-04-08 16:00:44 +00:00
|
|
|
@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
|
|
|
|
2024-07-30 13:58:03 +00:00
|
|
|
start-event-stream:
|
|
|
|
$(DOCKER_COMPOSE) up -d event-stream
|
|
|
|
|
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-06-24 12:01:08 +00:00
|
|
|
$(IN_BACKEND) poetry run pytest $(ARGS) 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-06-24 12:01:08 +00:00
|
|
|
$(IN_BACKEND) poetry run pytest -n auto -x --random-order $(ARGS) 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-04-22 15:25:32 +00:00
|
|
|
fe-npm-clean:
|
|
|
|
@if [ -d "$(NODE_MODULES_DIR)" ]; then \
|
|
|
|
rm -rf "$(NODE_MODULES_DIR)"; \
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
2024-04-17 18:04:07 +00:00
|
|
|
fe-npm-rm:
|
2024-04-22 15:25:32 +00:00
|
|
|
$(IN_FRONTEND) npm rm $(JUST)
|
2024-04-17 18:04:07 +00:00
|
|
|
|
2024-02-23 00:31:55 +00:00
|
|
|
fe-sh:
|
2024-02-24 00:13:16 +00:00
|
|
|
$(IN_FRONTEND) /bin/bash
|
|
|
|
|
2024-04-10 16:05:29 +00:00
|
|
|
fe-unimported:
|
|
|
|
$(IN_FRONTEND) npx unimported
|
|
|
|
|
2024-05-31 19:10:01 +00:00
|
|
|
git-debranch:
|
|
|
|
$(IN_ARENA) poetry run git-debranch
|
|
|
|
|
|
|
|
git-debranch-offline:
|
|
|
|
$(IN_ARENA) poetry run git-debranch --offline
|
|
|
|
|
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:
|
2024-04-10 16:44:13 +00:00
|
|
|
$(IN_ARENA) poetry run ruff check --fix spiffworkflow-backend
|
2024-03-08 18:00:51 +00:00
|
|
|
|
|
|
|
run-pyl: fe-lint-fix ruff pre-commit be-mypy be-tests-par
|
2024-04-08 16:00:44 +00:00
|
|
|
@true
|
2024-02-27 14:13:02 +00:00
|
|
|
|
|
|
|
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-07-26 15:52:03 +00:00
|
|
|
include event-stream/demo.mk
|
|
|
|
|
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-04-22 15:25:32 +00:00
|
|
|
fe-lint-fix fe-logs fe-npm-clean fe-npm-i fe-npm-rm fe-sh fe-unimported \
|
2024-05-31 19:10:01 +00:00
|
|
|
git-debranch git-debranch-offline \
|
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
|