export SHELL := /bin/bash
export PATH := $(PWD)/bin:$(PWD):$(PATH)
export GOBIN := $(PWD)/bin

# Default to not using any 3P proxies
export GOPROXY := direct
export GOPRIVATE := *

default: build lint test

ci:
	./ci.sh
.PHONY: ci

# Verify dependencies and test code building
build:
	go mod verify
	go build -mod=readonly ./...
.PHONY: build

# Install lint tools into GOBIN
install-tools:
	@mkdir -p bin
	go install github.com/mgechev/revive
	go install github.com/golangci/golangci-lint/cmd/golangci-lint
.PHONY: install-tools

# Run lints
lint: install-tools
	golangci-lint run --config .golangci.yml
.PHONY: lint

# Run go tests with the race detector
test:
	go test -race ./...
.PHONY: test

# Run this one time to add lint dependencies to go.mod
add-lint-dependencies:
	go get github.com/mgechev/revive@88015ccf8e97dec79f401f2628aa199f8fe8cb10
	go get github.com/golangci/golangci-lint@v1.21.0
.PHONY: add-lint-dependencies
