From 35e7b9ffad591831793e2eedaa62c59998c5e4b3 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:33:37 -0600 Subject: [PATCH 01/13] Fix typo in build container readme --- etc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/README.md b/etc/README.md index 1f4f9d013..6e541ecee 100644 --- a/etc/README.md +++ b/etc/README.md @@ -6,7 +6,7 @@ Our circle.yml uses this docker container to build, test and create release pack ### Updating new node/go versions After updating the Dockerfile_build run -`docker build -t quay.io/influxdb/builder:chronograf-$(date "+%Y%m%d") -f Dockerfile_build` +`docker build -t quay.io/influxdb/builder:chronograf-$(date "+%Y%m%d") -f Dockerfile_build .` and push to quay with: `docker push quay.io/influxdb/builder:chronograf-$(date "+%Y%m%d")` From 721183ad89595e38d0a43f24666468ec325b0bbb Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:34:38 -0600 Subject: [PATCH 02/13] Add yarn to docker container build --- etc/Dockerfile_build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/Dockerfile_build b/etc/Dockerfile_build index 72d8daa23..81b64d9ce 100644 --- a/etc/Dockerfile_build +++ b/etc/Dockerfile_build @@ -1,8 +1,10 @@ FROM ubuntu:trusty RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \ + apt-transport-https \ python-dev \ wget \ + curl \ git \ mercurial \ make \ @@ -26,6 +28,10 @@ RUN cd $(npm root -g)/npm \ && sed -i -e s/graceful-fs/fs-extra/ -e s/fs.rename/fs.move/ ./lib/utils/rename.js RUN npm install npm -g +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \ + apt-get update && sudo apt-get install yarn + # Install go ENV GOPATH /root/go ENV GO_VERSION 1.7.5 From 3e2f2555caef022ea1b1603f30f2ec173c457a79 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:34:52 -0600 Subject: [PATCH 03/13] Update docker container builds to Node 6.9.5 --- etc/Dockerfile_build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/Dockerfile_build b/etc/Dockerfile_build index 81b64d9ce..a16f83551 100644 --- a/etc/Dockerfile_build +++ b/etc/Dockerfile_build @@ -18,9 +18,9 @@ RUN pip install boto requests python-jose --upgrade RUN gem install fpm # Install node -RUN wget -q https://nodejs.org/dist/latest-v6.x/node-v6.9.4-linux-x64.tar.gz; \ - tar -xvf node-v6.9.4-linux-x64.tar.gz -C / --strip-components=1; \ - rm -f node-v6.9.4-linux-x64.tar.gz +RUN wget -q https://nodejs.org/dist/latest-v6.x/node-v6.9.5-linux-x64.tar.gz; \ + tar -xvf node-v6.9.5-linux-x64.tar.gz -C / --strip-components=1; \ + rm -f node-v6.9.5-linux-x64.tar.gz # Update npm RUN cd $(npm root -g)/npm \ From 59806ff0ac1f62f5c5846d62524ba27bdc7e8a9e Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:38:31 -0600 Subject: [PATCH 04/13] Update build script to require yarn --- etc/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/build.py b/etc/build.py index 80d89cc5e..6622c32e1 100755 --- a/etc/build.py +++ b/etc/build.py @@ -46,7 +46,7 @@ MAINTAINER = "contact@influxdb.com" VENDOR = "InfluxData" DESCRIPTION = "Open source monitoring and visualization UI for the entire TICK stack." -prereqs = [ 'git', 'go', 'npm' ] +prereqs = [ 'git', 'go', 'npm','yarn' ] go_vet_command = "go tool vet ./" optional_prereqs = [ 'fpm', 'rpmbuild', 'gpg' ] From 23c63195e73d1b34437e0157a7ee570c3807060e Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:38:55 -0600 Subject: [PATCH 05/13] Update README build instructions to mention yarn --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b82650ca..39fd18df1 100644 --- a/README.md +++ b/README.md @@ -142,11 +142,12 @@ docker pull quay.io/influxdb/chronograf:latest ### From Source -* Chronograf works with go 1.7.x, node 6.x/7.x, and npm 3.x. +* Chronograf works with go 1.7.x, node 6.x/7.x, and yarn 0.18+. * Chronograf requires [Kapacitor](https://github.com/influxdata/kapacitor) 1.1.x+ to create and store alerts. 1. [Install Go](https://golang.org/doc/install) 1. [Install Node and NPM](https://nodejs.org/en/download/) +1. [Install yarn](https://yarnpkg.com/docs/install) 1. [Setup your GOPATH](https://golang.org/doc/code.html#GOPATH) 1. Run `go get github.com/influxdata/chronograf` 1. Run `cd $GOPATH/src/github.com/influxdata/chronograf` From 0a022b188fe9e3ecaaafcfae295f8dd85ecf8436 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:39:33 -0600 Subject: [PATCH 06/13] Update Makefile to use yarn instead of npm install --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 996dded34..45f856934 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ godep: go get -u github.com/jteeuwen/go-bindata/... jsdep: - cd ui && npm install + cd ui && yarn gen: bolt/internal/internal.proto go generate -x ./bolt/internal From d072b7b34e0465cdf51d62e96102f704817adeeb Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:40:01 -0600 Subject: [PATCH 07/13] Update circle to use build container from 20170208 --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index d0e81fb1b..2a1683db9 100644 --- a/circle.yml +++ b/circle.yml @@ -3,7 +3,7 @@ machine: services: - docker environment: - DOCKER_TAG: chronograf-20170127 + DOCKER_TAG: chronograf-20170208 dependencies: override: From 5f6e78d1396caff7ec872f782ec75de0f5cd8565 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 09:44:52 -0600 Subject: [PATCH 08/13] Updated CHANGELOG to use yarn over npm install --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83e3a5f41..81d34ffed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Upcoming Bug Fixes ### Upcoming Features +1. [#853](https://github.com/influxdata/chronograf/issues/853): Updated builds to use yarn over npm install ### Upcoming UI Improvements From 13bb878b5aa612263139c7a7640b84fcd270b84a Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 10:17:19 -0600 Subject: [PATCH 09/13] Update build log level to debug --- circle.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/circle.yml b/circle.yml index 2a1683db9..8bf615b24 100644 --- a/circle.yml +++ b/circle.yml @@ -22,6 +22,7 @@ deployment: commands: - > ./etc/scripts/docker/run.sh + --debug --clean --package --platform all @@ -42,6 +43,7 @@ deployment: - > ./etc/scripts/docker/run.sh --clean + --debug --release --package --platform all @@ -64,6 +66,7 @@ deployment: - > ./etc/scripts/docker/run.sh --clean + --debug --release --package --platform all From 2d6c9521c682ec5e73c834aedc95b40af41877bf Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 10:18:01 -0600 Subject: [PATCH 10/13] Update builds to be more verbose to help debugging --- etc/build.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/etc/build.py b/etc/build.py index 6622c32e1..2373d4b05 100755 --- a/etc/build.py +++ b/etc/build.py @@ -3,7 +3,6 @@ import sys import os import subprocess -import time from datetime import datetime import shutil import tempfile @@ -142,29 +141,38 @@ def package_scripts(build_root, config_only=False, windows=False): run("cp {} {} && chmod 644 {}".format(CANNED_SCRIPTS, os.path.join(build_root, CANNED_DIR[1:]), os.path.join(build_root, CANNED_DIR[1:], "*json")), - shell=True) + shell=True, print_output=True) def run_generate(): """Generate static assets. """ + start_time = datetime.utcnow() logging.info("Generating static assets...") - run("make assets", shell=True) + run("make assets", shell=True, print_output=True) + end_time = datetime.utcnow() + logging.info("Time taken: {}s".format((end_time - start_time).total_seconds())) return True def go_get(branch, update=False, no_uncommitted=False): """Retrieve build dependencies or restore pinned dependencies. """ + start_time = datetime.utcnow() if local_changes() and no_uncommitted: logging.error("There are uncommitted changes in the current directory.") return False - run("make dep", shell=True) + run("make dep", shell=True, print_output=True) + end_time = datetime.utcnow() + logging.info("Time taken: {}s".format((end_time - start_time).total_seconds())) return True def run_tests(race, parallel, timeout, no_vet): - """Run the Go test suite on binary output. + """Run the Go and NPM test suite on binary output. """ + start_time = datetime.utcnow() logging.info("Running tests...") run("make test", shell=True, print_output=True) + end_time = datetime.utcnow() + logging.info("Time taken: {}s".format((end_time - start_time).total_seconds())) return True ################ @@ -497,7 +505,7 @@ def build(version=None, build_command += "-a -installsuffix cgo " build_command += path start_time = datetime.utcnow() - run(build_command, shell=True) + run(build_command, shell=True, print_output=True) end_time = datetime.utcnow() logging.info("Time taken: {}s".format((end_time - start_time).total_seconds())) return True @@ -633,13 +641,13 @@ def package(build_output, pkg_name, version, nightly=False, iteration=1, static= current_location = os.path.join(os.getcwd(), current_location) if package_type == 'tar': tar_command = "cd {} && tar -cvzf {}.tar.gz --owner=root ./*".format(package_build_root, name) - run(tar_command, shell=True) + run(tar_command, shell=True, print_output=True) run("mv {}.tar.gz {}".format(os.path.join(package_build_root, name), current_location), shell=True) outfile = os.path.join(current_location, name + ".tar.gz") outfiles.append(outfile) elif package_type == 'zip': zip_command = "cd {} && zip -r {}.zip ./*".format(package_build_root, name) - run(zip_command, shell=True) + run(zip_command, shell=True, print_output=True) run("mv {}.zip {}".format(os.path.join(package_build_root, name), current_location), shell=True) outfile = os.path.join(current_location, name + ".zip") outfiles.append(outfile) @@ -720,7 +728,7 @@ def main(args): orig_branch = get_current_branch() if args.platform not in supported_builds and args.platform != 'all': - logging.error("Invalid build platform: {}".format(target_platform)) + logging.error("Invalid build platform: {}".format(args.platform)) return 1 build_output = {} @@ -730,10 +738,10 @@ def main(args): return 1 elif args.branch != orig_branch: logging.info("Moving to git branch: {}".format(args.branch)) - run("git checkout {}".format(args.branch)) + run("git checkout {}".format(args.branch), print_output=True) elif args.commit != orig_commit: logging.info("Moving to git commit: {}".format(args.commit)) - run("git checkout {}".format(args.commit)) + run("git checkout {}".format(args.commit), print_output=True) if not args.no_get: if not go_get(args.branch, update=args.update, no_uncommitted=args.no_uncommitted): @@ -890,7 +898,7 @@ def main(args): logging.info(json.dumps(package_output, sort_keys=True, indent=4)) if orig_branch != get_current_branch(): logging.info("Moving back to original git branch: {}".format(orig_branch)) - run("git checkout {}".format(orig_branch)) + run("git checkout {}".format(orig_branch), print_output=True) return 0 From 61f40f064653502316a12ec4dfbae52959e6712d Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 10:24:10 -0600 Subject: [PATCH 11/13] Add debug to circle builds to make it easier to debug --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index 8bf615b24..21a30d204 100644 --- a/circle.yml +++ b/circle.yml @@ -13,6 +13,7 @@ test: override: - > ./etc/scripts/docker/run.sh + --debug --test --no-build From 4828dc9f404ab76a852d24f8d4abf5a5f05b2053 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 10:47:20 -0600 Subject: [PATCH 12/13] Update gitignore to filter MacOSX .DS_Store --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cb52f7190..e334f1b41 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ chronograf.db chronograf-v1.db npm-debug.log .vscode +.DS_Store From 3b9f24d9068fdc7cc9fb33283bd291f26ef8b158 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 8 Feb 2017 18:17:10 -0600 Subject: [PATCH 13/13] Update Makefile and webpack to make builds incremental --- .gitignore | 5 ++++ Godeps | 2 +- Makefile | 63 +++++++++++++++++++++++++++++----------- ui/README.md | 33 +++++++++++++++++++++ ui/package.json | 2 +- ui/webpack/prodConfig.js | 2 +- 6 files changed, 87 insertions(+), 20 deletions(-) create mode 100644 ui/README.md diff --git a/.gitignore b/.gitignore index e334f1b41..bbef07c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,8 @@ chronograf-v1.db npm-debug.log .vscode .DS_Store +.godep +.jsdep +.jssrc +.dev-jssrc +.bindata diff --git a/Godeps b/Godeps index c280e3991..f2c6cb8ba 100644 --- a/Godeps +++ b/Godeps @@ -6,7 +6,7 @@ github.com/elazarl/go-bindata-assetfs 9a6736ed45b44bf3835afeebb3034b57ed329f3e github.com/gogo/protobuf 6abcf94fd4c97dcb423fdafd42fe9f96ca7e421b github.com/google/go-github 1bc362c7737e51014af7299e016444b654095ad9 github.com/google/go-querystring 9235644dd9e52eeae6fa48efd539fdc351a0af53 -github.com/influxdata/kapacitor 0eb8c348b210dd3d32cb240a417f9e6ded1b691d +github.com/influxdata/kapacitor 5408057e5a3493d3b5bd38d5d535ea45b587f8ff github.com/influxdata/usage-client 6d3895376368aa52a3a81d2a16e90f0f52371967 github.com/jessevdk/go-flags 4cc2832a6e6d1d3b815e2b9d544b2a4dfb3ce8fa github.com/satori/go.uuid b061729afc07e77a8aa4fad0a2fd840958f1942a diff --git a/Makefile b/Makefile index 45f856934..3ebbbcba3 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,26 @@ +.PHONY: assets dep clean test gotest gotestrace jstest run run-dev + VERSION ?= $(shell git describe --always --tags) COMMIT ?= $(shell git rev-parse --short=8 HEAD) +GDM := $(shell command -v gdm 2> /dev/null) +GOBINDATA := $(shell go list -f {{.Root}} github.com/jteeuwen/go-bindata 2> /dev/null) +YARN := $(shell command -v yarn 2> /dev/null) -SOURCES := $(shell find . -name '*.go') +SOURCES := $(shell find . -name '*.go' ! -name '*_gen.go') +UISOURCES := $(shell find ui -type f -not \( -path ui/build/\* -o -path ui/node_modules/\* -prune \) ) LDFLAGS=-ldflags "-s -X main.version=${VERSION} -X main.commit=${COMMIT}" BINARY=chronograf -default: dep build +.DEFAULT_GOAL := all + +all: dep build build: assets ${BINARY} -dev: dev-assets ${BINARY} +dev: dep dev-assets ${BINARY} -${BINARY}: $(SOURCES) +${BINARY}: $(SOURCES) .bindata go build -o ${BINARY} ${LDFLAGS} ./cmd/chronograf/main.go docker-${BINARY}: $(SOURCES) @@ -22,30 +30,51 @@ docker-${BINARY}: $(SOURCES) docker: dep assets docker-${BINARY} docker build -t chronograf . -assets: js bindata +assets: .jssrc .bindata -dev-assets: dev-js bindata +dev-assets: .dev-jssrc .bindata -bindata: +.bindata: server/swagger_gen.go canned/bin_gen.go dist/dist_gen.go + @touch .bindata + +dist/dist_gen.go: $(UISOURCES) go generate -x ./dist - go generate -x ./canned + +server/swagger_gen.go: server/swagger.json go generate -x ./server -js: +canned/bin_gen.go: canned/*.json + go generate -x ./canned + +.jssrc: $(UISOURCES) cd ui && npm run build + @touch .jssrc -dev-js: +.dev-jssrc: $(UISOURCES) cd ui && npm run build:dev + @touch .dev-jssrc -dep: jsdep godep +dep: .jsdep .godep -godep: +.godep: Godeps +ifndef GDM + @echo "Installing GDM" go get github.com/sparrc/gdm - gdm restore +endif +ifndef GOBINDATA + @echo "Installing go-bindata" go get -u github.com/jteeuwen/go-bindata/... +endif + gdm restore + @touch .godep -jsdep: - cd ui && yarn +.jsdep: ui/yarn.lock +ifndef YARN + $(error Please install yarn 0.19.1+) +else + cd ui && yarn --no-progress --no-emoji + @touch .jsdep +endif gen: bolt/internal/internal.proto go generate -x ./bolt/internal @@ -71,5 +100,5 @@ clean: if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi cd ui && npm run clean cd ui && rm -rf node_modules - -.PHONY: clean test jstest gotest run + rm -f dist/dist_gen.go canned/bin_gen.go server/swagger_gen.go + @rm -f .godep .jsdep .jssrc .dev-jssrc .bindata diff --git a/ui/README.md b/ui/README.md new file mode 100644 index 000000000..015356cb1 --- /dev/null +++ b/ui/README.md @@ -0,0 +1,33 @@ +## Packages +We are using [yarn](https://yarnpkg.com/en/docs/install) 0.19.1. + +### Adding new packages +To add a new package, run + +```sh +yarn add packageName +``` + +### Adding devDependency + +```sh +yarn add --dev packageName +``` + +### Updating a package +First, run + +```sh +yarn outdated +``` + +... to determine which packages may need upgrading. + +We _really_ should not upgrade all packages at once, but, one at a time and make darn sure +to test. + +To upgrade a single package named `packageName`: + +```sh +yarn upgrade packageName +``` diff --git a/ui/package.json b/ui/package.json index aeb98fed0..765e67506 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "chronograf-ui", - "version": "1.1.0", + "version": "1.2.0", "private": false, "license": "AGPL-3.0", "description": "", diff --git a/ui/webpack/prodConfig.js b/ui/webpack/prodConfig.js index 269e818db..fd06f9d6b 100644 --- a/ui/webpack/prodConfig.js +++ b/ui/webpack/prodConfig.js @@ -8,7 +8,7 @@ var dependencies = package.dependencies; var config = { bail: true, - devtool: 'hidden-source-map', + devtool: 'eval', entry: { app: path.resolve(__dirname, '..', 'src', 'index.js'), vendor: Object.keys(dependencies),