sky/Makefile
root 6ed55254a0 chore: initial import of sky project
Go + PostgreSQL + Valkey backend (cmd/internal/migrations),
uni-app mobile frontend, PC web (web/), admin console (admin/),
Android WebView container (android_project/).
Build artifacts, node_modules, local env and debug screenshots excluded.
2026-11-09 22:22:44 +08:00

119 lines
3.5 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 内容平台 V4 — 常用命令
# 用 make 而非零散脚本:所有操作有唯一入口,新人不靠口口相传
SHELL := /bin/bash
API_ADDR ?= http://127.0.0.1:18080
.PHONY: help build build-api build-worker test smoke load clean \
dev-db dev-redis dev-api dev-worker migrate docker-up docker-down fmt vet
help:
@echo "内容平台 V4"
@echo ""
@echo " make build 编译 api 与 worker"
@echo " make test 运行 Go 单元测试"
@echo " make smoke 端到端冒烟测试(需服务已启动)"
@echo " make load 并发压测"
@echo " make ui UI 冒烟(Playwright 真渲染)"
@echo " make test-all 单元 + 端到端 + UI 全跑"
@echo " make vet 静态检查"
@echo " make fmt 格式化"
@echo ""
@echo " 本地开发:"
@echo " make dev-db 启动隔离 PG(端口 55432)"
@echo " make dev-redis 启动隔离 Redis(端口 56379)"
@echo " make migrate 应用迁移"
@echo " make dev-api 启动 API"
@echo " make dev-worker 启动 worker"
@echo ""
@echo " 前端:"
@echo " make web-install 安装前端依赖"
@echo " make web-dev 启动前端 dev server (:3100)"
@echo " make web-build 构建前端产物"
@echo ""
@echo " 容器编排:"
@echo " make docker-up docker compose up -d"
@echo " make docker-down docker compose down"
build: build-api build-worker
build-api:
@echo "→ 编译 api"
@CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o ./_api.exe ./cmd/api
build-worker:
@echo "→ 编译 worker"
@CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o ./_worker.exe ./cmd/worker
test:
@go test ./... -count=1
vet:
@go vet ./...
fmt:
@gofmt -l -w cmd internal
smoke:
@python scripts/smoke.py
load:
@python scripts/loadtest.py
ui:
@node scripts/ui_check.mjs
test-all: test smoke ui
@echo "全部测试通过"
# ── 本地开发环境(Windows 友好,不依赖 Docker Desktop) ──
PGBIN ?= C:/Program Files/PostgreSQL/16/bin
PGPORT ?= 55432
dev-db:
@test -d .devdb || "$(PGBIN)/initdb" -D ./.devdb -U postgres --auth=trust --encoding=UTF8 --locale=C
@"$(PGBIN)/pg_ctl" -D ./.devdb -o "-p $(PGPORT) -c listen_addresses=127.0.0.1" -l ./.devdb.log start || true
@sleep 3
@"$(PGBIN)/psql" -h 127.0.0.1 -p $(PGPORT) -U postgres -tc "SELECT 1 FROM pg_database WHERE datname='article_platform'" | grep -q 1 || \
"$(PGBIN)/psql" -h 127.0.0.1 -p $(PGPORT) -U postgres -c "CREATE DATABASE article_platform"
@echo "PG 就绪: 127.0.0.1:$(PGPORT)"
dev-redis:
@.devtools/redis/Redis-8.0.2-Windows-x64-msys2/redis-server.exe --port 56379 \
--bind 127.0.0.1 --save "" --appendonly no > .redis.log 2>&1 &
@sleep 2
@.devtools/redis/Redis-8.0.2-Windows-x64-msys2/redis-cli.exe -p 56379 PING
migrate:
@python -c "s=open('migrations/00001_init.sql',encoding='utf-8').read(); \
open('_init_up.sql','w',encoding='utf-8').write(s.split('-- +goose Up',1)[1].split('-- +goose Down',1)[0])"
@"$(PGBIN)/psql" -h 127.0.0.1 -p $(PGPORT) -U postgres -d article_platform -v ON_ERROR_STOP=1 -f _init_up.sql
@rm -f _init_up.sql
dev-api: build-api
@set -a; source .env; set +a; ./_api.exe
dev-worker: build-worker
@set -a; source .env; set +a; ./_worker.exe
# ── 前端 ──
web-install:
@cd web && npm install
web-dev:
@cd web && npm run dev
web-build:
@cd web && npm run build
docker-up:
@docker compose up -d --build
@docker compose ps
docker-down:
@docker compose down
clean:
@rm -f _api.exe _worker.exe _api.log _worker.log _init_up.sql
@rm -rf _build_api.exe