A Telegram Mini App served by the core under /app/, embedded in the binary. - API under /app/api/ with initData validated (HMAC, age) on every call - Pages: Home, Queue, Buy (target, product, invoice), History, Groups, group detail (Overview, Settings, Wallet, Usage) and Me - Every action runs through the same service, billing and scheduler code as the chat, so limits, prices and admin checks are decided on the server - Texts come from the catalog over the API; layout mirrors for RTL - Front end in web/miniapp (Vite, React, TypeScript); the build is committed and guarded by a source hash test; the Docker image rebuilds it - MINIAPP_ENABLED with an https PUBLIC_URL; entry points from /app, group settings and the over-limit offer - Browser test (make miniapp-e2e) against a core in test mode - Fix: each download attempt gets its own scratch directory, so a retry cannot lose its file to the cleanup of the failed attempt Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
63 lines
1.9 KiB
Makefile
63 lines
1.9 KiB
Makefile
GO ?= go
|
|
BIN := bin
|
|
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
|
|
|
.PHONY: all build faketelegram miniapp miniapp-e2e test test-postgres race vet fmt check run e2e acceptance clean
|
|
|
|
all: check build
|
|
|
|
build:
|
|
$(GO) build -trimpath -ldflags "-s -w" -o $(BIN)/core ./cmd/core
|
|
$(GO) build -trimpath -ldflags "-s -w" -o $(BIN)/worker ./cmd/worker
|
|
|
|
# Fake Telegram Bot API, for trying the bot without a token.
|
|
faketelegram:
|
|
$(GO) build -o $(BIN)/faketelegram ./cmd/faketelegram
|
|
|
|
# Rebuild the Mini App front end into web/miniapp/dist, which the core
|
|
# embeds. Needed only after changing web/miniapp; commit dist with the change.
|
|
miniapp:
|
|
cd web/miniapp && npm ci --no-audit --no-fund && npm run build
|
|
|
|
# Click through the Mini App in headless Chromium against a core in test
|
|
# mode. Needs "make miniapp" once, and a browser: see web/miniapp/e2e/run.sh.
|
|
miniapp-e2e:
|
|
web/miniapp/e2e/run.sh
|
|
|
|
test:
|
|
$(GO) test ./...
|
|
|
|
race:
|
|
$(GO) test -race -count=1 ./...
|
|
|
|
vet:
|
|
$(GO) vet ./...
|
|
|
|
fmt:
|
|
@out="$$(gofmt -l .)"; if [ -n "$$out" ]; then echo "gofmt needed on:"; echo "$$out"; exit 1; fi
|
|
|
|
# Everything CI runs.
|
|
check: fmt vet race
|
|
|
|
run: build
|
|
./$(BIN)/core
|
|
|
|
# The same test suite against Postgres. Point PG_DSN at an empty database;
|
|
# each test creates and drops its own schema in it.
|
|
# make test-postgres PG_DSN=postgres://user:pass@127.0.0.1:5432/dlbot_test?sslmode=disable
|
|
test-postgres:
|
|
@test -n "$(PG_DSN)" || { echo "set PG_DSN, see the comment in the Makefile"; exit 1; }
|
|
DLBOT_TEST_DB=postgres DLBOT_TEST_PG_DSN="$(PG_DSN)" $(GO) test -count=1 ./...
|
|
|
|
# Kill a worker mid-job and watch the other one finish it. MODE=compose
|
|
# runs it in containers.
|
|
acceptance:
|
|
deploy/acceptance/kill-worker.sh
|
|
|
|
# End-to-end test with the real yt-dlp and ffmpeg. Needs network access.
|
|
e2e:
|
|
DLBOT_E2E_YTDLP=$${YTDLP_PATH:-$$(command -v yt-dlp)} $(GO) test -count=1 -v -run TestRealYtDlp ./internal/app
|
|
|
|
clean:
|
|
rm -rf $(BIN)
|