nandi/gleanpublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Makefile · 106 lines · 3.1 KBMakefile Blame HistoryRaw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
SQLITE3_VER := $(shell grep 'mattn/go-sqlite3' go.mod | awk '{print $$2}')
SQLITE3_INC := $(shell go env GOMODCACHE)/github.com/mattn/go-sqlite3@$(SQLITE3_VER)
export CGO_CFLAGS := -I$(CURDIR)/internal/db/include -I$(SQLITE3_INC)

# 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-install
tools-install:
	go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
	go install github.com/padiazg/go-crap@latest

.PHONY: lint
lint:
	go vet ./...
	go fix ./...
	test -z "$(shell gofmt -l ./...)"
	golangci-lint run ./... --fix

.PHONY: web-install
web-install:
	cd web && bun install

# Run the Go API (backend) and the SvelteKit dev server (frontend) together.
# The frontend proxies /api requests to the Go server (GLEAN_API_URL).
.PHONY: dev
dev:
	@if [ -f .env ]; then set -a; . ./.env; set +a; fi; \
	GLEAN_FRONTEND_URL="$${GLEAN_FRONTEND_URL:-http://localhost:3000}"; \
	echo "Starting Go API on :8080 and SvelteKit on :3000 (Ctrl-C stops both)..."; \
	GLEAN_API_URL=http://localhost:8080 GLEAN_FRONTEND_URL=$$GLEAN_FRONTEND_URL go run -tags fts5 . & \
	GO_PID=$$!; \
	trap 'kill $$GO_PID 2>/dev/null' INT TERM EXIT; \
	(cd web && GLEAN_API_URL=http://localhost:8080 bun run dev); \
	kill $$GO_PID 2>/dev/null || true

.PHONY: dev-api
dev-api:
	@if [ -f .env ]; then set -a; . ./.env; set +a; fi; \
	GLEAN_FRONTEND_URL="$${GLEAN_FRONTEND_URL:-http://localhost:3000}" go run -tags fts5 .

.PHONY: dev-web
dev-web:
	cd web && GLEAN_API_URL=http://localhost:8080 bun run dev

.PHONY: web-build
web-build:
	cd web && bun run build

.PHONY: build
build: web-build
	go build -tags fts5 -o glean .

.PHONY: icons
icons:
	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-lint
lex-lint:
	goat lex lint

.PHONY: lex-parse
lex-parse:
	goat lex parse $(shell find lexicons -name '*.json' 2>/dev/null)

.PHONY: test
test:
	go test -tags fts5 ./...

# CRAP score analysis (cyclomatic complexity x coverage).
# The fts5 build tag is required for the test build, so it's exported via GOFLAGS
# for the underlying `go test -cover` run go-crap performs.
.PHONY: crap
crap:
	GOFLAGS=-tags=fts5 go-crap scan --fail-above --threshold 450

.PHONY: check
check:
	cd web && bun run check

.PHONY: clean
clean:
	rm -f glean glean.db $(IMAGE_TAR)
	rm -rf web/build web/.svelte-kit

# Container image: built by Nix (flake.nix `image` output, dockerTools
# streamLayeredImage). scripts/build-image.sh builds locally when `nix` is
# present and otherwise on the remote builder in $GLEAN_NIX_VM.
IMAGE ?= atcr.io/julien.rbrt.fr/glean:latest
IMAGE_TAR ?= glean-image.tar

.PHONY: image
image:
	scripts/build-image.sh $(IMAGE_TAR)

.PHONY: image-load
image-load: image
	docker load < $(IMAGE_TAR)
	docker tag glean:latest $(IMAGE)

.PHONY: image-push
image-push: image-load
	docker push $(IMAGE)