forked from algorand/indexer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (91 loc) · 4.67 KB
/
Makefile
File metadata and controls
119 lines (91 loc) · 4.67 KB
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
SRCPATH := $(shell pwd)
VERSION := $(shell $(SRCPATH)/mule/scripts/compute_build_number.sh)
OS_TYPE ?= $(shell $(SRCPATH)/mule/scripts/ostype.sh)
ARCH ?= $(shell $(SRCPATH)/mule/scripts/archtype.sh)
PKG_DIR = $(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(VERSION)
ifeq ($(OS_TYPE), darwin)
ifeq ($(ARCH), arm64)
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
endif
endif
export GOPATH := $(shell go env GOPATH)
GOPATH1 := $(firstword $(subst :, ,$(GOPATH)))
# TODO: ensure any additions here are mirrored in misc/release.py
GOLDFLAGS += -X github.com/algorand/indexer/version.Hash=$(shell git log -n 1 --pretty="%H")
GOLDFLAGS += -X github.com/algorand/indexer/version.Dirty=$(if $(filter $(strip $(shell git status --porcelain|wc -c)), "0"),,true)
GOLDFLAGS += -X github.com/algorand/indexer/version.CompileTime=$(shell date -u +%Y-%m-%dT%H:%M:%S%z)
GOLDFLAGS += -X github.com/algorand/indexer/version.GitDecorateBase64=$(shell git log -n 1 --pretty="%D"|base64|tr -d ' \n')
GOLDFLAGS += -X github.com/algorand/indexer/version.ReleaseVersion=$(shell cat .version)
COVERPKG := $(shell go list ./... | grep -v '/cmd/' | egrep -v '(testing|test|mocks)$$' | paste -s -d, - )
# Used for e2e test
export GO_IMAGE = golang:$(shell go version | cut -d ' ' -f 3 | tail -c +3 )
# This is the default target, build everything:
all: conduit cmd/algorand-indexer/algorand-indexer go-algorand idb/postgres/internal/schema/setup_postgres_sql.go idb/mocks/IndexerDb.go
conduit: go-algorand
go generate ./... && cd cmd/conduit && go build -ldflags="${GOLDFLAGS}"
cmd/algorand-indexer/algorand-indexer: idb/postgres/internal/schema/setup_postgres_sql.go go-algorand
cd cmd/algorand-indexer && go build -ldflags="${GOLDFLAGS}"
go-algorand:
git submodule update --init && cd third_party/go-algorand && \
make crypto/libs/`scripts/ostype.sh`/`scripts/archtype.sh`/lib/libsodium.a
idb/postgres/internal/schema/setup_postgres_sql.go: idb/postgres/internal/schema/setup_postgres.sql
cd idb/postgres/internal/schema && go generate
idb/mocks/IndexerDb.go: idb/idb.go
go install github.com/vektra/mockery/v2@v2.12.1
cd idb && mockery --name=IndexerDb
# check that all packages (except tests) compile
check: go-algorand
go build ./...
package: go-algorand
rm -rf $(PKG_DIR)
mkdir -p $(PKG_DIR)
misc/release.py --host-only --outdir $(PKG_DIR)
# used in travis test builds; doesn't verify that tag and .version match
fakepackage: go-algorand
rm -rf $(PKG_DIR)
mkdir -p $(PKG_DIR)
misc/release.py --host-only --outdir $(PKG_DIR) --fake-release
test: idb/mocks/IndexerDb.go cmd/algorand-indexer/algorand-indexer
go test -coverpkg=$(COVERPKG) ./... -coverprofile=coverage.txt -covermode=atomic ${TEST_FLAG}
lint: go-algorand
golangci-lint run -c .golangci.yml
go vet ./...
fmt:
go fmt ./...
# note: when running e2e tests manually be sure to set the e2e filename:
# 'export CI_E2E_FILENAME=rel-nightly'
# To keep the container running at exit set 'export EXTRA="--keep-alive"',
# once the container is paused use 'docker exec <id> bash' to inspect temp
# files in `/tmp/*/'
e2e: cmd/algorand-indexer/algorand-indexer
cd e2e_tests/docker/indexer/ && docker-compose build --build-arg GO_IMAGE=${GO_IMAGE} && docker-compose up --exit-code-from e2e
e2e-nightly: cmd/algorand-indexer/algorand-indexer
cd e2e_tests/docker/indexer/ && docker-compose build --build-arg GO_IMAGE=${GO_IMAGE} --build-arg CHANNEL=nightly && docker-compose up --exit-code-from e2e
# note: when running e2e tests manually be sure to set the e2e filename: 'export CI_E2E_FILENAME=rel-nightly'
e2e-conduit: conduit
export PATH=$(GOPATH1)/bin:$(PATH); pip3 install e2e_tests/ && e2econduit --s3-source-net ${CI_E2E_FILENAME} --conduit-bin cmd/conduit/conduit
deploy:
mule/deploy.sh
sign:
mule/sign.sh
test-package:
mule/e2e.sh
test-generate:
test/test_generate.py
nightly-setup:
cd third_party/go-algorand && git fetch && git reset --hard origin/master
nightly-teardown:
git submodule update
indexer-v-algod-swagger:
pytest -sv misc/parity
indexer-v-algod: nightly-setup indexer-v-algod-swagger nightly-teardown
# fetch and update submodule. it's default to latest rel/nightly branch.
# to use a different branch, update the branch in .gitmodules for CI build,
# and for local testing, you may checkout a specific branch in the submodule.
# after submodule is updated, CI_E2E_FILENAME in .circleci/config.yml should
# also be updated to use a newer artifact. path copied from s3 bucket,
# s3://algorand-testdata/indexer/e2e4/
update-submodule:
git submodule update --remote
.PHONY: all test e2e integration fmt lint deploy sign test-package package fakepackage cmd/algorand-indexer/algorand-indexer idb/mocks/IndexerDb.go go-algorand indexer-v-algod conduit