forked from Cogwheel-Validator/spectra-gnoland-indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (65 loc) · 2.75 KB
/
Copy pathMakefile
File metadata and controls
87 lines (65 loc) · 2.75 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
########################################################
# Build and install the indexer and API
########################################################
.PHONY: build-indexer build-api clean
# Get git information
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null || echo "")
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
VERSION := $(if $(GIT_TAG),$(GIT_TAG),$(GIT_BRANCH)-$(GIT_COMMIT))
indexer_flags := -X github.com/Cogwheel-Validator/spectra-gnoland-indexer/indexer/cmd.Commit=$(GIT_COMMIT) \
-X github.com/Cogwheel-Validator/spectra-gnoland-indexer/indexer/cmd.Version=$(VERSION)
api_flags := -X main.Commit=$(GIT_COMMIT) -X main.Version=$(VERSION) -w -s
build-indexer:
mkdir -p build
GOTOOLCHAIN=auto go build -ldflags "$(indexer_flags) -w -s" -o build/indexer indexer/cmd/indexer.go
build-api:
mkdir -p build
GOTOOLCHAIN=auto go build -ldflags="$(api_flags)" -o build/api ./api
build-dev:
mkdir -p build
GOTOOLCHAIN=auto go build -gcflags="-m=2" -tags=devmode -ldflags "$(indexer_flags)" -o build/dev indexer/cmd/indexer.go
clean:
rm -rf build
########################################################
# Test the indexer
########################################################
test:
go test -v ./...
integration-test:
cd integration && go test -v -tags=integration -timeout=20m ./...
########################################################
# Vulnerability scanning
########################################################
snyk:
snyk test
semgrep:
semgrep ci
########################################################
# Code quality
########################################################
lint:
golangci-lint run
vulncheck:
GOTOOLCHAIN=auto govulncheck ./...
########################################################
# Train the zstd dictionary
########################################################
.PHONY: train-zstd
train-zstd:
@echo "Training the zstd dictionary"
@read -p "Enter the amount of events to collect (default: 10000): " amount; \
amount=$${amount:-10000}; \
go run compression/cmd/main.go --config training-config.yml --amount $$amount --chain-name gnoland --dict-path ./pkgs/dict_loader/events.zstd.bin
########################################################
# Add changes to the CHANGELOG.md
########################################################
.PHONY: changelog
changelog:
@echo "Adding changes to the CHANGELOG.md"
@read -p "Enter new git tag that the changes are associated with: " tag; \
new_tag=$${tag}; \
last_tag=$$(git describe --tags --abbrev=0 --match "v*" | tail -n 1); \
last_tag+="..HEAD"; \
git cliff $$last_tag --tag $$new_tag --prepend CHANGELOG.md
@echo "Changes added to CHANGELOG.md"