Something went wrong. Try again.
The social RSS reader. Built on AT Protocol. glean.at
app glean atproto atmosphere rss feed social
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134# Add `go install` bin dir to PATH so tools installed via `make tools-install`# (golangci-lint, go-crap) are found by later make targets in CI environments# where the default PATH does not include $(go env GOPATH)/bin.export PATH := $(shell go env GOPATH)/bin:$(PATH)
.PHONY: tools-installtools-install: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest go install github.com/padiazg/go-crap@latest
.PHONY: lintlint: go vet ./... go fix ./... test -z "$(shell gofmt -l ./...)" golangci-lint run ./... --fix
.PHONY: web-installweb-install: bun install cd web && bun install
# Local loop is the production topology: Worker + Container via wrangler.# Docker must be running. Secrets live in .dev.vars..PHONY: devdev: web-build bun run dev
.PHONY: web-buildweb-build: cd web && bun run build
.PHONY: buildbuild: web-build go build ./...
.PHONY: iconsicons: magick web/static/favicon.svg -background none -density 1200 -resize 512x512 -depth 8 PNG32:web/static/favicon.png magick web/static/favicon.svg -background none -density 1200 -resize 180x180 -depth 8 PNG32:web/static/apple-touch-icon.png
.PHONY: lex-lintlex-lint: goat lex lint
.PHONY: lex-parselex-parse: goat lex parse $(shell find lexicons -name '*.json' 2>/dev/null)
.PHONY: testtest: go test ./...
# CRAP score analysis (cyclomatic complexity x coverage)..PHONY: crapcrap: go-crap scan --fail-above --threshold 450
.PHONY: checkcheck: cd web && bun run check
.PHONY: cleanclean: rm -rf web/.svelte-kit .wrangler
# wrangler deploy can exit 0 without applying container changes (seen on# 4.128/4.129): the Worker version activates but the container application is# never assigned, and every /api request then fails with "There is no container# application assigned to this Durable Object namespace". Retry until the# version line confirms the upload, then poll /ready so that state fails the# deploy loudly; a redeploy re-creates the missing container application.## Every deploy pushes a new image tag to the registry (tags are content hashes,# so an unchanged build reuses its tag); without pruning they accumulate# forever. After a VERIFIED deploy, the just-pushed tag is identified as "the# tag present after the deploy that was absent before it" and every other# tag is deleted. Rollback therefore means `git revert && make deploy` (the# image rebuilds from source), not `wrangler rollback`. Any ambiguity —# nothing new pushed, or more than one new tag — prunes nothing..PHONY: deploydeploy: web-build @url=$$(grep -o '"GLEAN_FRONTEND_URL": "[^"]*"' wrangler.jsonc | cut -d'"' -f4); \ before=$$(CI=true bunx wrangler containers images list --json 2>/dev/null | grep -oE '"[0-9a-f]{8}"' | tr -d '"' | sort); \ ok=0; \ for i in 1 2 3 4 5; do \ out=$$(bunx wrangler deploy 2>&1); \ echo "$$out"; \ if echo "$$out" | grep -q 'Current Version ID'; then \ for j in 1 2 3 4 5 6 7 8 9 10 11 12; do \ code=$$(curl -s -o /dev/null -w '%{http_code}' "$$url/ready" || echo 000); \ if [ "$$code" = "204" ]; then echo "deploy verified: $$url/ready is up"; ok=1; break 2; fi; \ sleep 5; \ done; \ echo "deploy uploaded but /ready never returned 204 (last status $$code), retrying"; \ else \ echo "deploy did not complete, retrying in 3s..."; \ sleep 3; \ fi; \ done; \ [ "$$ok" = "1" ] || { echo "ERROR: deploy never completed"; exit 1; }; \ after=$$(CI=true bunx wrangler containers images list --json 2>/dev/null | grep -oE '"[0-9a-f]{8}"' | tr -d '"' | sort); \ new=$$(comm -13 <(echo "$$before") <(echo "$$after")); \ if [ -z "$$before" ] || [ -z "$$new" ] || [ "$$(echo "$$new" | wc -l)" -gt 1 ]; then \ echo "image prune skipped: deployed tag not uniquely identifiable (unchanged build, or registry diff ambiguous)"; \ exit 0; \ fi; \ echo "keeping image tag: $$new"; \ for tag in $$after; do \ [ "$$tag" = "$$new" ] && continue; \ echo "deleting stale image $$tag"; \ CI=true bunx wrangler containers images delete "glean-gleancontainer:$$tag" || true; \ done
# Teardown: delete every Cloudflare resource this project creates — the# Worker, the container application and its registry images, the D1 database# (ALL DATA, irreversible), the R2 archive bucket, and both Vectorize indexes.# Deleting the Worker does not remove its container application, which would# keep one instance running and billing forever. Idempotent..PHONY: teardownteardown: CI=true bunx wrangler delete --name glean || true @for id in $$(CI=true bunx wrangler containers list 2>/dev/null | grep glean-gleancontainer | awk '{print $$2}'); do \ CI=true bunx wrangler containers delete $$id || true; \ done @for tag in $$(CI=true bunx wrangler containers images list 2>/dev/null | grep glean-gleancontainer | awk '{print $$2}'); do \ CI=true bunx wrangler containers images delete glean-gleancontainer:$$tag || true; \ done CI=true bunx wrangler d1 delete glean -y || true CI=true bunx wrangler r2 bucket delete glean-archive || true CI=true bunx wrangler vectorize delete glean-articles -y || true CI=true bunx wrangler vectorize delete glean-feeds -y || true @echo "teardown complete: worker, container, images, d1, r2, vectorize deleted"