Merge PR #2318: Simplify version handling, rely on git describe
This commit is contained in:
parent
b74a6a9066
commit
10b916eb28
|
@ -154,6 +154,7 @@ jobs:
|
||||||
command: |
|
command: |
|
||||||
export PATH="$GOBIN:$PATH"
|
export PATH="$GOBIN:$PATH"
|
||||||
make install
|
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
|
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")
|
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"
|
GOCACHE=off go test -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -1,8 +1,8 @@
|
||||||
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
|
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
|
||||||
PACKAGES_SIMTEST=$(shell go list ./... | grep '/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_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)
|
GCC := $(shell command -v gcc 2> /dev/null)
|
||||||
LEDGER_ENABLED ?= true
|
LEDGER_ENABLED ?= true
|
||||||
UNAME_S := $(shell uname -s)
|
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
|
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/examples/democoin/cli_test` -tags=cli_test
|
||||||
|
|
||||||
test_unit:
|
test_unit:
|
||||||
@go test $(PACKAGES_NOSIMULATION)
|
@VERSION=$(VERSION) go test $(PACKAGES_NOSIMULATION)
|
||||||
|
|
||||||
test_race:
|
test_race:
|
||||||
@go test -race $(PACKAGES_NOSIMULATION)
|
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)
|
||||||
|
|
||||||
test_sim_modules:
|
test_sim_modules:
|
||||||
@echo "Running individual module simulations..."
|
@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
|
@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:
|
test_cover:
|
||||||
@bash tests/test_cover.sh
|
@export VERSION=$(VERSION); bash tests/test_cover.sh
|
||||||
|
|
||||||
test_lint:
|
test_lint:
|
||||||
gometalinter.v2 --config=tools/gometalinter.json ./...
|
gometalinter.v2 --config=tools/gometalinter.json ./...
|
||||||
|
|
|
@ -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)
|
* [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.
|
* [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
|
* 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
|
* SDK
|
||||||
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present.
|
* [tools] Make get_vendor_deps deletes `.vendor-new` directories, in case scratch files are present.
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -25,6 +26,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
tests "github.com/cosmos/cosmos-sdk/tests"
|
tests "github.com/cosmos/cosmos-sdk/tests"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
version "github.com/cosmos/cosmos-sdk/version"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||||
|
@ -34,6 +36,7 @@ import (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cryptoKeys.BcryptSecurityParameter = 1
|
cryptoKeys.BcryptSecurityParameter = 1
|
||||||
|
version.Version = os.Getenv("VERSION")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKeys(t *testing.T) {
|
func TestKeys(t *testing.T) {
|
||||||
|
@ -124,16 +127,16 @@ func TestVersion(t *testing.T) {
|
||||||
res, body := Request(t, port, "GET", "/version", nil)
|
res, body := Request(t, port, "GET", "/version", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
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)
|
require.Nil(t, err)
|
||||||
match := reg.MatchString(body)
|
match := reg.MatchString(body)
|
||||||
require.True(t, match, body)
|
require.True(t, match, body, fmt.Sprintf("%s", body))
|
||||||
|
|
||||||
// node info
|
// node info
|
||||||
res, body = Request(t, port, "GET", "/node_version", nil)
|
res, body = Request(t, port, "GET", "/node_version", nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
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)
|
require.Nil(t, err)
|
||||||
match = reg.MatchString(body)
|
match = reg.MatchString(body)
|
||||||
require.True(t, match, body)
|
require.True(t, match, body)
|
||||||
|
|
|
@ -17,15 +17,10 @@ var (
|
||||||
|
|
||||||
// return version of CLI/node and commit hash
|
// return version of CLI/node and commit hash
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
v := Version
|
return Version
|
||||||
if GitCommit != "" {
|
|
||||||
v = v + "-" + GitCommit
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMD
|
// CMD
|
||||||
func printVersion(cmd *cobra.Command, args []string) {
|
func printVersion(cmd *cobra.Command, args []string) {
|
||||||
v := GetVersion()
|
fmt.Println(GetVersion())
|
||||||
fmt.Println(v)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
//nolint
|
//nolint
|
||||||
package version
|
package version
|
||||||
|
|
||||||
const Maj = "0"
|
|
||||||
const Min = "24"
|
|
||||||
const Fix = "2"
|
|
||||||
|
|
||||||
const Version = "0.24.2"
|
|
||||||
|
|
||||||
// GitCommit set by build flags
|
// GitCommit set by build flags
|
||||||
var GitCommit = ""
|
var Version = ""
|
||||||
|
|
Loading…
Reference in New Issue