Merge PR #2318: Simplify version handling, rely on git describe

This commit is contained in:
Alessio Treglia 2018-09-19 17:03:04 +01:00 committed by Christopher Goes
parent b74a6a9066
commit 10b916eb28
6 changed files with 16 additions and 22 deletions

View File

@ -154,6 +154,7 @@ jobs:
command: |
export PATH="$GOBIN:$PATH"
make install
export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
for pkg in $(go list github.com/cosmos/cosmos-sdk/... | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test | grep -v '/simulation' | circleci tests split --split-by=timings); do
id=$(basename "$pkg")
GOCACHE=off go test -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"

View File

@ -1,8 +1,8 @@
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
COMMIT_HASH := $(shell git rev-parse --short HEAD)
VERSION := $(shell git describe --tags --long | sed 's/v\(.*\)/\1/')
BUILD_TAGS = netgo ledger
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION}"
GCC := $(shell command -v gcc 2> /dev/null)
LEDGER_ENABLED ?= true
UNAME_S := $(shell uname -s)
@ -142,10 +142,10 @@ test_examples:
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/examples/democoin/cli_test` -tags=cli_test
test_unit:
@go test $(PACKAGES_NOSIMULATION)
@VERSION=$(VERSION) go test $(PACKAGES_NOSIMULATION)
test_race:
@go test -race $(PACKAGES_NOSIMULATION)
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)
test_sim_modules:
@echo "Running individual module simulations..."
@ -175,7 +175,7 @@ test_sim_gaia_profile:
@go test -benchmem -run=^$$ github.com/cosmos/cosmos-sdk/cmd/gaia/app -bench ^BenchmarkFullGaiaSimulation$$ -SimulationEnabled=true -SimulationNumBlocks=$(SIM_NUM_BLOCKS) -SimulationBlockSize=$(SIM_BLOCK_SIZE) -SimulationCommit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out
test_cover:
@bash tests/test_cover.sh
@export VERSION=$(VERSION); bash tests/test_cover.sh
test_lint:
gometalinter.v2 --config=tools/gometalinter.json ./...

View File

@ -107,6 +107,7 @@ IMPROVEMENTS
* [x/stake] Improve speed of GetValidator, which was shown to be a performance bottleneck. [#2046](https://github.com/tendermint/tendermint/pull/2200)
* [genesis] \#2229 Ensure that there are no duplicate accounts or validators in the genesis state.
* Add SDK validation to `config.toml` (namely disabling `create_empty_blocks`) \#1571
* \#1941(https://github.com/cosmos/cosmos-sdk/issues/1941) Version is now inferred via `git describe --tags`.
* SDK
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present.

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"regexp"
"testing"
"time"
@ -25,6 +26,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
tests "github.com/cosmos/cosmos-sdk/tests"
sdk "github.com/cosmos/cosmos-sdk/types"
version "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/gov"
@ -34,6 +36,7 @@ import (
func init() {
cryptoKeys.BcryptSecurityParameter = 1
version.Version = os.Getenv("VERSION")
}
func TestKeys(t *testing.T) {
@ -124,16 +127,16 @@ func TestVersion(t *testing.T) {
res, body := Request(t, port, "GET", "/version", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
reg, err := regexp.Compile(`\d+\.\d+\.\d+(-dev)?`)
reg, err := regexp.Compile(`\d+\.\d+\.\d+.*`)
require.Nil(t, err)
match := reg.MatchString(body)
require.True(t, match, body)
require.True(t, match, body, fmt.Sprintf("%s", body))
// node info
res, body = Request(t, port, "GET", "/node_version", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
reg, err = regexp.Compile(`\d+\.\d+\.\d+(-dev)?`)
reg, err = regexp.Compile(`\d+\.\d+\.\d+.*`)
require.Nil(t, err)
match = reg.MatchString(body)
require.True(t, match, body)

View File

@ -17,15 +17,10 @@ var (
// return version of CLI/node and commit hash
func GetVersion() string {
v := Version
if GitCommit != "" {
v = v + "-" + GitCommit
}
return v
return Version
}
// CMD
func printVersion(cmd *cobra.Command, args []string) {
v := GetVersion()
fmt.Println(v)
fmt.Println(GetVersion())
}

View File

@ -1,11 +1,5 @@
//nolint
package version
const Maj = "0"
const Min = "24"
const Fix = "2"
const Version = "0.24.2"
// GitCommit set by build flags
var GitCommit = ""
var Version = ""