Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server and CLI use version from release and versionChecking constant and commit revision #4308

Merged
merged 13 commits into from
Jul 31, 2021
Prev Previous commit
Next Next commit
fix all
  • Loading branch information
longquanzheng committed Jul 31, 2021
commit a6c3f755c4f82489a33d0125fee5057a166cdf30
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ import (

// main entry point for the cadence server
func main() {
app := cadence.BuildCLI(metrics.Version, metrics.Revision)
app := cadence.BuildCLI(metrics.ReleaseVersion, metrics.Revision)
app.Run(os.Args)
}
2 changes: 1 addition & 1 deletion common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,4 @@ const StickyTaskConditionFailedErrorMsg = "StickyTaskConditionFailedError"
const MemoKeyForOperator = "operator"

// ReservedTaskListPrefix is the required naming prefix for any task list partition other than partition 0
const ReservedTaskListPrefix = "/__cadence_sys/"
const ReservedTaskListPrefix = "/__cadence_sys/"
8 changes: 4 additions & 4 deletions common/metrics/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ var (
// Revision is the VCS revision associated with this build. Overridden using ldflags
// at compile time. Example:
// $ go build -ldflags "-X github.com/uber/cadence/common/metrics.Revision=abcdef" ...
// Adapted from: https://www.atatus.com/blog/golang-auto-build-versioning/
// see go-build-ldflags.sh for GIT_REVISION
Revision = "unknown"

// Branch is the VCS branch associated with this build.
Branch = "unknown"

// Version is the version associated with this build.
Version = "unknown"
// ReleaseVersion is the version associated with this build.
ReleaseVersion = "unknown"

// BuildDate is the date this build was created.
BuildDate = "unknown"
Expand Down Expand Up @@ -102,7 +102,7 @@ func NewRuntimeMetricsReporter(
revisionTag: Revision,
branchTag: Branch,
buildDateTag: BuildDate,
buildVersionTag: Version,
buildVersionTag: ReleaseVersion,
goVersionTag: goVersion,
},
)
Expand Down
15 changes: 8 additions & 7 deletions scripts/go-build-ldflags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ if [ "$MODE" != "LDFLAG" ] && [ "$MODE" != "ECHO" ]; then
exit 1
fi

export GIT_REVISION=$(git rev-parse --short HEAD)
# $(git rev-parse --short HEAD) \"$(git log -1 --format=%cI-%h)\"
export GIT_REVISION=$(git log -1 --format=%cI-%h) # use commit date time and hash: e.g. 2021-07-27 19:36:53 -0700-40c5f1896, doc: https://git-scm.com/docs/pretty-formats
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
export BUILD_DATE=$(date '+%F-%T') # outputs something in this format 2017-08-21-18:58:45
export BUILD_TS_UNIX=$(date '+%s') # second since epoch
export BASE_PACKAGE=github.com/uber/cadence/common/metrics
if [ -z ${SERVER_VERSION} ]; then
# If not set SERVER_VERSION, then use the most recent tag.
export GIT_VERSION=$(git describe --tags --abbrev=0 --dirty 2>/dev/null || echo unknown)
if [ -z ${CADENCE_RELEASE_VERSION} ]; then
# If not set CADENCE_RELEASE_VERSION, then use the most recent tag.
export RELEASE_VERSION=$(git describe --tags --abbrev=0 --dirty 2>/dev/null || echo unknown)
else
# If passing a version explicitly, then use it
export GIT_VERSION=${SERVER_VERSION}
# If passing a CADENCE_RELEASE_VERSION explicitly, then use it
export RELEASE_VERSION=${CADENCE_RELEASE_VERSION}
fi


if [ "$MODE" = "LDFLAG" ]; then
LD_FLAGS="-X ${BASE_PACKAGE}.Revision=${GIT_REVISION} \
-X ${BASE_PACKAGE}.Branch=${GIT_BRANCH} \
-X ${BASE_PACKAGE}.Version=${GIT_VERSION} \
-X ${BASE_PACKAGE}.ReleaseVersion=${RELEASE_VERSION} \
-X ${BASE_PACKAGE}.BuildDate=${BUILD_DATE} \
-X ${BASE_PACKAGE}.BuildTimeUnix=${BUILD_TS_UNIX}"

Expand Down
6 changes: 3 additions & 3 deletions tools/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func SetFactory(factory ClientFactory) {

// NewCliApp instantiates a new instance of the CLI application.
func NewCliApp() *cli.App {
version := fmt.Sprintf("CLI version: %v (for compatibility checking between server and client/CLI)\n"+
version := fmt.Sprintf("CLI feature version: %v \n"+
" Release version:%v\n"+
" Build revision:%v\n"+
" Note: server is always backward compatible to older CLI versions, but not accepting newer than it can support.",
client.SupportedCLIVersion, metrics.Version, metrics.Revision)
" Note: CLI feature version is for compatibility checking between server and CLI if enabled feature checking. Server is always backward compatible to older CLI versions, but not accepting newer than it can support.",
client.SupportedCLIVersion, metrics.ReleaseVersion, metrics.Revision)

app := cli.NewApp()
app.Name = "cadence"
Expand Down