test
3.8 kB
126 lines
1
2SHELL = /usr/bin/env bash
3.SHELLFLAGS = -o pipefail -c
4
5# base path for Lexicon document tree (for lexgen)
6LEXDIR?=./lexicons
7
8# https://github.com/golang/go/wiki/LoopvarExperiment
9export GOEXPERIMENT := loopvar
10
11.PHONY: help
12help: ## Print info about all commands
13 @echo "Commands:"
14 @echo
15 @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[01;32m%-20s\033[0m %s\n", $$1, $$2}'
16
17.PHONY: build
18build: ## Build all executables
19 go build ./cmd/gosky
20 go build ./cmd/relay
21 go build ./cmd/beemo
22 go build ./cmd/lexgen
23 go build ./cmd/stress
24 go build ./cmd/fakermaker
25 go build ./cmd/hepa
26 go build -o ./sonar-cli ./cmd/sonar
27 go build ./cmd/tap
28
29.PHONY: all
30all: build
31
32.PHONY: test
33test: ## Run tests
34 go test ./...
35
36.PHONY: test-short
37test-short: ## Run tests, skipping slower integration tests
38 go test -test.short ./...
39
40.PHONY: test-interop
41test-interop: ## Run tests, including local interop (requires services running)
42 go clean -testcache && go test -tags=localinterop ./...
43
44.PHONY: test-search
45test-search: ## Run tests, including local search indexing (requires services running)
46 go clean -testcache && go test -tags=localsearch ./...
47
48.PHONY: coverage-html
49coverage-html: ## Generate test coverage report and open in browser
50 go test ./... -coverpkg=./... -coverprofile=test-coverage.out
51 go tool cover -html=test-coverage.out
52
53.PHONY: lint
54lint: ## Verify code style and run static checks
55 go vet ./...
56 test -z $(gofmt -l ./...)
57
58.PHONY: fmt
59fmt: ## Run syntax re-formatting (modify in place)
60 go fmt ./...
61
62.PHONY: check
63check: ## Compile everything, checking syntax (does not output binaries)
64 go build ./...
65
66.PHONY: lexgen
67lexgen: ## Run codegen tool for lexicons (lexicon JSON to Go packages)
68 go run ./cmd/lexgen/ --build-file cmd/lexgen/bsky.json $(LEXDIR)
69
70.PHONY: lexgen-ext
71lexgen-ext: ## Run codegen tool for lexicons (lexicon JSON to Go packages)
72 go run ./cmd/lexgen/ --build-file cmd/lexgen/ext.json $(LEXDIR)
73
74.PHONY: cborgen
75cborgen: ## Run codegen tool for CBOR serialization
76 go run ./gen
77
78.env:
79 if [ ! -f ".env" ]; then cp example.dev.env .env; fi
80
81.PHONY: run-dev-relay
82run-dev-relay: .env ## Runs relay for local dev
83 LOG_LEVEL=info go run ./cmd/relay --admin-password localdev serve
84
85.PHONY: run-dev-ident
86run-dev-ident: .env ## Runs 'bluepages' identity directory for local dev
87 GOLOG_LOG_LEVEL=info go run ./cmd/bluepages serve
88
89.PHONY: build-relay-image
90build-relay-image: ## Builds relay docker image
91 docker build -t relay -f cmd/relay/Dockerfile .
92
93.PHONY: build-relay-admin-ui
94build-relay-admin-ui: ## Build relay admin web UI
95 cd cmd/relay/relay-admin-ui; yarn install --frozen-lockfile; yarn build
96 mkdir -p public
97 cp -r cmd/relay/relay-admin-ui/dist/* public/
98
99.PHONY: run-relay-image
100run-relay-image:
101 docker run -p 2470:2470 relay /relay serve --admin-password localdev
102# --crawl-insecure-ws
103
104.PHONY: sonar-up
105sonar-up: # Runs sonar docker container
106 docker compose -f cmd/sonar/docker-compose.yml up --build -d || docker-compose -f cmd/sonar/docker-compose.yml up --build -d
107
108.PHONY: run-netsync
109run-netsync: .env ## Runs netsync for local dev
110 go run ./cmd/netsync --checkout-limit 100 --worker-count 100 --out-dir ../netsync-out
111
112SCYLLA_VERSION := latest
113SCYLLA_CPU := 0
114SCYLLA_NODES := 127.0.0.1:9042
115
116.PHONY: run-scylla
117run-scylla:
118 @echo "==> Running test instance of Scylla $(SCYLLA_VERSION)"
119 @docker pull scylladb/scylla:$(SCYLLA_VERSION)
120 @docker run --name scylla -p 9042:9042 --cpuset-cpus=$(SCYLLA_CPU) --memory 1G --rm -d scylladb/scylla:$(SCYLLA_VERSION)
121 @until docker exec scylla cqlsh -e "DESCRIBE SCHEMA"; do sleep 2; done
122
123.PHONY: stop-scylla
124stop-scylla:
125 @echo "==> Stopping test instance of Scylla $(SCYLLA_VERSION)"
126 @docker stop scylla