*: add 'make revendor' and tests to catch incorrect glide usage
Introducing glide-vc caused us to unknowingly removed our Go protobuf compiler (since it's a main). Add flags to glide-vc usage to remedy this. Since we now require several glide and glide-vc flags, add a Makfile target and tests to catch when PRs don't use the correct flags.
This commit is contained in:
parent
54afc8f1d2
commit
d87a4c35b9
@ -15,11 +15,10 @@ To add a new dependency to dex or update an existing one:
|
|||||||
|
|
||||||
Tests will fail if transitive dependencies aren't included.
|
Tests will fail if transitive dependencies aren't included.
|
||||||
|
|
||||||
Once `glide.yaml` describes the desired state use glide and glide-vc to update `glide.lock` and `vendor`.
|
Once `glide.yaml` describes the desired state use `make` to update `glide.lock` and `vendor`. This calls both `glide` and `glide-vc` with the set of flags that dex requires.
|
||||||
|
|
||||||
```
|
```
|
||||||
glide up -v
|
make revendor
|
||||||
glide-vc
|
|
||||||
```
|
```
|
||||||
|
|
||||||
When composing commits make sure that updates to `vendor` are in a separate commit from the main changes. GitHub's UI makes commits with a large number of changes unreviewable.
|
When composing commits make sure that updates to `vendor` are in a separate commit from the main changes. GitHub's UI makes commits with a large number of changes unreviewable.
|
||||||
|
5
Makefile
5
Makefile
@ -35,6 +35,11 @@ bin/example-app: check-go-version
|
|||||||
release-binary:
|
release-binary:
|
||||||
@go build -o _output/bin/dex -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
|
@go build -o _output/bin/dex -v -ldflags $(LD_FLAGS) $(REPO_PATH)/cmd/dex
|
||||||
|
|
||||||
|
.PHONY: revendor
|
||||||
|
revendor:
|
||||||
|
@glide up -v
|
||||||
|
@glide-vc --use-lock-file --no-tests --only-code
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@go test -v -i $(shell go list ./... | grep -v '/vendor/')
|
@go test -v -i $(shell go list ./... | grep -v '/vendor/')
|
||||||
@go test -v $(shell go list ./... | grep -v '/vendor/')
|
@go test -v $(shell go list ./... | grep -v '/vendor/')
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"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 {
|
err := filepath.Walk("vendor", func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("walk: stat path %s failed: %v", path, err)
|
t.Fatalf("walk: stat path %s failed: %v", path, err)
|
||||||
}
|
}
|
||||||
if info.IsDir() && filepath.Base(path) == ".git" {
|
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)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user