diff --git a/Dockerfile b/Dockerfile index 626ca9619..b2f1a82f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,11 @@ FROM golang:1.11-stretch as builder WORKDIR /go/src/github.com/CovenantSQL/CovenantSQL COPY . . -RUN CGO_ENABLED=1 GOOS=linux GOLDFLAGS="-linkmode external -extldflags -static" ./build.sh +RUN GOOS=linux GOLDFLAGS="-linkmode external -extldflags -static" ./build.sh RUN rm -f bin/*.test # Stage: runner -FROM alpine:3.7 +FROM frolvlad/alpine-glibc:latest ARG COMMIT ARG VERSION diff --git a/Makefile b/Makefile index 43e9dbbe4..a8928efde 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -default: build +default: docker IMAGE := covenantsql/covenantsql GIT_COMMIT ?= $(shell git rev-parse --short HEAD) @@ -15,7 +15,7 @@ IMAGE_TAR_GZ := $(IMAGE_TAR).gz status: @echo "Commit: $(COMMIT) Version: $(VERSION) Ship Version: $(SHIP_VERSION)" -build: status +docker: status docker build \ --tag $(IMAGE):$(VERSION) \ --tag $(IMAGE):latest \ @@ -35,6 +35,9 @@ start: docker-compose up --no-start docker-compose start +stop: + docker-compose down + logs: docker-compose logs -f --tail=10 @@ -42,4 +45,16 @@ push: docker push $(IMAGE):$(VERSION) docker push $(IMAGE):latest -.PHONY: status build save start logs push +bp: + ./build.sh bp + +miner: + ./build.sh miner + +client: + ./build.sh client + +all: + ./build.sh + +.PHONY: status docker save start stop logs push bp miner client all diff --git a/build.sh b/build.sh index fc39ea309..848608406 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,8 @@ #!/bin/bash -x set -e +param=$1 + branch=`git rev-parse --abbrev-ref HEAD` commitid=`git rev-parse --short HEAD` builddate=`date +%Y%m%d%H%M%S` @@ -19,38 +21,74 @@ cd `dirname $0` version=`getversion` -cql_utils_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-utils" -go build -ldflags "-X main.version=${version} ${GOLDFLAGS}" -o bin/cql-utils ${cql_utils_pkgpath} +tags="${platform} sqlite_omit_load_extension" +testtags="${platform} sqlite_omit_load_extension testbinary" -cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B ${GOLDFLAGS}" -tags "${platform} sqlite_omit_load_extension" -o bin/cqld ${cqld_pkgpath} -CGO_ENABLED=1 go test -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c -tags "${platform} sqlite_omit_load_extension testbinary" -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B ${GOLDFLAGS}" -o bin/cqld.test ${cqld_pkgpath} +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}" -cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-minerd ${cql_minerd_pkgpath} -CGO_ENABLED=1 go test -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c -tags "${platform} sqlite_omit_load_extension testbinary" -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M ${GOLDFLAGS}" -o bin/cql-minerd.test ${cql_minerd_pkgpath} +test_flags="-coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c" -cql_observer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-observer" -go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" -o bin/cql-observer ${cql_observer_pkgpath} -go test -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c -tags 'testbinary' -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" -o bin/cql-observer.test ${cql_observer_pkgpath} +export CGO_ENABLED=1 -cli_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql ${cli_pkgpath} +cql_utils_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-utils" +go build -ldflags "-X main.version=${version} ${GOLDFLAGS}" -o bin/cql-utils ${cql_utils_pkgpath} -fuse_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-fuse ${fuse_pkgpath} -cql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-adapter ${cql_adapter_pkgpath} +build_bp() { + cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld" + go build -ldflags "${ldflags_role_bp}" --tags "${tags}" -o bin/cqld ${cqld_pkgpath} + go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_bp}" -o bin/cqld.test ${cqld_pkgpath} +} + +build_miner() { + cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd" + go build -ldflags "${ldflags_role_miner}" --tags "${tags}" -o bin/cql-minerd ${cql_minerd_pkgpath} + go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_miner}" -o bin/cql-minerd.test ${cql_minerd_pkgpath} +} -cql_faucet_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-faucet ${cql_faucet_pkgpath} -cql_mysql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath} +build_client() { + cql_observer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-observer" + go build -ldflags "${ldflags_role_client}" -o bin/cql-observer ${cql_observer_pkgpath} + go test ${test_flags} -tags 'testbinary' -ldflags "${ldflags_role_client}" -o bin/cql-observer.test ${cql_observer_pkgpath} + + cli_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql" + go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql ${cli_pkgpath} + + fuse_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse" + go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-fuse ${fuse_pkgpath} + + cql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter" + go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-adapter ${cql_adapter_pkgpath} + + cql_faucet_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet" + go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-faucet ${cql_faucet_pkgpath} + + cql_mysql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter" + go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath} + + cql_explorer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer" + go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-explorer ${cql_explorer_pkgpath} +} -cql_explorer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer" -CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-explorer ${cql_explorer_pkgpath} +case $param in + "bp") + build_bp + ;; + 'miner') + build_miner + ;; + 'client') + build_client + ;; + *) + build_bp + build_miner + build_client + ;; +esac echo "done" diff --git a/test/GNTE/GNTE b/test/GNTE/GNTE index d34ad0da6..82ab29afb 160000 --- a/test/GNTE/GNTE +++ b/test/GNTE/GNTE @@ -1 +1 @@ -Subproject commit d34ad0da6cf6fb07065da2fb8e050366adb58123 +Subproject commit 82ab29afbb75cb89c196029d49d5df7aae74de4c diff --git a/test/GNTE/run.sh b/test/GNTE/run.sh index 69ca7800a..3afb4739d 100755 --- a/test/GNTE/run.sh +++ b/test/GNTE/run.sh @@ -1,11 +1,8 @@ #!/bin/bash -x -yaml[0]=./scripts/gnte_0ms.yaml -yaml[1]=./scripts/gnte_5ms.yaml -yaml[2]=./scripts/gnte_20ms.yaml -yaml[3]=./scripts/gnte_100ms.yaml -yaml[4]=./scripts/gnte_200ms.yaml - +yaml=( + ./scripts/gnte_{0,5,20,100,200}ms.yaml +) TEST_WD=$(cd $(dirname $0)/; pwd) PROJECT_DIR=$(cd ${TEST_WD}/../../; pwd)