You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.8 KiB
Makefile
68 lines
1.8 KiB
Makefile
SQL_DATABASE?=./pulley.db
|
|
COVER_PROFILE?=./tmp/profile.out
|
|
|
|
# TODO maybe only use -race in an ARG for CI
|
|
FLAGS := -race -v
|
|
|
|
# `make <target> ARGS=no-cache` will avoid using cached results in go test.
|
|
ifeq ($(ARGS), no-cache)
|
|
FLAGS += -count=1
|
|
endif
|
|
|
|
# make test ARGS=no-cache
|
|
test:
|
|
go test $(FLAGS) ./...
|
|
.PHONY: test
|
|
|
|
test-short:
|
|
go test -short $(FLAGS) ./...
|
|
.PHONY: test-short
|
|
|
|
# make test-int ARGS=no-cache
|
|
test-int:
|
|
go test $(FLAGS) ./cmd/...
|
|
.PHONY: test-int
|
|
|
|
## Coverage See also -covermode=count and -covermode=atomic
|
|
cover-html: test-cover
|
|
go tool cover -html=$(COVER_PROFILE)
|
|
.PHONY:cover-html
|
|
|
|
coverage: test-cover
|
|
go tool cover -func=$(COVER_PROFILE)
|
|
.PHONY: coverage
|
|
|
|
test-cover:
|
|
go test -coverprofile=$(COVER_PROFILE) $(FLAGS) ./...
|
|
.PHONY: test-cover
|
|
|
|
serve:
|
|
go run ./cmd/api/...
|
|
.PHONY: serve
|
|
|
|
# SQLite Commands
|
|
sql-cli:
|
|
sqlite3 $(SQL_DATABASE) -cmd ".headers on" -cmd ".mode box" -cmd ".tables"
|
|
.PHONY: sql-cli
|
|
|
|
init-db: run-migrate
|
|
sqlite3 $(SQL_DATABASE) "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
|
|
.PHONY: init-db
|
|
|
|
run-migrate:
|
|
migrate -database sqlite3://$(SQL_DATABASE) -path ./migrations up
|
|
.PHONY: run-migrate
|
|
|
|
# Checks system dependencies needed to run the local dev environment
|
|
check-system-deps:
|
|
@echo "Checking system dependencies..."
|
|
@command -v air > /dev/null || (echo "Missing air command. go install github.com/air-verse/air@latest"; exit 1)
|
|
@command -v sqlite3 > /dev/null || (echo "Missing sqlite3 command. brew install sqlite"; exit 1)
|
|
@command -v migrate > /dev/null || (echo "Missing migrate command. go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"; exit 1)
|
|
@echo "System dependencies fulfilled 👍"
|
|
.PHONY: check-system-deps
|
|
# Certs
|
|
|
|
local-certs:
|
|
cd ./tls && go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
|
|
.PHONY: local-certs |