-
Notifications
You must be signed in to change notification settings - Fork 103
/
Makefile
59 lines (45 loc) · 1.67 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
# Copyright the Hyperledger Fabric contributors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
base_dir := $(patsubst %/,%,$(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
functional_dir := $(base_dir)/internal/functionaltests
go_bin_dir := $(shell go env GOPATH)/bin
mockery_version := 2.43.2
kernel_name := $(shell uname -s)
machine_hardware := $(shell uname -m)
.PHONY: test
test: generate lint unit-test functional-test
.PHONY: lint
lint: staticcheck golangci-lint
.PHONY: staticcheck
staticcheck:
go install honnef.co/go/tools/cmd/staticcheck@latest
cd '$(base_dir)' && staticcheck -f stylish ./...
.PHONY: install-golangci-lint
install-golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b '$(go_bin_dir)'
$(go_bin_dir)/golangci-lint:
$(MAKE) install-golangci-lint
.PHONY: golangci-lint
golangci-lint: $(go_bin_dir)/golangci-lint
cd '$(base_dir)' && golangci-lint run
.PHONY: install-mockery
install-mockery:
curl --fail --location \
'https://github.com/vektra/mockery/releases/download/v$(mockery_version)/mockery_$(mockery_version)_$(kernel_name)_$(machine_hardware).tar.gz' \
| tar -C '$(go_bin_dir)' -xzf - mockery
$(go_bin_dir)/mockery:
$(MAKE) install-mockery
.PHONY: generate
generate: $(go_bin_dir)/mockery
cd '$(base_dir)' && mockery
.PHONY: unit-test
unit-test:
cd '$(base_dir)' && go test -race $$(go list ./... | grep -v functionaltests)
.PHONY: functional-test
functional-test:
go install github.com/cucumber/godog/cmd/[email protected]
cd '$(functional_dir)' && godog run features/*
.PHONY: scan
scan:
go install golang.org/x/vuln/cmd/govulncheck@latest
cd '$(base_dir)' && govulncheck ./...