Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ab68e83
Update vendor/github.com/CovenantSQL/go-sqlite3-encrypt/
Jun 18, 2019
3014d79
Update vendor/github.com/CovenantSQL/sqlparser
Jun 18, 2019
31c4a41
Update Gopkg
Jun 18, 2019
6b351e8
Add darwin and sqlite_vtable sqlite_fts5 sqlite_icu sqlite_json tags
Jun 18, 2019
99c52a3
Add convertQueryAndBuildArgs test for VIRTUAL TABLE and MATCH
Jun 18, 2019
ef6a67a
Hang on for 10 seconds after startDBMS
Jun 19, 2019
789418e
Fix tests for go-sqlite 3.28.0 will return table name and column name…
Jun 19, 2019
2d48523
Hack: sleep 10s before start dbms failed fatal
Jun 19, 2019
c9203c2
Only open sqlite_vtable sqlite_fts5 sqlite_icu sqlite_json for miner
Jun 19, 2019
08e5de7
Merge branch 'develop' into feature/fts
auxten Jun 19, 2019
a6ad547
Add docker/builder docker/ci-builder Dockerfile
Jun 19, 2019
7570cdf
Use 1.12.x for release, remove bin/cql-minerd from release pkg
Jun 19, 2019
1db9791
Merge branch 'feature/fts' of github.com:CovenantSQL/CovenantSQL into…
Jun 19, 2019
f5af571
Fix static build of miner
Jun 20, 2019
bceba02
Static build for all linux binaries
Jun 20, 2019
071c6b1
Fix go-sqlite3-encrypt FLAGS
Jun 20, 2019
625eda9
Fix golint
Jun 20, 2019
4d83a9e
Add -lpthread for linux libicu
Jun 20, 2019
bcf11dd
Try make on travis
Jun 20, 2019
a9ecb2d
Check ldd in travis
Jun 20, 2019
d5bd2a3
Merge branch 'feature/fts' of github.com:CovenantSQL/CovenantSQL into…
Jun 20, 2019
2d402e5
Fix misleading console log
Jun 20, 2019
2f769a9
Only build static in Linux release
Jun 20, 2019
e3fdc36
Fix indent
Jun 20, 2019
875fc16
Add build-release-static target
Jun 20, 2019
852d181
Fix ldflags
Jun 20, 2019
a9400ad
Fix else
Jun 20, 2019
2be450b
Use apline to make static release
Jun 20, 2019
9516820
Fix travis release for macOS and Linux, alpine
Jun 20, 2019
676d37f
Fix if in makefile
Jun 20, 2019
d423666
Run test on travis static release
Jun 20, 2019
4eff68e
Fix test/testnet_client/run.sh
Jun 20, 2019
c9de139
Fix mv
Jun 20, 2019
24dd2fb
Print Querying SQLChain Profile on the second rpc.RequestBP
Jun 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
- REVIEWDOG_VERSION=0.9.11
language: go
go:
- '1.11.x'
- '1.12.x'

os:
- linux
Expand All @@ -30,14 +30,21 @@ before_script:
- echo $TRAVIS_SECURE_ENV_VARS
- ulimit -n 8192
script:
- make release
- mkdir tmp && tar zxvf app-bin.tgz -C tmp
- ldd tmp/bin/cql* || true
- set -x
- mv -f tmp/bin/cql* bin/
- ./test/testnet_client/run.sh
- >-
golint ./... | grep -v 'vendor/' | grep -v 'server/' | grep -v 'utils/' | reviewdog -f=golint -reporter=github-pr-review || true

before_deploy:
- make clean
- make use_all_cores
- mkdir -p build
- tar czvf build/CovenantSQL-$TRAVIS_TAG.$TRAVIS_OS_NAME-amd64.tar.gz bin/cql bin/cql-fuse bin/cql-minerd bin/cql-mysql-adapter
- make release
- mkdir build && tar zxvf app-bin.tgz -C build
- ldd build/bin/cql* || true
- mv app-bin.tgz build/CovenantSQL-$TRAVIS_TAG.$TRAVIS_OS_NAME-amd64.tar.gz

deploy:
provider: releases
Expand Down
8 changes: 4 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
name = "github.com/CovenantSQL/xurls"
branch = "master"

[[override]]
name = "github.com/CovenantSQL/sqlparser"
branch = "master"

[[override]]
name = "github.com/zserge/metric"
branch = "master"
Expand Down
85 changes: 73 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ docker_clean: status
docker rmi -f $(BUILDER):$(VERSION)
docker rmi -f $(IMAGE):$(VERSION)

alpine_release: builder
temp_container=$$(docker create $(BUILDER):$(VERSION)) ; \
docker cp $${temp_container}:/go/src/github.com/CovenantSQL/CovenantSQL/bin - | gzip > app-bin.tgz

save: status
ifeq ($(SHIP_VERSION),)
Expand Down Expand Up @@ -102,6 +105,10 @@ unamestr := $(shell uname)

ifeq ($(unamestr),Linux)
platform := linux
else
ifeq ($(unamestr),Darwin)
platform := darwin
endif
endif

ifdef CQLVERSION
Expand All @@ -111,16 +118,22 @@ else
endif

tags := $(platform) sqlite_omit_load_extension
testtags := $(tags) testbinary
miner_tags := $(tags) sqlite_vtable sqlite_fts5 sqlite_icu sqlite_json
test_tags := $(tags) testbinary
miner_test_tags := $(test_tags) sqlite_vtable sqlite_fts5 sqlite_icu sqlite_json

static_flags := -linkmode external -extldflags '-static'
test_flags := -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c

ldflags_role_bp := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B $$GOLDFLAGS
ldflags_role_miner := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M $$GOLDFLAGS
ldflags_role_client := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C $$GOLDFLAGS
ldflags_role_bp := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B
ldflags_role_miner := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M
ldflags_role_client := -X main.version=$(version) -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C
ldflags_role_client_simple_log := $(ldflags_role_client) -X github.com/CovenantSQL/CovenantSQL/utils/log.SimpleLog=Y

GOTEST := CGO_ENABLED=1 go test $(test_flags) -tags "$(testtags)"
GOTEST := CGO_ENABLED=1 go test $(test_flags) -tags "$(test_tags)"
GOTEST_MINER := CGO_ENABLED=1 go test $(test_flags) -tags "$(miner_test_tags)"
GOBUILD := CGO_ENABLED=1 go build -tags "$(tags)"
GOBUILD_MINER := CGO_ENABLED=1 go build -tags "$(miner_tags)"

bin/cqld.test:
$(GOTEST) \
Expand All @@ -134,49 +147,84 @@ bin/cqld:
-o bin/cqld \
github.com/CovenantSQL/CovenantSQL/cmd/cqld

bin/cqld.static:
$(GOBUILD) \
-ldflags "$(ldflags_role_bp) $(static_flags)" \
-o bin/cqld \
github.com/CovenantSQL/CovenantSQL/cmd/cqld

bin/cql-minerd.test:
$(GOTEST) \
$(GOTEST_MINER) \
-ldflags "$(ldflags_role_miner)" \
-o bin/cql-minerd.test \
github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd

bin/cql-minerd:
$(GOBUILD) \
$(GOBUILD_MINER) \
-ldflags "$(ldflags_role_miner)" \
-o bin/cql-minerd \
github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd

bin/cql:
$(GOBUILD) \
-ldflags "$(ldflags_role_client_simple_log)" \
-o bin/cql \
github.com/CovenantSQL/CovenantSQL/cmd/cql
bin/cql-minerd.static:
$(GOBUILD_MINER) \
-ldflags "$(ldflags_role_miner) $(static_flags)" \
-o bin/cql-minerd \
github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd

bin/cql.test:
$(GOTEST) \
-ldflags "$(ldflags_role_client)" \
-o bin/cql.test \
github.com/CovenantSQL/CovenantSQL/cmd/cql

bin/cql:
$(GOBUILD) \
-ldflags "$(ldflags_role_client_simple_log)" \
-o bin/cql \
github.com/CovenantSQL/CovenantSQL/cmd/cql

bin/cql.static:
$(GOBUILD) \
-ldflags "$(ldflags_role_client_simple_log) $(static_flags)" \
-o bin/cql \
github.com/CovenantSQL/CovenantSQL/cmd/cql

bin/cql-fuse:
$(GOBUILD) \
-ldflags "$(ldflags_role_client_simple_log)" \
-o bin/cql-fuse \
github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse

bin/cql-fuse.static:
$(GOBUILD) \
-ldflags "$(ldflags_role_client_simple_log) $(static_flags)" \
-o bin/cql-fuse \
github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse

bin/cql-mysql-adapter:
$(GOBUILD) \
-ldflags "$(ldflags_role_client)" \
-o bin/cql-mysql-adapter \
github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter

bin/cql-mysql-adapter.static:
$(GOBUILD) \
-ldflags "$(ldflags_role_client) $(static_flags)" \
-o bin/cql-mysql-adapter \
github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter

bin/cql-faucet:
$(GOBUILD) \
-ldflags "$(ldflags_role_client)" \
-o bin/cql-faucet \
github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet

bin/cql-faucet.static:
$(GOBUILD) \
-ldflags "$(ldflags_role_client) $(static_flags)" \
-o bin/cql-faucet \
github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet

bp: bin/cqld.test bin/cqld

miner: bin/cql-minerd.test bin/cql-minerd
Expand All @@ -187,8 +235,21 @@ all: bp miner client

build-release: bin/cqld bin/cql-minerd bin/cql bin/cql-fuse bin/cql-mysql-adapter bin/cql-faucet

# This should only called in alpine docker builder
build-release-static: bin/cqld.static bin/cql-minerd.static bin/cql.static \
bin/cql-fuse.static bin/cql-mysql-adapter.static bin/cql-faucet.static

release:
ifeq ($(unamestr),Linux)
if [ -f /.dockerenv ]; then \
make -j$(JOBS) build-release-static; \
else \
make alpine_release; \
fi
else
make -j$(JOBS) build-release
tar czvf app-bin.tgz bin/cqld bin/cql-minerd bin/cql bin/cql-fuse bin/cql-mysql-adapter bin/cql-faucet
endif

android-release: status
docker build \
Expand Down
4 changes: 2 additions & 2 deletions api/models/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ func (p *Pagination) SetTotal(total int) {
}

// Limit returns the page size.
// Attened to be used in SQL statements.
// Intend to be used in SQL statements.
func (p *Pagination) Limit() int {
p.normalize()
return p.Size
}

// Offset returns the size of skipped items of current page.
// Attened to be used in SQL statements.
// Intend to be used in SQL statements.
func (p *Pagination) Offset() int {
p.normalize()
return (p.Page - 1) * p.Size
Expand Down
2 changes: 1 addition & 1 deletion bin/completion/_cql
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ _cql() {
"adapter:start a SQLChain adapter"
"idminer:calculate nonce and node id for config.yaml file"
"rpc:make a rpc request"
"version:show build version infomation"
"version:show build version information"
"help:show help for sub command"
)

Expand Down
2 changes: 1 addition & 1 deletion client/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func WaitBPDatabaseCreation(
select {
case <-ticker.C:
count++
fmt.Printf("\rWaiting for miner confirmation %vs", count*int(period.Seconds()))

if err = rpc.RequestBP(
route.MCCQuerySQLChainProfile.String(), req, nil,
Expand All @@ -291,6 +290,7 @@ func WaitBPDatabaseCreation(
return
}
}
fmt.Printf("\rQuerying SQLChain Profile %vs", count*int(period.Seconds()))
case <-ctx.Done():
err = ctx.Err()
return
Expand Down
3 changes: 3 additions & 0 deletions cmd/cql-minerd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func main() {
if dbms, err = startDBMS(server, direct, func() {
sendProvideService(reg)
}); err != nil {
// FIXME(auxten): if restart all miners with the same db,
// miners will fail to start
time.Sleep(10 * time.Second)
log.WithError(err).Fatal("start dbms failed")
}

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ENV VERSION=${VERSION}
ENV COVENANT_ROLE=miner
ENV COVENANT_CONF=config.yaml

RUN apk --no-cache add ca-certificates
RUN apk --no-cache add ca-certificates icu-libs musl

WORKDIR /app
COPY --from=covenantsql/covenantsql-builder /go/src/github.com/CovenantSQL/CovenantSQL/bin/* /app/
Expand Down
5 changes: 2 additions & 3 deletions docker/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Stage: builder
FROM golang:1.11-alpine3.9 as builder
FROM covenantsql/release-builder as builder

ARG BUILD_ARG

WORKDIR /go/src/github.com/CovenantSQL/CovenantSQL
COPY . .
RUN apk --no-cache add build-base make git
RUN make clean
RUN GOOS=linux GOLDFLAGS="-linkmode external -extldflags -static" make ${BUILD_ARG}
RUN GOOS=linux make ${BUILD_ARG}

10 changes: 10 additions & 0 deletions docker/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:alpine3.9
MAINTAINER auxten

RUN apk add build-base
RUN apk add make
RUN apk add git
RUN apk add icu-dev
RUN apk add icu-static

WORKDIR $GOPATH
4 changes: 4 additions & 0 deletions docker/builder/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker build -t covenantsql/release-builder:latest . && \
docker push covenantsql/release-builder
14 changes: 14 additions & 0 deletions docker/ci-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.12
MAINTAINER auxten

RUN apt-get update && apt-get install -y --no-install-recommends \
libicu-dev \
&& rm -rf /var/lib/apt/lists/*


RUN go get github.com/mattn/goveralls
RUN go get github.com/haya14busa/goverage
RUN go get golang.org/x/lint/golint
RUN go get github.com/haya14busa/reviewdog/cmd/reviewdog

WORKDIR $GOPATH
4 changes: 4 additions & 0 deletions docker/ci-builder/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker build -t covenantsql/build:latest . && \
docker push covenantsql/build
5 changes: 1 addition & 4 deletions metric/cpu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ func (c *cpuCollector) Update(ch chan<- prometheus.Metric) error {
if err := c.updateStat(ch); err != nil {
return err
}
if err := c.updateCPUfreq(ch); err != nil {
return err
}
return nil
return c.updateCPUfreq(ch)
}

// updateCPUfreq reads /sys/devices/system/cpu/cpu* and expose cpu frequency statistics.
Expand Down
16 changes: 8 additions & 8 deletions storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ func TestStorage(t *testing.T) {
t.Fatalf("error result count: %v, should be 3", len(data))
} else {
// compare rows
should1 := []interface{}{[]byte("k0"), nil}
should2 := []interface{}{[]byte("k1"), []byte("v1")}
should3 := []interface{}{[]byte("k3"), []byte("v3-2")}
should1 := []interface{}{"k0", nil}
should2 := []interface{}{"k1", "v1"}
should3 := []interface{}{"k3", "v3-2"}
t.Logf("Rows: %v", data)
if !reflect.DeepEqual(data[0], should1) {
t.Fatalf("error result row: %v, should: %v", data[0], should1)
Expand Down Expand Up @@ -229,9 +229,9 @@ func TestStorage(t *testing.T) {
t.Fatalf("error result count: %v, should be 3", len(data))
} else {
// compare rows
should1 := []interface{}{[]byte("k0")}
should2 := []interface{}{[]byte("k1")}
should3 := []interface{}{[]byte("k3")}
should1 := []interface{}{"k0"}
should2 := []interface{}{"k1"}
should3 := []interface{}{"k3"}
t.Logf("Rows: %v", data)
if !reflect.DeepEqual(data[0], should1) {
t.Fatalf("error result row: %v, should: %v", data[0], should1)
Expand Down Expand Up @@ -261,8 +261,8 @@ func TestStorage(t *testing.T) {
t.Fatalf("error result count: %v, should be 3", len(data))
} else {
// compare rows
should1 := []interface{}{[]byte("k1")}
should2 := []interface{}{[]byte("k3")}
should1 := []interface{}{"k1"}
should2 := []interface{}{"k3"}
t.Logf("Rows: %v", data)
if !reflect.DeepEqual(data[0], should1) {
t.Fatalf("error result row: %v, should: %v", data[0], should1)
Expand Down
Loading