build: rq

GO=go

.PHONY: build
build: rq

.PHONY: rq
# uncomment for stripped binaries:
rq: build_dir
	$(GO) build -o "./build/$@" -ldflags="-s -w" ./cmd/rq
# uncomment for regular binaries:
#rq:
#        $(GO) build -o "$@" ./cmd/rq

.PHONY: build_dir
build_dir:
	mkdir -p ./build

.PHONY: test
test: rq
	TZ=UTC $(GO) test -timeout 30s ./...
	TZ=UTC sh ./smoketest/smoketest.sh

.PHONY: fmt
fmt:
	$(GO) fmt ./...

# The sourcehut builders don't have enough memory to run nilaway, so we skip
# those in CI.
.PHONY: ci_lint
ci_lint:
	golangci-lint run ./...
	govulncheck ./...

.PHONY: lint
lint: ci_lint
	nilaway ./...

.PHONY: coverage
coverage:
	TZ=UTC $(GO) test -timeout 30s -coverprofile /dev/null ./...

.PHONY: viewcoverage
viewcoverage:
	TZ=UTC $(GO) test -timeout 30s -coverprofile cover.out ./...
	TZ=UTC $(GO) tool cover -html=cover.out

.PHONY: benchmark
benchmark:
	TZ=UTC $(GO) test -bench=.

.PHONY: install
install:
	$(GO) install ./...

.PHONY: capabilities
capabilities: rq
	./build/rq capabilities > capabilities.json

.PHONY: clean
clean:
	rm -f ./cover.out
	rm -rf ./build

