laconicd/Makefile

94 lines
2.2 KiB
Makefile
Raw Normal View History

#!/usr/bin/make -f
DOCKER := $(shell which docker)
LACONIC_BINARY = laconic2d
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
# Update the ldflags with the app, client & server names
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=laconic \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(LACONIC_BINARY) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
BUILD_FLAGS := -ldflags '$(ldflags)'
###########
# Install #
###########
all: install
install:
@echo "--> ensure dependencies have not been modified"
@go mod verify
@echo "--> installing laconic2d"
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/laconic2d
init:
./scripts/init.sh
##################
### Protobuf ###
##################
protoVer=0.14.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
proto-all: proto-format proto-lint proto-gen
proto-gen:
@echo "Generating protobuf files..."
@$(protoImage) sh ./scripts/protocgen.sh
@go mod tidy
proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
proto-lint:
@$(protoImage) buf lint proto/ --error-format=json
.PHONY: proto-all proto-gen proto-format proto-lint
#################
### Linting ###
#################
golangci_lint_cmd=golangci-lint
golangci_version=v1.51.2
lint:
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run ./... --timeout 15m
lint-fix:
@echo "--> Running linter and fixing issues"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run ./... --fix --timeout 15m
.PHONY: lint lint-fix
#################
### Tests ###
#################
test-integration:
$(MAKE) -C tests test-integration
test-e2e:
$(MAKE) -C tests test-e2e