Skip to content

Commit

Permalink
Use go modules (#454)
Browse files Browse the repository at this point in the history
* Initial mod init

* mode

* fix broken tests

* cleanup lint

* Remove unused stuff from makefiles

* Remove glide files

* make it v3.4.31
  • Loading branch information
phliar committed Mar 9, 2021
1 parent dde02e6 commit 53d1ffd
Show file tree
Hide file tree
Showing 15 changed files with 369 additions and 507 deletions.
21 changes: 4 additions & 17 deletions .build/deps.mk
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
.PHONY: libdeps
libdeps:
@$(call label,Installing Glide and locked dependencies...)
$(ECHO_V)glide --version 2>/dev/null || go get -u -f github.com/Masterminds/glide
$(ECHO_V)glide install
modvendor:
@$(call label,Updating vendor mod...)
$(ECHO_V)go mod vendor

.PHONY: deps
deps: libdeps
@$(call label,Installing test dependencies...)
$(ECHO_V)go install ./vendor/github.com/axw/gocov/gocov
$(ECHO_V)go install ./vendor/github.com/matm/gocov-html
$(ECHO_V)go install ./vendor/github.com/mattn/goveralls
$(ECHO_V)go install ./vendor/github.com/go-playground/overalls
deps: modvendor
@$(call label,Installing golint...)
$(ECHO_V)go install ./vendor/golang.org/x/lint/golint
@$(call label,Installing errcheck...)
$(ECHO_V)go install ./vendor/github.com/kisielk/errcheck
@$(call label,Installing md-to-godoc...)
$(ECHO_V)go install ./vendor/github.com/sectioneight/md-to-godoc

GOCOV := gocov
OVERALLS := overalls
6 changes: 0 additions & 6 deletions .build/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ lint: vendor
$(ECHO_V)go test -i $(PKGS)
@echo "Checking formatting..."
@$(MAKE) fmt
@echo "Checking vet..."
$(ECHO_V)$(foreach dir,$(PKG_FILES),go tool vet $(VET_RULES) $(dir) 2>&1 | $(FILTER_LINT) | tee -a $(LINT_LOG);)
@echo "Checking lint..."
$(ECHO_V)$(foreach dir,$(PKGS),golint $(dir) 2>&1 | $(FILTER_LINT) | tee -a $(LINT_LOG);)
@echo "Checking unchecked errors..."
Expand All @@ -29,7 +27,3 @@ lint: vendor
$(ECHO_V)git grep -w -i fixme | grep -v -e $(_THIS_MAKEFILE) -e CONTRIBUTING.md | tee -a $(LINT_LOG)
@echo "Checking for imports of log package"
$(ECHO_V)go list -f '{{ .ImportPath }}: {{ .Imports }}' $(shell glide nv) | grep -e "\blog\b" | tee -a $(LINT_LOG)
@echo "Ensuring generated doc.go are up to date"
$(ECHO_V)$(MAKE) gendoc
$(ECHO_V)[ -z "$(shell git status --porcelain | grep '\bdoc.go$$')" ] || echo "Commit updated doc.go changes" | tee -a $(LINT_LOG)
$(ECHO_V)[ ! -s $(LINT_LOG) ]
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Changelog

## v3.4.31 (unreleased)
## v3.4.32 (unreleased)
- Nothing changed yet.

## v3.4.31 (2021-03-08)
- Migrate to go modules.

## v3.4.30 (2020-11-03)
- Plumb through FieldTag into the YARPC connector.
- Add field tag "maxlen" to define the max. size of a field.
Expand Down
53 changes: 1 addition & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ include $(SUPPORT_FILES)/verbosity.mk
all: lint test
.DEFAULT_GOAL := all

COVER_OUT := profile.coverprofile

# all .go files that don't exist in hidden directories
ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor \
-e ".*/\..*" \
Expand All @@ -23,63 +21,14 @@ TEST_TIMEOUT := "-timeout=60s"
.PHONY: test
test: clean vendor
$(ECHO_V)go test $(RACE) $(TEST_TIMEOUT) $(PKGS)
$(ECHO_V)$(MAKE) $(COV_REPORT)

TEST_IGNORES = vendor .git
COVER_IGNORES = $(TEST_IGNORES)

comma := ,
null :=
space := $(null) #
OVERALLS_IGNORE = $(subst $(space),$(comma),$(strip $(COVER_IGNORES)))

ifeq ($(V),0)
_FILTER_OVERALLS = cat
else
_FILTER_OVERALLS = grep -v "^Processing:"
endif

COV_REPORT := overalls.coverprofile

$(COV_REPORT): $(PKG_FILES) $(ALL_SRC)
@$(call label,Running tests)
@echo
$(ECHO_V)$(OVERALLS) -project=$(PROJECT_ROOT) \
-ignore "$(OVERALLS_IGNORE)" \
-covermode=atomic \
$(DEBUG_FLAG) -- \
$(TEST_FLAGS) $(RACE) $(TEST_TIMEOUT) $(TEST_VERBOSITY_FLAG) | \
grep -v "No Go Test files" | \
$(_FILTER_OVERALLS)
$(ECHO_V)if [ -a $(COV_REPORT) ]; then \
$(GOCOV) convert $@ | $(GOCOV) report ; \
fi

COV_HTML := coverage.html

$(COV_HTML): $(COV_REPORT)
$(ECHO_V)$(GOCOV) convert $< | gocov-html > $@

.PHONY: coveralls
coveralls: $(COV_REPORT)
$(ECHO_V)goveralls -service=travis-ci -coverprofile=$(COV_REPORT)

include $(SUPPORT_FILES)/lint.mk

.PHONY: gendoc
gendoc:
$(ECHO_V)find . \( \
-path ./vendor -o \
-path ./ccm -o \
-path ./node_modules -o \
-path ./.glide \
\) -prune -o -name README.md -print | \
xargs -I% md-to-godoc -input=%

.PHONY: clean
clean:
$(ECHO_V)rm -f $(COV_REPORT) $(COV_HTML) $(LINT_LOG)
$(ECHO_V)find $(subst /...,,$(PKGS)) -name $(COVER_OUT) -delete
$(ECHO_V)rm -f $(LINT_LOG)

.PHONY: vendor
vendor:
Expand Down
1 change: 1 addition & 0 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func (op Operator) String() string {
}
}

// Symbol returns the symbol of the operator.
func (op Operator) Symbol() string {
switch op {
case Eq:
Expand Down
2 changes: 1 addition & 1 deletion connectors/cache/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func newConnector(origin, fallback dosa.Connector, scope metrics.Scope, encoder
encoder: encoder,
cacheableEntities: set,
cacheableEndpointStatus: cacheableEndpointStatus,
stats: scope,
stats: scope,
}
}

Expand Down
11 changes: 6 additions & 5 deletions connectors/memory/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package memory

import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"sort"
Expand Down Expand Up @@ -945,7 +946,7 @@ func TestConnector_Scan(t *testing.T) {
// first, insert some random UUID values into two partition keys
for x := 0; x < idcount; x++ {
err := sut.Upsert(context.TODO(), clusteredEi, map[string]dosa.FieldValue{
"f1": dosa.FieldValue("data" + string(x%2)),
"f1": dosa.FieldValue(fmt.Sprintf("data%d", x%2)),
"c1": dosa.FieldValue(int64(1)),
"c7": dosa.FieldValue(testUUIDs[x])})
assert.NoError(t, err)
Expand All @@ -959,7 +960,7 @@ func TestConnector_Scan(t *testing.T) {
// there's an odd edge case when you delete everything, so do that, then call scan
for x := 0; x < idcount; x++ {
err := sut.Remove(context.TODO(), clusteredEi, map[string]dosa.FieldValue{
"f1": dosa.FieldValue("data" + string(x%2)),
"f1": dosa.FieldValue(fmt.Sprintf("data%d", x%2)),
"c1": dosa.FieldValue(int64(1)),
"c7": dosa.FieldValue(testUUIDs[x])})
assert.NoError(t, err)
Expand All @@ -974,7 +975,7 @@ func TestConnector_ScanWithToken(t *testing.T) {
sut := NewConnector()
const idcount = 100
createTestData(t, sut, func(id int) string {
return "data" + string(id%3)
return fmt.Sprintf("data%d", id%3)
}, idcount)
var token string
var err error
Expand Down Expand Up @@ -1009,7 +1010,7 @@ func TestConnector_ScanWithTokenFromWrongTable(t *testing.T) {
sut := NewConnector()
const idcount = 100
createTestData(t, sut, func(id int) string {
return "data" + string(id%3)
return fmt.Sprintf("data%d", id%3)
}, idcount)
err := sut.Upsert(context.TODO(), testEi, map[string]dosa.FieldValue{
"p1": dosa.FieldValue("test"),
Expand All @@ -1035,7 +1036,7 @@ func TestConnector_ScanWithTokenNoClustering(t *testing.T) {
const idcount = 100
for x := 0; x < idcount; x++ {
sut.Upsert(context.TODO(), testEi, map[string]dosa.FieldValue{
"p1": dosa.FieldValue("data" + string(x)),
"p1": dosa.FieldValue(fmt.Sprintf("data%d", x)),
})
}
var token string
Expand Down
11 changes: 6 additions & 5 deletions connectors/routing/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package routing

import (
"context"
"fmt"
"reflect"
"sort"
"strings"
Expand Down Expand Up @@ -754,7 +755,7 @@ func TestConnector_Scan(t *testing.T) {
// first, insert some random UUID values into two partition keys
for x := 0; x < idcount; x++ {
err := rc.Upsert(ctx, clusteredEi, map[string]dosa.FieldValue{
"f1": dosa.FieldValue("data" + string(x%2)),
"f1": dosa.FieldValue(fmt.Sprintf("data%d", x%2)),
"c1": dosa.FieldValue(int64(1)),
"c7": dosa.FieldValue(testUUIDs[x])})
assert.NoError(t, err)
Expand All @@ -768,7 +769,7 @@ func TestConnector_Scan(t *testing.T) {
// there's an odd edge case when you delete everything, so do that, then call scan
for x := 0; x < idcount; x++ {
err := rc.Remove(ctx, clusteredEi, map[string]dosa.FieldValue{
"f1": dosa.FieldValue("data" + string(x%2)),
"f1": dosa.FieldValue(fmt.Sprintf("data%d", x%2)),
"c1": dosa.FieldValue(int64(1)),
"c7": dosa.FieldValue(testUUIDs[x])})
assert.NoError(t, err)
Expand Down Expand Up @@ -850,7 +851,7 @@ func TestConnector_ScanWithToken(t *testing.T) {
rc := NewConnector(cfg, connectorMap)

createTestData(t, rc, func(id int) string {
return "data" + string(id%3)
return fmt.Sprintf("data%d", id%3)
}, idcount)
var token string
var err error
Expand Down Expand Up @@ -886,7 +887,7 @@ func TestConnector_ScanWithTokenFromWrongTable(t *testing.T) {
rc := NewConnector(cfg, connectorMap)

createTestData(t, rc, func(id int) string {
return "data" + string(id%3)
return fmt.Sprintf("data%d", id%3)
}, idcount)
err := rc.Upsert(ctx, testInfo, map[string]dosa.FieldValue{
"p1": dosa.FieldValue("test"),
Expand All @@ -911,7 +912,7 @@ func TestConnector_ScanWithTokenNoClustering(t *testing.T) {

for x := 0; x < idcount; x++ {
rc.Upsert(ctx, testInfo, map[string]dosa.FieldValue{
"p1": dosa.FieldValue("data" + string(x)),
"p1": dosa.FieldValue(fmt.Sprintf("data%d", x)),
})
}
var token string
Expand Down
Loading

0 comments on commit 53d1ffd

Please sign in to comment.