Skip to content

Commit

Permalink
Merge PR cosmos#2318: Simplify version handling, rely on git describe
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio authored and cwgoes committed Sep 19, 2018
1 parent b74a6a9 commit 10b916e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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..."
Expand Down Expand Up @@ -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 ./...
Expand Down
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"regexp"
"testing"
"time"
Expand All @@ -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"
Expand All @@ -34,6 +36,7 @@ import (

func init() {
cryptoKeys.BcryptSecurityParameter = 1
version.Version = os.Getenv("VERSION")
}

func TestKeys(t *testing.T) {
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 2 additions & 7 deletions version/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
8 changes: 1 addition & 7 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -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 = ""

0 comments on commit 10b916e

Please sign in to comment.