Skip to content

Commit

Permalink
cdc compile version (#201)
Browse files Browse the repository at this point in the history
Signed-off-by: haojinming <[email protected]>
  • Loading branch information
haojinming authored Aug 10, 2022
1 parent 0a4ace4 commit 1d8847b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions br/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
func removeVAndHash(v string) string {
v = versionHash.ReplaceAllLiteralString(v, "")
v = strings.TrimSuffix(v, "-dirty")
v = strings.TrimPrefix(v, "br-") // tag is named with br-vx.x.x
return strings.TrimPrefix(v, "v")
}

Expand Down
15 changes: 12 additions & 3 deletions br/pkg/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestCheckClusterVersion(t *testing.T) {
}

{
build.ReleaseVersion = "v0.1"
build.ReleaseVersion = "br-v0.1"
mock.getAllStores = func() []*metapb.Store {
return tiflash("v4.0.0-rc.1")
}
Expand All @@ -56,7 +56,7 @@ func TestCheckClusterVersion(t *testing.T) {
}

{
build.ReleaseVersion = "v3.1.0-beta.2"
build.ReleaseVersion = "br-v3.1.0-beta.2"
mock.getAllStores = func() []*metapb.Store {
return []*metapb.Store{{Version: minTiKVVersion.String()}}
}
Expand All @@ -65,7 +65,16 @@ func TestCheckClusterVersion(t *testing.T) {
}

{
build.ReleaseVersion = "v0.1.0"
build.ReleaseVersion = "rb-v3.1.0-beta.2"
mock.getAllStores = func() []*metapb.Store {
return []*metapb.Store{{Version: minTiKVVersion.String()}}
}
err := CheckClusterVersion(context.Background(), &mock, CheckVersionForBR)
require.Regexp(t, `rb is not in dotted-tri format`, err.Error())
}

{
build.ReleaseVersion = "br-v0.1.0"
mock.getAllStores = func() []*metapb.Store {
return []*metapb.Store{{Version: "v6.1.0"}}
}
Expand Down
4 changes: 2 additions & 2 deletions cdc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ FAILPOINT_DISABLE := $$(echo $(FAILPOINT_DIR) | xargs $(FAILPOINT) disable >/dev
RELEASE_VERSION =
ifeq ($(RELEASE_VERSION),)
RELEASE_VERSION := v1.0.0-master
release_version_regex := ^v[0-9]\..*$$
release_branch_regex := "^release-[0-9]\.[0-9].*$$|^HEAD$$|^.*/*tags/v[0-9]\.[0-9]\..*$$"
release_version_regex := ^cdc-v[0-9]\..*$$
release_branch_regex := "^cdc-[0-9]\.[0-9].*$$|^HEAD$$|^.*/*tags/cdc-v[0-9]\.[0-9]\..*$$"
ifneq ($(shell git rev-parse --abbrev-ref HEAD | egrep $(release_branch_regex)),)
# If we are in release branch, try to use tag version.
ifneq ($(shell git describe --tags --dirty | egrep $(release_version_regex)),)
Expand Down
1 change: 1 addition & 0 deletions cdc/pkg/version/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func removeVAndHash(v string) string {
}
v = versionHash.ReplaceAllLiteralString(v, "")
v = strings.TrimSuffix(v, "-dirty")
v = strings.TrimPrefix(v, "cdc-") // tag is named with cdc-vx.x.x
return strings.TrimPrefix(v, "v")
}

Expand Down

0 comments on commit 1d8847b

Please sign in to comment.