-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
102 lines (79 loc) · 2.44 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
include common.mk
# Check if Go's linkers flags are set in common.mk and add them as extra flags.
ifneq ($(GOLDFLAGS),)
GO_EXTRA_FLAGS += -ldflags $(GOLDFLAGS)
endif
# Set all target as the default target.
all: build
# Build.
build:
@$(ECHO) "$(MAGENTA)*** Building Go code...$(OFF)"
@$(GO) build $(GOFLAGS) -o oasis-registry/oasis-registry ./oasis-registry
# Build examples.
build-examples:
@$(ECHO) "$(MAGENTA)*** Building examples...$(OFF)"
@cd examples/lookup && \
$(GO) build
# Generate test vectors.
gen_vectors:
@$(ECHO) "$(MAGENTA)*** Generating test vectors ...$(OFF)"
@$(GO) run ./$@
# Format code.
fmt-targets := fmt-go fmt-sh
fmt-go:
@$(ECHO) "$(CYAN)*** Running Go formatters...$(OFF)"
@gofumpt -s -w .
@gofumports -w -local github.com/oasisprotocol/metadata-registry-tools .
fmt-sh:
@$(ECHO) "$(CYAN)*** Running Shell formatters...$(OFF)"
@shfmt -l -w .
fmt: $(fmt-targets)
# Lint code, commits and documentation.
lint-targets := lint-go lint-sh lint-docs lint-git lint-go-mod-tidy
lint-go:
@$(ECHO) "$(CYAN)*** Running Go linters...$(OFF)"
@env -u GOPATH golangci-lint run
lint-sh:
@$(ECHO) "$(CYAN)*** Running Shell linters...$(OFF)"
@shfmt -d .
lint-git:
@$(ECHO) "$(CYAN)*** Runnint gitlint...$(OFF)"
@$(CHECK_GITLINT)
lint-docs:
@$(ECHO) "$(CYAN)*** Runnint markdownlint-cli...$(OFF)"
@npx markdownlint-cli '**/*.md'
lint-go-mod-tidy:
@$(ECHO) "$(CYAN)*** Checking go mod tidy...$(OFF)"
@$(ENSURE_GIT_CLEAN)
@$(CHECK_GO_MOD_TIDY)
lint: $(lint-targets)
# Test.
test-targets := test-unit test-cli test-cli-ledger
test-unit:
@$(ECHO) "$(CYAN)*** Running unit tests...$(OFF)"
@$(GO) test -v -race ./...
test-cli: build
@$(ECHO) "$(CYAN)*** Running CLI tests...$(OFF)"
@./tests/test-cli-general.sh
@unset LEDGER_SIGNER_PATH; ./tests/test-cli-metadata.sh
test-cli-ledger: build
@if [[ -n "$(LEDGER_SIGNER_PATH)" ]]; then \
$(ECHO) "$(CYAN)*** Running CLI tests with Ledger signer...$(OFF)"; \
$(ECHO) "$(RED)*** Make sure your Ledger device is connected and the Oasis app is open.$(OFF)"; \
./tests/test-cli-metadata.sh; \
else \
$(ECHO) "$(CYAN)*** Skipping CLI tests with Ledger signer since LEDGER_SIGNER_PATH is not defined.$(OFF)"; \
fi
test: $(test-targets)
# Clean.
clean:
@$(ECHO) "$(CYAN)*** Cleaning up ...$(OFF)"
@$(GO) clean -x
# List of targets that are not actual files.
.PHONY: \
all build build-examples \
gen_vectors \
$(fmt-targets) fmt \
$(lint-targets) lint \
$(test-targets) test \
clean