forked from edgexfoundry/app-rfid-llrp-inventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (55 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
.PHONY: build test unittest lint clean update fmt docker run
ARCH=$(shell uname -m)
MICROSERVICE=app-rfid-llrp-inventory
.PHONY: build test clean fmt docker run
APPVERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)
GIT_SHA=$(shell git rev-parse HEAD)
# This pulls the version of the SDK from the go.mod file. It works by looking for the line
# with the SDK and printing just the version number that comes after it.
SDKVERSION=$(shell sed -En 's|.*github.com/edgexfoundry/app-functions-sdk-go/v3 (v[\.0-9a-zA-Z-]+).*|\1|p' go.mod)
GOFLAGS=-ldflags "-X github.com/edgexfoundry/app-functions-sdk-go/v3/internal.SDKVersion=$(SDKVERSION) \
-X github.com/edgexfoundry/app-functions-sdk-go/v3/internal.ApplicationVersion=$(APPVERSION) \
-X edgexfoundry/app-rfid-llrp-inventory.Version=$(APPVERSION)" -trimpath -mod=readonly
GOTESTFLAGS?=-race
# CGO is enabled by default and causes local docker builds to fail due to no gcc,
# but is required for test with -race, so must disable it for the builds only
build:
CGO_ENABLED=0 go build -tags "$(ADD_BUILD_TAGS)" $(GOFLAGS) -o $(MICROSERVICE)
build-nats:
make -e ADD_BUILD_TAGS=include_nats_messaging build
tidy:
go mod tidy
t:
[ -z "$$(gofmt -p -l . || echo 'err')" ]
unittest:
go test $(GOTESTFLAGS) ./... -coverprofile=coverage.out ./...
lint:
@which golangci-lint >/dev/null || echo "WARNING: go linter not installed. To install, run make install-lint"
@if [ "z${ARCH}" = "zx86_64" ] && which golangci-lint >/dev/null ; then golangci-lint run --config .golangci.yml ; else echo "WARNING: Linting skipped (not on x86_64 or linter not installed)"; fi
install-lint:
sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.54.2
test: unittest lint
go vet ./...
gofmt -l $$(find . -type f -name '*.go'| grep -v "/vendor/")
[ "`gofmt -l $$(find . -type f -name '*.go'| grep -v "/vendor/")`" = "" ]
./bin/test-attribution.sh
clean:
rm -f $(MICROSERVICE)
fmt:
go fmt ./...
docker:
docker build \
--rm \
--build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \
--build-arg http_proxy \
--build-arg https_proxy \
--label "git_sha=$(GIT_SHA)" \
-t edgexfoundry/app-rfid-llrp-inventory:$(GIT_SHA) \
-t edgexfoundry/app-rfid-llrp-inventory:$(APPVERSION)-dev \
.
docker-nats:
make -C . -e ADD_BUILD_TAGS=include_nats_messaging docker
run: build
./$(MICROSERVICE) -cp=consul.http://localhost:8500 -confdir=res
vendor:
go mod vendor