-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
50 lines (39 loc) · 1.75 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
.PHONY: all setup lint build test image-build image-push
TEST_TIMEOUT := 10s
SHELL := /bin/bash
TAG ?= latest
all: lint test build
setup: bin/golangci-lint bin/gofumpt bin/moq
go mod download
bin:
mkdir -p bin
bin/moq: bin
GOBIN=$(PWD)/bin go install github.com/matryer/moq@v0.3.4
bin/golangci-lint: bin
GOBIN=$(PWD)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1
bin/gofumpt: bin
GOBIN=$(PWD)/bin go install mvdan.cc/gofumpt@v0.6.0
build: cmd/main.go
CGO_ENABLED=0 go build -ldflags="-X github.com/duneanalytics/blockchain-ingester/client/duneapi.commitHash=$(shell git rev-parse --short HEAD)" -o indexer cmd/main.go
lint: bin/golangci-lint bin/gofumpt
go fmt ./...
go vet ./...
bin/golangci-lint -c .golangci.yml run ./...
bin/gofumpt -l -e -d ./
go mod tidy
test:
go mod tidy
CGO_ENABLED=1 go test -timeout=$(TEST_TIMEOUT) -race -bench=. -benchmem -cover ./...
gen-mocks: bin/moq ./client/jsonrpc/ ./client/duneapi/
./bin/moq -pkg jsonrpc_mock -out ./mocks/jsonrpc/httpclient.go ./client/jsonrpc HTTPClient
./bin/moq -pkg jsonrpc_mock -out ./mocks/jsonrpc/rpcnode.go ./client/jsonrpc BlockchainClient
./bin/moq -pkg duneapi_mock -out ./mocks/duneapi/client.go ./client/duneapi BlockchainIngester
image-build:
@echo "# Building Docker images"
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t "duneanalytics/node-indexer:${TAG}" -f Dockerfile .
image-push:
@echo "# Pushing Docker images to Docker Hub (after building)"
echo -n "${DOCKER_HUB_KEY}" | docker login --username duneanalytics --password-stdin
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t "duneanalytics/node-indexer:${TAG}" -f Dockerfile --push .