From 0565479e8cc4c12c96cd2d9327b8edd51f5b7e6a Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Sat, 16 Jan 2016 11:56:34 -0800 Subject: [PATCH 1/3] Build example app in container. --- Makefile | 1 + experimental/example/Makefile | 14 ++++-- .../vendor/github.com/richo/GOSHOUT/README.MD | 1 + .../vendor/github.com/richo/GOSHOUT/SHOUT.go | 46 +++++++++++++++++++ experimental/example/vendor/manifest | 11 +++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 experimental/example/vendor/github.com/richo/GOSHOUT/README.MD create mode 100644 experimental/example/vendor/github.com/richo/GOSHOUT/SHOUT.go create mode 100644 experimental/example/vendor/manifest diff --git a/Makefile b/Makefile index fe98f258f..516800843 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,7 @@ clean: deps: go get -u -f -tags netgo \ + github.com/FiloSottile/gvt \ github.com/mattn/goveralls \ github.com/mjibson/esc \ github.com/weaveworks/github-release diff --git a/experimental/example/Makefile b/experimental/example/Makefile index 00b8085e8..17f943633 100644 --- a/experimental/example/Makefile +++ b/experimental/example/Makefile @@ -1,19 +1,27 @@ CC=gcc CFLAGS=-g -lpthread +BUILD_IN_CONTAINER=true all: qotd.marker app.marker client.marker searchapp.marker shout.marker frontend.marker echo.marker +searchapp/searchapp: searchapp/app.go +shout/shout: shout/shout.go qotd/qotd: qotd/qotd.o + +ifeq ($(BUILD_IN_CONTAINER),true) +qotd/qotd qotd/qotd.o searchapp/searchapp shout/shout: + $(SUDO) docker run -ti --rm -v $(shell pwd)/../../:/go/src/github.com/weaveworks/scope -e GOARCH -e GOOS \ + weaveworks/scope-backend-build -C experimental/example $@ +else +qotd/qotd: gcc -o $@ $< $(CFLAGS) %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) -searchapp/searchapp: searchapp/app.go -shout/shout: shout/shout.go shout/shout searchapp/searchapp: - go get -tags netgo ./$(@D) go build -ldflags "-extldflags \"-static\"" -tags netgo -o $@ ./$(@D) +endif qotd.marker: qotd/* qotd/qotd app.marker: app/* diff --git a/experimental/example/vendor/github.com/richo/GOSHOUT/README.MD b/experimental/example/vendor/github.com/richo/GOSHOUT/README.MD new file mode 100644 index 000000000..6563c7b6f --- /dev/null +++ b/experimental/example/vendor/github.com/richo/GOSHOUT/README.MD @@ -0,0 +1 @@ +GOLANG LIBRARY TO PROD [SHOUTCLOUD](SHOUTCLOUD.IO) diff --git a/experimental/example/vendor/github.com/richo/GOSHOUT/SHOUT.go b/experimental/example/vendor/github.com/richo/GOSHOUT/SHOUT.go new file mode 100644 index 000000000..779e707bd --- /dev/null +++ b/experimental/example/vendor/github.com/richo/GOSHOUT/SHOUT.go @@ -0,0 +1,46 @@ +package SHOUTCLOUD + +import ( + "bytes" + "encoding/json" + "errors" + "io/ioutil" + "net/http" +) + +type SHOUTREQUEST struct { + INPUT string +} + +type SHOUTRESPONSE struct { + INPUT string + OUTPUT string +} + +func UPCASE(THING_TO_YELL string) (string, error) { + REQUEST := &SHOUTREQUEST{THING_TO_YELL} + ENCODED, ERR := json.Marshal(REQUEST) + if ERR != nil { + return "", errors.New("COULDN'T MARSHALL THE REQUEST") + } + READER := bytes.NewReader(ENCODED) + + // NO TLS, SO MUCH SADNESS. + RESP, ERR := http.Post("http://API.SHOUTCLOUD.IO/V1/SHOUT", + "application/json", READER) + if ERR != nil { + return "", errors.New("REQUEST FAILED CAN'T UPCASE ERROR MESSAGE HALP") + } + + BODYBYTES, ERR := ioutil.ReadAll(RESP.Body) + if ERR != nil { + return "", errors.New("COULDN'T READ BODY HALP") + } + + var BODY SHOUTRESPONSE + if json.Unmarshal(BODYBYTES, &BODY) != nil { + return "", errors.New("COULDN'T UNPACK RESPONSE") + } + + return BODY.OUTPUT, nil +} diff --git a/experimental/example/vendor/manifest b/experimental/example/vendor/manifest new file mode 100644 index 000000000..144ec4d02 --- /dev/null +++ b/experimental/example/vendor/manifest @@ -0,0 +1,11 @@ +{ + "version": 0, + "dependencies": [ + { + "importpath": "github.com/richo/GOSHOUT", + "repository": "https://github.com/richo/GOSHOUT", + "revision": "da80b9993cbabeba5d04ee1c31688313dd730ad8", + "branch": "master" + } + ] +} \ No newline at end of file From 0441e70ba033aa5417122d474bd6461fd3d538e6 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Sat, 16 Jan 2016 12:11:34 -0800 Subject: [PATCH 2/3] Squashed 'tools/' changes from fb5985b..c7d833c c7d833c Allow vendor dirs in sub directories. git-subtree-dir: tools git-subtree-split: c7d833c2b1fc8447022d3b8b41930c2c8430d122 --- lint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint b/lint index 818c05a25..2adc9213e 100755 --- a/lint +++ b/lint @@ -148,7 +148,7 @@ function lint_files { function list_files { if [ $# -gt 0 ]; then - find "$@" -type f | grep -vE '^\./(\.git|vendor)/' + find "$@" -type f | grep -vE '(^\./\.git|^\./\.pkg|/vendor/)' else git diff --cached --name-only fi From 98d7887ba0941a666b159a08b7f801afda11cfc6 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Sat, 16 Jan 2016 12:22:23 -0800 Subject: [PATCH 3/3] Condense some more steps in circle, this seems to speed things up. --- circle.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/circle.yml b/circle.yml index de1e3fa63..d886538c7 100644 --- a/circle.yml +++ b/circle.yml @@ -17,11 +17,14 @@ dependencies: cache_directories: - "~/docker" override: - - "sudo apt-get update && sudo apt-get install jq pv" - - curl https://sdk.cloud.google.com | bash - - test -z "$SECRET_PASSWORD" || bin/setup-circleci-secrets "$SECRET_PASSWORD" - - make deps - - "mkdir -p $(dirname $SRCDIR) && cp -r $(pwd)/ $SRCDIR" + - > + sudo apt-get update && + sudo apt-get install jq pv && + (curl https://sdk.cloud.google.com | bash) && + (test -z "$SECRET_PASSWORD" || bin/setup-circleci-secrets "$SECRET_PASSWORD") && + make deps && + mkdir -p $(dirname $SRCDIR) && + cp -r $(pwd)/ $SRCDIR - "cd $SRCDIR/client; ../tools/rebuild-image weaveworks/scope-ui-build . Dockerfile package.json webpack.production.config.js .eslintrc .babelrc && touch $SRCDIR/.scope_ui_build.uptodate" - "cd $SRCDIR/backend; ../tools/rebuild-image weaveworks/scope-backend-build . Dockerfile build.sh && touch $SRCDIR/.scope_backend_build.uptodate" - cd $SRCDIR/integration; ./gce.sh make_template: