-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
151 lines (129 loc) · 3.89 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Variables
export GO111MODULE ?= on
export GOPROXY ?= https://proxy.golang.org
export GOSUMDB ?= sum.golang.org
#export GOROOT ?= dist/
# Applications name
# CGO ?= 0
BINARY ?= pastelup
TEST_IMG = pastel-test
# Version
VERSION = $(shell git describe --tag)
# Target for cross build and specific extention name
PLATFORMS ?= darwin/amd64 windows/amd64/.exe linux/amd64
# Macros to sub info from platforms
temp = $(subst /, ,$@)
cross_os = $(word 1, $(temp))
cross_arch = $(word 2, $(temp))
cross_ext = $(word 3, $(temp))
arch = "amd64"
ifeq ($(OS),Windows_NT)
os = "windows"
ext = ".exe"
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
os = "linux"
ext = ""
endif
ifeq ($(UNAME_S),Darwin)
os = "darwin"
ext = ""
endif
endif
# GO build flags
LDFLAGS="-s -w -X github.com/pastelnetwork/pastelup/common/version.version=$(VERSION)"
release:
go build $(GCFLAGS) -ldflags=$(LDFLAGS) -o $(BINARY) main.go
strip -v $(BINARY) -o dist/$(BINARY)-$(os)-$(arch)$(ext)
#
# Target build
#
release-all: $(PLATFORMS)
$(PLATFORMS):
CGO_ENABLED=$(CGO) GOOS=$(cross_os) GOARCH=$(cross_arch) go build $(GCFLAGS) -ldflags=$(LDFLAGS) -o dist/$(BINARY)-$(cross_os)-$(cross_arch)$(cross_ext) main.go
# upx dist/$(BINARY)-$(os)-$(arch)$(ext)
#.PHONY: release $(PLATFORMS)
build-dev-container:
docker build -t pastel-dev -f ./test/Dockerfile-dev .
# useful if developing on a non-linux OS like a mac
run-dev-container:
docker rm pastel-dev || true
docker run -it \
--name pastel-dev \
--mount type=bind,source=${PWD},target=/home/ubuntu \
--entrypoint '/bin/bash' \
--memory="1g" \
--memory-swap="2g" \
pastel-dev
# clear files generated from using run-dev-container with mounted workdir
clean-dev:
rm -rf .bash_history
rm -rf .cache/
rm -rf .keras/
rm -rf pastel_dupe_detection_service/
rm -rf venv/
lint:
gofmt -d -e .
go vet -v ./...
revive -config ./.circleci/revive.toml ./...
staticcheck ./...
build-test-img:
docker build -t $(TEST_IMG) -f ./test/Dockerfile .
tmp-local:
docker build -t pastel-local -f ./test/Dockerfile .
docker run -it pastel-local /bin/bash
test-walletnode:
$(eval CONTAINER_NAME := "pastel-walletnode-test")
$(eval SCRIPT := "test-walletnode.sh")
docker rm $(CONTAINER_NAME) || true
docker run \
--name $(CONTAINER_NAME) \
--mount type=bind,source=${PWD}/test/scripts/$(SCRIPT),target=/home/ubuntu/$(SCRIPT) \
--entrypoint '/bin/bash' \
$(TEST_IMG) \
-c "./$(SCRIPT)"
test-local-supernode:
$(eval CONTAINER_NAME := "pastel-local-supernode-test")
$(eval SCRIPT := "test-local-supernode.sh")
docker rm $(CONTAINER_NAME) || true
docker run \
--name $(CONTAINER_NAME) \
--interactive \
--mount type=bind,source=${PWD}/test/scripts/$(SCRIPT),target=/home/ubuntu/$(SCRIPT) \
--expose=19933 \
--entrypoint '/bin/bash' \
$(TEST_IMG) \
-c "./$(SCRIPT)"
test-local-supernode-service:
$(eval CONTAINER_NAME := "pastel-local-supernode-service-test")
$(eval SCRIPT := "test-local-supernode.sh")
docker rm $(CONTAINER_NAME) || true
docker run \
--name $(CONTAINER_NAME) \
--interactive \
--mount type=bind,source=${PWD}/test/scripts/$(SCRIPT),target=/home/ubuntu/$(SCRIPT) \
--expose=19933 \
--entrypoint '/bin/bash' \
$(TEST_IMG) \
-c "./$(SCRIPT) --enable-service"
test-ddservice:
$(eval CONTAINER_NAME := "pastel-ddservice-test")
$(eval SCRIPT := "test-ddservice.sh")
docker rm $(CONTAINER_NAME) || true
docker run -it \
--name $(CONTAINER_NAME) \
--mount type=bind,source=${PWD}/test/scripts/$(SCRIPT),target=/home/ubuntu/$(SCRIPT) \
--entrypoint '/bin/bash' \
$(TEST_IMG) \
-c "./$(SCRIPT)"
test-servicemanager:
$(eval CONTAINER_NAME := "pastel-servicemanager-test")
$(eval SCRIPT := "test-servicemanager.sh")
docker rm $(CONTAINER_NAME) || true
docker run \
--name $(CONTAINER_NAME) \
--mount type=bind,source=${PWD}/test/scripts/$(SCRIPT),target=/home/ubuntu/$(SCRIPT) \
--entrypoint '/bin/bash' \
$(TEST_IMG) \
-c "./$(SCRIPT)"