Merge pull request #1888 from filecoin-project/feat/build-typ-version

Include build type in version
This commit is contained in:
Łukasz Magiera 2020-06-01 21:18:30 +02:00 committed by GitHub
commit c6b6c2990c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 44 additions and 17 deletions

View File

@ -17,7 +17,7 @@ MODULES:=
CLEAN:=
BINS:=
ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit='+git$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))'
ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit=+git.$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))
ifneq ($(strip $(LDFLAGS)),)
ldflags+=-extldflags=$(LDFLAGS)
endif

View File

@ -4,9 +4,11 @@ import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/stretchr/testify/assert"
)
type TestNode struct {
@ -62,9 +64,7 @@ func (ts *testSuite) testVersion(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if v.Version != build.BuildVersion {
t.Error("Version didn't work properly")
}
require.Equal(t, v.Version, build.BuildVersion)
}
func (ts *testSuite) testID(t *testing.T) {

View File

@ -16,6 +16,8 @@ func init() {
abi.RegisteredProof_StackedDRG2KiBSeal: {},
}
verifreg.MinVerifiedDealSize = big.NewInt(256)
BuildType |= Build2k
}
// Seconds

View File

@ -4,6 +4,7 @@ package build
func init() {
InsecurePoStValidation = true
BuildType |= BuildDebug
}
// NOTE: Also includes settings from params_2k

View File

@ -3,11 +3,33 @@ package build
import "fmt"
var CurrentCommit string
var BuildType int
const (
BuildDefault = 0
Build2k = 0x1
BuildDebug = 0x3
)
func buildType() string {
switch BuildType {
case BuildDefault:
return ""
case BuildDebug:
return "+debug"
case Build2k:
return "+2k"
default:
return "+huh?"
}
}
// BuildVersion is the local build version, set by build system
const BuildVersion = "0.4.0"
var UserVersion = BuildVersion + CurrentCommit
func UserVersion() string {
return BuildVersion + buildType() + CurrentCommit
}
type Version uint32

View File

@ -23,7 +23,9 @@ var versionCmd = &cli.Command{
if err != nil {
return err
}
fmt.Println(v)
fmt.Println("Daemon: ", v)
fmt.Print("Local: ")
cli.VersionPrinter(cctx)
return nil
},

View File

@ -78,7 +78,7 @@ func main() {
app := &cli.App{
Name: "lotus-bench",
Usage: "Benchmark performance of lotus on your hardware",
Version: build.UserVersion,
Version: build.UserVersion(),
Commands: []*cli.Command{
proveCmd,
sealBenchCmd,

View File

@ -29,7 +29,7 @@ func main() {
app := &cli.App{
Name: "lotus-chainwatch",
Usage: "Devnet token distribution utility",
Version: build.UserVersion,
Version: build.UserVersion(),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",

View File

@ -46,7 +46,7 @@ func main() {
app := &cli.App{
Name: "lotus-fountain",
Usage: "Devnet token distribution utility",
Version: build.UserVersion,
Version: build.UserVersion(),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",

View File

@ -36,7 +36,7 @@ func main() {
app := &cli.App{
Name: "lotus-health",
Usage: "Tools for monitoring lotus daemon health",
Version: build.UserVersion,
Version: build.UserVersion(),
Commands: local,
Flags: []cli.Flag{
&cli.StringFlag{

View File

@ -47,7 +47,7 @@ func main() {
app := &cli.App{
Name: "lotus-seal-worker",
Usage: "Remote storage miner worker",
Version: build.UserVersion,
Version: build.UserVersion(),
Flags: []cli.Flag{
&cli.StringFlag{
Name: FlagStorageRepo,

View File

@ -39,7 +39,7 @@ func main() {
app := &cli.App{
Name: "lotus-seed",
Usage: "Seal sectors for genesis miner",
Version: build.UserVersion,
Version: build.UserVersion(),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "sector-dir",

View File

@ -57,7 +57,7 @@ func main() {
app := &cli.App{
Name: "lotus-storage-miner",
Usage: "Filecoin decentralized storage network storage miner",
Version: build.UserVersion,
Version: build.UserVersion(),
EnableShellCompletion: true,
Flags: []cli.Flag{
&cli.StringFlag{

View File

@ -52,7 +52,7 @@ func main() {
app := &cli.App{
Name: "lotus",
Usage: "Filecoin decentralized storage network client",
Version: build.UserVersion,
Version: build.UserVersion(),
EnableShellCompletion: true,
Flags: []cli.Flag{
&cli.StringFlag{

View File

@ -100,7 +100,7 @@ func (a *CommonAPI) ID(context.Context) (peer.ID, error) {
func (a *CommonAPI) Version(context.Context) (api.Version, error) {
return api.Version{
Version: build.UserVersion,
Version: build.UserVersion(),
APIVersion: build.APIVersion,
BlockDelay: build.BlockDelay,

View File

@ -46,7 +46,7 @@ func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (RawHost,
libp2p.Peerstore(params.Peerstore),
libp2p.NoListenAddrs,
libp2p.Ping(true),
libp2p.UserAgent("lotus-" + build.UserVersion),
libp2p.UserAgent("lotus-" + build.UserVersion()),
}
for _, o := range params.Opts {
opts = append(opts, o...)