Files
stpweb/Makefile
T
adamfandClaude Opus 5.5 4530cb8dc4
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s
Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo,
keep short ones for security boundaries, upstream quirks and ordering
constraints, and record the convention in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:49:03 +00:00

78 lines
2.9 KiB
Makefile

# `make check` before pushing; `make help` lists targets. A missing toolchain
# fails only the targets that need it.
.DEFAULT_GOAL := help
PYTHON ?= python3
# At the root, not in python/, which is a docker build context.
VENV := .venv
# Re-installs only when a requirements file changes.
VENV_STAMP := $(VENV)/.installed
.PHONY: help check check-backend check-python check-vue check-compose check-caddy generate dev
help:
@echo "Targets:"
@echo " make check run every check below"
@echo " make check-backend go vet + go test in backend/"
@echo " make check-python pytest in python/ (venv created on demand in $(VENV)/)"
@echo " make check-vue vite build of vue/ into a throwaway directory"
@echo " make check-compose validate docker-compose.yml, alone and with the dev override"
@echo " make check-caddy build the Caddy image, which validates caddy/ for prod and dev"
@echo " make generate regenerate the gqlgen GraphQL code after a schema edit"
@echo " make dev build and run the dev stack (http://localhost)"
check: check-backend check-python check-vue check-compose check-caddy
check-backend:
cd backend && go vet ./... && go test ./...
# Recreated from scratch so packages dropped from the files don't linger.
$(VENV_STAMP): python/requirements.txt python/requirements-dev.txt
rm -rf $(VENV)
$(PYTHON) -m venv $(VENV)
$(VENV)/bin/python -m pip install --quiet --upgrade pip
$(VENV)/bin/python -m pip install --quiet -r python/requirements-dev.txt
touch $@
check-python: $(VENV_STAMP)
cd python && ../$(VENV)/bin/python -m pytest tests -q
# Builds into a temp directory, so vue/dist is never touched.
check-vue:
@test -d vue/node_modules || { \
echo "check-vue: vue/node_modules/ is missing. Run: cd vue && npm install"; \
exit 1; }
@out=$$(mktemp -d) && trap 'rm -rf "$$out"' EXIT && \
cd vue && npx vite build --outDir "$$out" --emptyOutDir
# Without a .env, validates against a temp project dir holding .env.example
# (compose refuses a missing env_file, and a blank OBSIDIAN_DIR is an invalid
# bind mount). A real .env is never created.
check-compose:
@set -e; \
if [ -f .env ]; then \
pd="."; \
else \
echo "check-compose: no .env, validating against .env.example"; \
pd=$$(mktemp -d); trap 'rm -rf "$$pd"' EXIT; \
cp .env.example "$$pd/.env"; \
echo "OBSIDIAN_DIR=/placeholder/obsidian" >> "$$pd/.env"; \
fi; \
echo "docker compose -f docker-compose.yml config -q"; \
docker compose --project-directory "$$pd" -f docker-compose.yml config -q; \
echo "docker compose -f docker-compose.yml -f docker-compose.dev.yml config -q"; \
docker compose --project-directory "$$pd" -f docker-compose.yml -f docker-compose.dev.yml config -q
# The image build runs `caddy validate` for both modes.
check-caddy:
docker build -q -t web_server-caddy:check caddy/
generate:
cd backend && go run github.com/99designs/gqlgen generate
dev:
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build