This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
135 lines (108 loc) · 4.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
include version.mk
# Check for required dependencies
CHECK_GO := $(shell command -v go 2> /dev/null)
CHECK_CURL := $(shell command -v curl 2> /dev/null)
CHECK_DOCKER := $(shell command -v docker 2> /dev/null)
CHECK_MOCKERY := $(shell command -v mockery 2> /dev/null)
check-go:
ifndef CHECK_GO
$(error "Go is not installed. Please install Go and retry.")
endif
check-curl:
ifndef CHECK_CURL
$(error "curl is not installed. Please install curl and retry.")
endif
check-docker:
ifndef CHECK_DOCKER
$(error "Docker is not installed. Please install Docker and retry.")
endif
check-mockery:
ifndef CHECK_MOCKERY
$(error "Mockery is not installed. Please install Mockery and retry.")
endif
# Targets that require the checks
build: check-go
build-docker: check-docker
build-docker-nc: check-docker
run-docker: check-docker
run-docker-bo: run-docker-bo
stop-docker: check-docker
destroy-docker: check-docker
install-linter: check-go check-curl
lint: check-go
unit-tests: check-go
e2e-tests: check-go
generate-mocks: check-go check-mockery
ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH = amd64
else
ifeq ($(ARCH),aarch64)
ARCH = arm64
endif
endif
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/dist
GOOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
GOENVVARS := GOBIN=$(GOBIN) CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(ARCH)
GOBINARY := agglayer
GOCMD := $(GOBASE)/cmd
LDFLAGS += -X 'github.com/0xPolygon/agglayer.Version=$(VERSION)'
LDFLAGS += -X 'github.com/0xPolygon/agglayer.GitRev=$(GITREV)'
LDFLAGS += -X 'github.com/0xPolygon/agglayer.GitBranch=$(GITBRANCH)'
LDFLAGS += -X 'github.com/0xPolygon/agglayer.BuildDate=$(DATE)'
DOCKERCOMPOSE := docker-compose -f docker/docker-compose.yaml
DOCKERCOMPOSESTATEDB := agglayer-db
RUNSTATEDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSESTATEDB)
STOP := $(DOCKERCOMPOSE) down --remove-orphans
.PHONY: build
build: ## Builds the binary locally into ./dist
$(GOENVVARS) go build -ldflags "all=$(LDFLAGS)" -o $(GOBIN)/$(GOBINARY) $(GOCMD)
.PHONY: build-docker
build-docker: ## Builds a docker image with the agglayer binary
docker compose -f ./docker/docker-compose.yaml build agglayer
.PHONY: build-docker-nc
build-docker-nc: ## Builds a docker image with the agglayer binary - but without build cache
docker compose -f ./docker/docker-compose.yaml build --no-cache agglayer
.PHONY: run-docker
run-docker: ## Builds and runs agglayer with the default list of required services such as l1 and zkevm node
docker compose -f ./docker/docker-compose.yaml up -d zkevm-mock-l1-network zkevm-prover zkevm-node
docker compose -f ./docker/docker-compose.yaml up -d --build agglayer
.PHONY: run-docker-bo
run-docker-bo: ## Builds and runs agglayer only
docker compose -f ./docker/docker-compose.yaml up -d --build agglayer
.PHONY: stop-docker
stop-docker: ## Stops agglayer container and other side services without removing state
docker compose -f ./docker/docker-compose.yaml stop
.PHONY: destroy-docker
destroy-docker: ## Stops and removes agglayer container and other side services
docker compose -f ./docker/docker-compose.yaml down
.PHONY: install-linter
install-linter: ## Installs the linter
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.52.2
.PHONY: lint
lint: ## Runs the linter
export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/golangci-lint run
## Help display.
## Pulls comments from beside commands and prints a nicely formatted
## display with the commands and their usage information.
.DEFAULT_GOAL := help
.PHONY: help
help: ## Prints the help
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: e2e-tests
e2e-tests: stop ## Runs E2E tests
go test -v -timeout=30m github.com/0xPolygon/agglayer/test
.PHONY: unit-tests
unit-tests: stop ## Runs unit tests
$(RUNSTATEDB)
sleep 40
trap '$(STOP)' EXIT; MallocNanoZone=0 go test -v -timeout=5m -race -shuffle=on -coverprofile coverage.out `go list ./... | grep -v test`
.PHONY: generate-mocks
generate-mocks: ## Generates mocks and other autogenerated types
mockery
.PHONY: stop
stop: ## Stops all services
$(STOP)