-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
*: add 'make revendor' and tests to catch incorrect glide usage #756
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import ( | |
"os" | ||
"path" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"gopkg.in/yaml.v2" | ||
|
@@ -96,13 +97,23 @@ func TestGlideYAMLPinsAllDependencies(t *testing.T) { | |
} | ||
} | ||
|
||
func TestRemoveVersionControl(t *testing.T) { | ||
func TestGlideVCUseLockFile(t *testing.T) { | ||
_, err := os.Stat("vendor/github.com/golang/protobuf/protoc-gen-go") | ||
if err != nil { | ||
t.Fatalf("vendor did not use glide-vc --use-lock-file. Revendor packages using 'make revendor' to use the correct glide and glide-vc flags") | ||
} | ||
} | ||
|
||
func TestGlideFlagsAndGlideVC(t *testing.T) { | ||
err := filepath.Walk("vendor", func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
t.Fatalf("walk: stat path %s failed: %v", path, err) | ||
} | ||
if info.IsDir() && filepath.Base(path) == ".git" { | ||
t.Fatalf(".git directory detected in vendor: %s. Revendor packages and remove version control data with 'glide update -s -v -u'", path) | ||
t.Fatalf(".git directory detected in vendor: %s. Revendor packages using 'make revendor' to use the correct glide and glide-vc flags", path) | ||
} | ||
if !info.IsDir() && strings.HasSuffix(path, "_test.go") { | ||
t.Fatalf("'_test.go' file detected in vendor: %s. Revendor packages using 'make revendor' to use the correct glide and glide-vc flags", path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this so we avoid vendors from introducing their own tests into our code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. glide-vc has a mode that deletes all test files from the |
||
} | ||
return nil | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth checking the version of glide used too, if you're trying to catch mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda already addressed in our documentation.
If we ever need something that was added in a specific version of glide we can add a script similar to
scripts/check-go-version
, but I don't really want to write a bunch ofsed
commands right now :/