Skip to content

Commit 9e2d75d

Browse files
authored
Merge branch 'develop' into feature/prune
2 parents 7d666e7 + db03770 commit 9e2d75d

25 files changed

Lines changed: 308 additions & 220 deletions

‎.gitlab-ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ before_script:
2525
test-my-project:
2626
stage: test
2727
script:
28-
- bash -x build.sh
28+
- make clean
29+
- make use_all_cores
2930
- go test -v -race -failfast -parallel 16 -cpu 16 $(go list ./... | grep -v "/vendor/") -coverprofile cover.out
3031
- cd rpc && go test -test.bench ^BenchmarkPersistentCaller_Call$ -test.run ^$ && cd -
3132
- bash cleanupDB.sh || true

‎.travis.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ script:
3434
golint ./... | grep -v 'vendor/' | grep -v 'server/' | grep -v 'utils/' | reviewdog -f=golint -reporter=github-pr-review || true
3535
3636
before_deploy:
37-
- bash build.sh
37+
- make clean
38+
- make use_all_cores
3839
- mkdir -p build
3940
- tar czvf build/CovenantSQL-$TRAVIS_TAG.$TRAVIS_OS_NAME-amd64.tar.gz $(ls bin/cql* | grep -v test)
4041

‎Makefile‎

Lines changed: 161 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
default: all
22

3+
# Do a parallel build with multiple jobs, based on the number of CPUs online
4+
# in this system: 'make -j8' on a 8-CPU system, etc.
5+
ifeq ($(JOBS),)
6+
JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
7+
ifeq ($(JOBS),)
8+
JOBS := $(shell sysctl -n hw.logicalcpu 2>/dev/null)
9+
ifeq ($(JOBS),)
10+
JOBS := 1
11+
endif
12+
endif
13+
endif
14+
15+
use_all_cores:
16+
make -j$(JOBS) all
17+
18+
BUILDER := covenantsql/covenantsql-builder
319
IMAGE := covenantsql/covenantsql
20+
OB_IMAGE := covenantsql/covenantsql-observer
21+
422
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
523
GIT_DIRTY ?= $(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
624
GIT_DESCRIBE ?= $(shell git describe --tags --always)
@@ -11,18 +29,47 @@ SHIP_VERSION := $(shell docker image inspect -f "{{ .Config.Labels.version }}" $
1129
IMAGE_TAR := $(subst /,_,$(IMAGE)).$(SHIP_VERSION).tar
1230
IMAGE_TAR_GZ := $(IMAGE_TAR).gz
1331

14-
1532
status:
1633
@echo "Commit: $(COMMIT) Version: $(VERSION) Ship Version: $(SHIP_VERSION)"
1734

18-
docker: status
35+
36+
builder: status
37+
docker build \
38+
--tag $(BUILDER):$(VERSION) \
39+
--tag $(BUILDER):latest \
40+
--build-arg BUILD_ARG=use_all_cores \
41+
-f docker/builder.Dockerfile \
42+
.
43+
44+
runner: builder
1945
docker build \
2046
--tag $(IMAGE):$(VERSION) \
2147
--tag $(IMAGE):latest \
2248
--build-arg COMMIT=$(COMMIT) \
2349
--build-arg VERSION=$(VERSION) \
50+
-f docker/Dockerfile \
2451
.
2552

53+
observer_docker: builder
54+
docker build \
55+
--tag $(OB_IMAGE):$(VERSION) \
56+
--tag $(OB_IMAGE):latest \
57+
--build-arg COMMIT=$(COMMIT) \
58+
--build-arg VERSION=$(VERSION) \
59+
-f docker/observer.Dockerfile \
60+
.
61+
62+
docker: runner observer_docker
63+
64+
docker_clean: status
65+
docker rmi -f $(BUILDER):latest
66+
docker rmi -f $(IMAGE):latest
67+
docker rmi -f $(OB_IMAGE):latest
68+
docker rmi -f $(BUILDER):$(VERSION)
69+
docker rmi -f $(IMAGE):$(VERSION)
70+
docker rmi -f $(OB_IMAGE):$(VERSION)
71+
72+
2673
save: status
2774
ifeq ($(SHIP_VERSION),)
2875
$(error No version to ship, please build first)
@@ -45,16 +92,119 @@ push:
4592
docker push $(IMAGE):$(VERSION)
4693
docker push $(IMAGE):latest
4794

48-
bp:
49-
./build.sh bp
5095

51-
miner:
52-
./build.sh miner
5396

54-
client:
55-
./build.sh client
97+
branch := $(shell git rev-parse --abbrev-ref HEAD)
98+
builddate := $(shell date +%Y%m%d%H%M%S)
99+
100+
unamestr := $(shell uname)
101+
102+
ifeq ($(unamestr),"Linux")
103+
platform := "linux"
104+
endif
105+
106+
version := $(branch)-$(GIT_COMMIT)-$(builddate)
107+
108+
tags := $(platform) sqlite_omit_load_extension
109+
testtags := $(platform) sqlite_omit_load_extension testbinary
110+
test_flags := -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c
111+
112+
ldflags_role_bp := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B $$GOLDFLAGS
113+
ldflags_role_miner := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M $$GOLDFLAGS
114+
ldflags_role_client := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C $$GOLDFLAGS
115+
116+
GOTEST := CGO_ENABLED=1 go test $(test_flags) -tags "$(testtags)"
117+
GOBUILD := CGO_ENABLED=1 go build -tags "$(tags)"
118+
119+
bin/cqld.test:
120+
$(GOTEST) \
121+
-ldflags "$(ldflags_role_bp)" \
122+
-o bin/cqld.test \
123+
github.com/CovenantSQL/CovenantSQL/cmd/cqld
124+
125+
bin/cqld:
126+
$(GOBUILD) \
127+
-ldflags "$(ldflags_role_bp)" \
128+
-o bin/cqld \
129+
github.com/CovenantSQL/CovenantSQL/cmd/cqld
130+
131+
bin/cql-minerd.test:
132+
$(GOTEST) \
133+
-ldflags "$(ldflags_role_miner)" \
134+
-o bin/cql-minerd.test \
135+
github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd
136+
137+
bin/cql-minerd:
138+
$(GOBUILD) \
139+
-ldflags "$(ldflags_role_miner)" \
140+
-o bin/cql-minerd \
141+
github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd
142+
143+
bin/cql-observer.test:
144+
$(GOTEST) \
145+
-ldflags "$(ldflags_role_client)" \
146+
-o bin/cql-observer.test \
147+
github.com/CovenantSQL/CovenantSQL/cmd/cql-observer
148+
149+
bin/cql-observer:
150+
$(GOBUILD) \
151+
-ldflags "$(ldflags_role_client)" \
152+
-o bin/cql-observer \
153+
github.com/CovenantSQL/CovenantSQL/cmd/cql-observer
154+
155+
bin/cql-utils:
156+
$(GOBUILD) \
157+
-ldflags "$(ldflags_role_client)" \
158+
-o bin/cql-utils \
159+
github.com/CovenantSQL/CovenantSQL/cmd/cql-utils
160+
161+
bin/cql:
162+
$(GOBUILD) \
163+
-ldflags "$(ldflags_role_client)" \
164+
-o bin/cql \
165+
github.com/CovenantSQL/CovenantSQL/cmd/cql
166+
167+
bin/cql-fuse:
168+
$(GOBUILD) \
169+
-ldflags "$(ldflags_role_client)" \
170+
-o bin/cql-fuse \
171+
github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse
172+
173+
bin/cql-adapter:
174+
$(GOBUILD) \
175+
-ldflags "$(ldflags_role_client)" \
176+
-o bin/cql-adapter \
177+
github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter
178+
179+
bin/cql-mysql-adapter:
180+
$(GOBUILD) \
181+
-ldflags "$(ldflags_role_client)" \
182+
-o bin/cql-mysql-adapter \
183+
github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter
184+
185+
bin/cql-faucet:
186+
$(GOBUILD) \
187+
-ldflags "$(ldflags_role_client)" \
188+
-o bin/cql-faucet \
189+
github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet
190+
191+
bin/cql-explorer:
192+
$(GOBUILD) \
193+
-ldflags "$(ldflags_role_client)" \
194+
-o bin/cql-explorer \
195+
github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer
196+
197+
bp: bin/cqld.test bin/cqld
198+
199+
miner: bin/cql-minerd.test bin/cql-minerd
200+
201+
observer: bin/cql-observer.test bin/cql-observer
202+
203+
client: bin/cql-utils bin/cql bin/cql-fuse bin/cql-adapter bin/cql-mysql-adapter bin/cql-faucet bin/cql-explorer
204+
205+
all: bp miner observer client
56206

57-
all:
58-
./build.sh
207+
clean:
208+
rm -rf bin/cql*
59209

60-
.PHONY: status docker save start stop logs push bp miner client all
210+
.PHONY: status start stop logs push clean

‎bin/docker-entry.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ blockproducer)
1010
exec /app/cqld -config "${COVENANT_CONF}" "${@}"
1111
;;
1212
observer)
13-
exec /app/cql-observer -config "${COVENANT_CONF}" "${@}"
13+
MAGIC_DOLLAR='$' envsubst < /etc/nginx/conf.d/servers/explorer.conf.template > /etc/nginx/conf.d/default.conf
14+
nginx -g 'daemon off;' </dev/null &
15+
exec /app/cql-observer -config "${COVENANT_CONF}" -listen "${COVENANTSQL_OBSERVER_ADDR}"
1416
;;
1517
adapter)
1618
exec /app/cql-adapter -config "${COVENANT_CONF}" "${@}"

‎build.sh‎

Lines changed: 0 additions & 94 deletions
This file was deleted.

‎cmd/cql-adapter/storage/sqlite3.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"math/rand"
2525
"os"
2626
"path/filepath"
27+
2728
// Import sqlite3 manually.
2829
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
2930
)

‎cmd/cql-faucet/persistence.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/CovenantSQL/CovenantSQL/conf"
2727
"github.com/CovenantSQL/CovenantSQL/utils/log"
2828
uuid "github.com/satori/go.uuid"
29+
2930
// Load sqlite3 database driver.
3031
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
3132
)

‎cmd/cql-minerd/bench.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
../../build.sh && \
3+
make -C ../../ clean && \
4+
make -C ../../ use_all_cores && \
45
go test -bench=^BenchmarkSQLite$ -benchtime=10s -run ^$ && \
56
go test -bench=^BenchmarkMinerOne$ -benchtime=10s -run ^$ && \
67
go test -bench=^BenchmarkMinerOneNoSign$ -benchtime=10s -run ^$ && \

‎cmd/cql-minerd/benchGNTE.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
#../../build.sh && \
3+
#make -C ../../ clean && \
4+
#make -C ../../ use_all_cores && \
45
go test -bench=^BenchmarkMinerGNTE1$ -benchtime=10s -run ^$ |tee gnte.log
56
go test -bench=^BenchmarkMinerGNTE2$ -benchtime=10s -run ^$ |tee -a gnte.log
67
go test -bench=^BenchmarkMinerGNTE3$ -benchtime=10s -run ^$ |tee -a gnte.log

‎cmd/cql-minerd/mcprof.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/sh -x
22

33
../../cleanupDB.sh
4-
../../build.sh
4+
make -C ../../ clean
5+
make -C ../../ use_all_cores
56

67
(go test -bench=^BenchmarkMinerTwo$ -benchtime=40s -run ^$ &) && \
78
(sleep 25 && DSN=`cat .dsn` go test '-bench=^BenchmarkClientOnly$' -benchtime=20s -run '^$')

0 commit comments

Comments
 (0)