Skip to content

Commit

Permalink
nicer make default (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris authored Sep 24, 2024
1 parent c01a101 commit 9866063
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
# Heavily inspired by Lighthouse: https://github.com/sigp/lighthouse/blob/stable/Makefile
# and Reth: https://github.com/paradigmxyz/reth/blob/main/Makefile
.DEFAULT_GOAL := help

VERSION := $(shell git describe --tags --always --dirty="-dev")

.PHONY: all
all: clean build
##@ Help

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: v
v:
v: ## Show the version
@echo "Version: ${VERSION}"

##@ Build

.PHONY: clean
clean:
clean: ## Clean the build directory
rm -rf build/

.PHONY: build-cli
build-cli:
build-cli: ## Build the CLI
@mkdir -p ./build
go build -trimpath -ldflags "-X github.com/flashbots/go-template/common.Version=${VERSION}" -v -o ./build/cli cmd/cli/main.go

.PHONY: build-httpserver
build-httpserver:
build-httpserver: ## Build the HTTP server
@mkdir -p ./build
go build -trimpath -ldflags "-X github.com/flashbots/go-template/common.Version=${VERSION}" -v -o ./build/httpserver cmd/httpserver/main.go

##@ Test & Development

.PHONY: test
test:
test: ## Run tests
go test ./...

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

.PHONY: lint
lint:
lint: ## Run linters
gofmt -d -s .
gofumpt -d -extra .
go vet ./...
Expand All @@ -39,33 +50,33 @@ lint:
nilaway ./...

.PHONY: fmt
fmt:
fmt: ## Format the code
gofmt -s -w .
gci write .
gofumpt -w -extra .
go mod tidy

.PHONY: gofumpt
gofumpt:
gofumpt: ## Run gofumpt
gofumpt -l -w -extra .

.PHONY: lt
lt: lint test
lt: lint test ## Run linters and tests

.PHONY: cover
cover:
cover: ## Run tests with coverage
go test -coverprofile=/tmp/go-sim-lb.cover.tmp ./...
go tool cover -func /tmp/go-sim-lb.cover.tmp
unlink /tmp/go-sim-lb.cover.tmp

.PHONY: cover-html
cover-html:
cover-html: ## Run tests with coverage and open the HTML report
go test -coverprofile=/tmp/go-sim-lb.cover.tmp ./...
go tool cover -html=/tmp/go-sim-lb.cover.tmp
unlink /tmp/go-sim-lb.cover.tmp

.PHONY: docker-cli
docker-cli:
docker-cli: ## Build the CLI Docker image
DOCKER_BUILDKIT=1 docker build \
--platform linux/amd64 \
--build-arg VERSION=${VERSION} \
Expand All @@ -74,7 +85,7 @@ docker-cli:
.

.PHONY: docker-httpserver
docker-httpserver:
docker-httpserver: ## Build the HTTP server Docker image
DOCKER_BUILDKIT=1 docker build \
--platform linux/amd64 \
--build-arg VERSION=${VERSION} \
Expand Down

0 comments on commit 9866063

Please sign in to comment.