Skip to content

Commit

Permalink
Only install dependencies once for examples (uber-go#123)
Browse files Browse the repository at this point in the history
* Only install dependencies once for examples

Fixes uber-go#118
  • Loading branch information
Aiden Scandella authored Dec 12, 2016
1 parent c9cc32e commit 6700076
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .build/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ERRCHECK_FLAGS := -ignorepkg example -ignore "fmt.*,io:WriteString" -ignoretests
lint:
$(ECHO_V)rm -rf $(LINT_LOG)
@echo "Generating code"
$(ECHO_V)make -C examples/keyvalue kv/types.go ECHO_V=$(ECHO_V)
$(ECHO_V)make examples
@echo "Installing test dependencies for vet..."
$(ECHO_V)go test -i $(PKGS)
@echo "Removing YARPC generated code"
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor \
TEST_TIMEOUT := "-timeout=3s"

.PHONY: test
test:
$(ECHO_V)$(MAKE) -C examples/keyvalue/ kv/types.go ECHO_V=$(ECHO_V)
test: examples
$(ECHO_V)go test $(RACE) $(TEST_TIMEOUT) $(PKGS)
$(ECHO_V)$(MAKE) $(COV_REPORT)

Expand All @@ -45,9 +44,6 @@ endif
COVER_OUT := profile.coverprofile

$(COV_REPORT): $(PKG_FILES) $(ALL_SRC)
@$(call label,Generating example RPC bindings)
@echo
$(ECHO_V)$(MAKE) -C examples/keyvalue/ kv/types.go ECHO_V=$(ECHO_V)
@$(call label,Running tests)
@echo
$(ECHO_V)$(OVERALLS) -project=$(PROJECT_ROOT) \
Expand Down Expand Up @@ -121,8 +117,18 @@ gendoc:
xargs -I% md-to-godoc -input=%

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

.PHONY: examples
examples:
@$(call label,Installing thriftrw and YARPC plugins)
@echo
$(ECHO_V)test -d vendor || $(MAKE) libdeps
$(ECHO_V)which thriftrw >/dev/null || go install ./vendor/go.uber.org/thriftrw
$(ECHO_V)which thriftrw-plugin-yarpc >/dev/null || go install ./vendor/go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc
@$(call label,Generating example RPC bindings)
@echo
$(ECHO_)$(MAKE) -C examples/keyvalue kv/types.go ECHO_V=$(ECHO_V)
11 changes: 1 addition & 10 deletions examples/keyvalue/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
.PHONY: deps
deps:
@echo "Installing UberFx dependencies..."
$(ECHO_V)$(MAKE) -C ../.. libdeps
@echo "Installing thriftrw..."
$(ECHO_V)go install ../../vendor/go.uber.org/thriftrw
@echo "Installing thriftrw-plugin-yarpc..."
$(ECHO_V)go install ../../vendor/go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc

kv/types.go: kv.thrift deps
kv/types.go: kv.thrift
$(ECHO_V)go generate

server/server: $(wildcard server/*.go) kv/types.go
Expand Down
3 changes: 3 additions & 0 deletions examples/keyvalue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# KeyValue example

Run `make examples` from the root of this project to build this example.
26 changes: 26 additions & 0 deletions examples/keyvalue/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Package keyvalue is the KeyValue example.
//
// Run make examples from the root of this project to build this example.
//
//
package keyvalue

0 comments on commit 6700076

Please sign in to comment.