-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set version in source instead of injecting via ldflags (#956)
* Set version in source instead of injecting via ldflags * Update version number and compatibility rules * Add version tests * Fix tests * Received version 0.0.0 is compatible with whatever we have * Add IsCompatible tests for 0.0.0 * Lint fix * Add Prerelease to protocol definition * Compile protobuf with the correct version of protoc * Fix IsCompatible test * Update protoc and related package versions so that they match everywhere * One more protoc fix * Another protoc fix * More explicit error message with incompatible node version * Version 0.0.0 should be compatible both ways * Add DISABLE_VERSION_CHECK env var and hack regression.yml to unblock * Lint fix * Fix version numbers in regression test
- Loading branch information
Showing
16 changed files
with
246 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package common | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestVersionStringNoPre(t *testing.T) { | ||
var version = Version{ | ||
Major: 1, | ||
Minor: 2, | ||
Patch: 3, | ||
Prerelease: "", | ||
} | ||
|
||
actual := version.String() | ||
expected := "1.2.3" | ||
|
||
if actual != expected { | ||
t.Fatalf("Incorrect version string. Actual: %s, expected: %s", actual, expected) | ||
} | ||
} | ||
|
||
func TestVersionStringPre(t *testing.T) { | ||
version := Version{ | ||
Major: 1, | ||
Minor: 2, | ||
Patch: 3, | ||
Prerelease: "pre", | ||
} | ||
|
||
actual := version.String() | ||
expected := "1.2.3+pre" | ||
|
||
if actual != expected { | ||
t.Fatalf("Incorrect version string. Actual: %s, expected: %s", actual, expected) | ||
} | ||
} | ||
|
||
func TestVersionCompatible(t *testing.T) { | ||
version000 := Version{ | ||
Major: 0, | ||
Minor: 0, | ||
Patch: 0, | ||
Prerelease: "", | ||
} | ||
|
||
version123 := Version{ | ||
Major: 1, | ||
Minor: 2, | ||
Patch: 3, | ||
Prerelease: "", | ||
} | ||
|
||
version124 := Version{ | ||
Major: 1, | ||
Minor: 2, | ||
Patch: 4, | ||
Prerelease: "", | ||
} | ||
|
||
version123pre := Version{ | ||
Major: 1, | ||
Minor: 2, | ||
Patch: 3, | ||
Prerelease: "+pre", | ||
} | ||
|
||
version130 := Version{ | ||
Major: 1, | ||
Minor: 3, | ||
Patch: 0, | ||
Prerelease: "", | ||
} | ||
|
||
version130pre := Version{ | ||
Major: 1, | ||
Minor: 3, | ||
Patch: 0, | ||
Prerelease: "pre", | ||
} | ||
|
||
version200 := Version{ | ||
Major: 2, | ||
Minor: 0, | ||
Patch: 0, | ||
Prerelease: "", | ||
} | ||
|
||
testCompatible := func(a Version, b Version) { | ||
if !a.IsCompatible(b) || !b.IsCompatible(a) { | ||
t.Fatalf("Version %s should be compatible with %s", a, b) | ||
} | ||
} | ||
|
||
testIncompatible := func(a Version, b Version) { | ||
if a.IsCompatible(b) || b.IsCompatible(a) { | ||
t.Fatalf("Version %s should not be compatible with %s", a, b) | ||
} | ||
} | ||
|
||
testCompatible(version123, version123) | ||
testCompatible(version123, version123pre) | ||
testCompatible(version123, version124) | ||
|
||
testIncompatible(version123, version130) | ||
testIncompatible(version123, version130pre) | ||
testIncompatible(version123, version200) | ||
testIncompatible(version123pre, version130pre) | ||
|
||
t.Setenv("DISABLE_VERSION_CHECK", "1") | ||
testCompatible(version123, version000) | ||
testCompatible(version123pre, version000) | ||
testCompatible(version124, version000) | ||
testCompatible(version130, version000) | ||
testCompatible(version130pre, version000) | ||
testCompatible(version200, version000) | ||
testCompatible(version123, version130) | ||
testCompatible(version123, version130pre) | ||
testCompatible(version123, version200) | ||
testCompatible(version123pre, version130pre) | ||
} |
Oops, something went wrong.