From 6f1eaa9b39769420e07c2947af22c4e481dea1d0 Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Thu, 13 Dec 2018 06:36:15 +0100 Subject: [PATCH] Use go modules and simplify build (#1444) * Update .travis.yml and use stages This updates the .travis.yml configuration to use separate stages for unittests and CLI tests. The output is now clearer, since for unittests and CLI tests separate web pages are available. * Use go modules and simplify build --- .travis.yml | 41 +++++++++++++++++++-------------- Makefile | 65 +++++++++++++++++++++-------------------------------- glide.lock | 48 --------------------------------------- glide.yaml | 16 ------------- go.mod | 17 ++++++++++++++ go.sum | 26 +++++++++++++++++++++ 6 files changed, 92 insertions(+), 121 deletions(-) delete mode 100644 glide.lock delete mode 100644 glide.yaml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.travis.yml b/.travis.yml index 0a368fd..8608ccd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,27 @@ -language: ruby -dist: trusty -sudo: required -matrix: +language: go +dist: xenial +addons: + apt: + sources: + - sourceline: "ppa:pi-rho/dev" + - sourceline: "ppa:fish-shell/release-2" + packages: + - tmux + - zsh + - fish + +env: + - GO111MODULE=on + +jobs: include: - - env: TAGS= - rvm: 2.3.3 -# - env: TAGS=tcell -# rvm: 2.3.3 + - stage: unittest + go: "1.11.x" + script: make && make test -install: -- sudo add-apt-repository -y ppa:pi-rho/dev -- sudo apt-add-repository -y ppa:fish-shell/release-2 -- sudo apt-get update -- sudo apt-get install -y tmux zsh fish + - stage: cli + go: "1.11.x" + rvm: "2.5" + script: | + make install && ./install --all && tmux new "ruby test/test_go.rb > out && touch ok" && cat out && [ -e ok ] -script: | - make test install && - ./install --all && - tmux new "ruby test/test_go.rb > out && touch ok" && cat out && [ -e ok ] diff --git a/Makefile b/Makefile index 8ca872f..4a35cb1 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,9 @@ -ifndef GOOS -GOOS := $(word 1, $(subst /, " ", $(word 4, $(shell go version)))) -endif +GO ?= go +GOOS ?= $(word 1, $(subst /, " ", $(word 4, $(shell go version)))) MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST))) ROOT_DIR := $(shell dirname $(MAKEFILE)) -GOPATH := $(ROOT_DIR)/gopath -SRC_LINK := $(GOPATH)/src/github.com/junegunn/fzf/src -VENDOR_LINK := $(GOPATH)/src/github.com/junegunn/fzf/vendor -export GOPATH - -GLIDE_YAML := glide.yaml -GLIDE_LOCK := glide.lock -SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK) $(MAKEFILE) +SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE) REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES)) BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" @@ -90,19 +82,8 @@ release-all: clean test GOOS=openbsd make release GOOS=windows make release -$(SRC_LINK): - mkdir -p $(shell dirname $(SRC_LINK)) - ln -sf $(ROOT_DIR)/src $(SRC_LINK) - -$(VENDOR_LINK): - mkdir -p $(shell dirname $(VENDOR_LINK)) - ln -sf $(ROOT_DIR)/vendor $(VENDOR_LINK) - -vendor: $(GLIDE_YAML) - go get -u github.com/Masterminds/glide && $(GOPATH)/bin/glide install && touch $@ - -test: $(SOURCES) vendor - SHELL=/bin/sh GOOS= go test -v -tags "$(TAGS)" \ +test: $(SOURCES) + SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" \ github.com/junegunn/fzf/src \ github.com/junegunn/fzf/src/algo \ github.com/junegunn/fzf/src/tui \ @@ -111,29 +92,29 @@ test: $(SOURCES) vendor install: bin/fzf clean: - rm -rf target + $(RM) -r target -target/$(BINARY32): $(SOURCES) vendor - GOARCH=386 go build $(BUILD_FLAGS) -o $@ +target/$(BINARY32): $(SOURCES) + GOARCH=386 $(GO) build $(BUILD_FLAGS) -o $@ -target/$(BINARY64): $(SOURCES) vendor - GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ +target/$(BINARY64): $(SOURCES) + GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@ # https://github.com/golang/go/wiki/GoArm -target/$(BINARYARM5): $(SOURCES) vendor - GOARCH=arm GOARM=5 go build $(BUILD_FLAGS) -o $@ +target/$(BINARYARM5): $(SOURCES) + GOARCH=arm GOARM=5 $(GO) build $(BUILD_FLAGS) -o $@ -target/$(BINARYARM6): $(SOURCES) vendor - GOARCH=arm GOARM=6 go build $(BUILD_FLAGS) -o $@ +target/$(BINARYARM6): $(SOURCES) + GOARCH=arm GOARM=6 $(GO) build $(BUILD_FLAGS) -o $@ -target/$(BINARYARM7): $(SOURCES) vendor - GOARCH=arm GOARM=7 go build $(BUILD_FLAGS) -o $@ +target/$(BINARYARM7): $(SOURCES) + GOARCH=arm GOARM=7 $(GO) build $(BUILD_FLAGS) -o $@ -target/$(BINARYARM8): $(SOURCES) vendor - GOARCH=arm64 go build $(BUILD_FLAGS) -o $@ +target/$(BINARYARM8): $(SOURCES) + GOARCH=arm64 $(GO) build $(BUILD_FLAGS) -o $@ -target/$(BINARYPPC64LE): $(SOURCES) vendor - GOARCH=ppc64le go build $(BUILD_FLAGS) -o $@ +target/$(BINARYPPC64LE): $(SOURCES) + GOARCH=ppc64le $(GO) build $(BUILD_FLAGS) -o $@ bin/fzf: target/$(BINARY) | bin cp -f target/$(BINARY) bin/fzf @@ -146,4 +127,8 @@ docker-test: docker build -t fzf-arch . docker run -it fzf-arch -.PHONY: all release release-all test install clean docker docker-test +update: + $(GO) get -u + $(GO) mod tidy + +.PHONY: all release release-all test install clean docker docker-test update diff --git a/glide.lock b/glide.lock deleted file mode 100644 index f735fe8..0000000 --- a/glide.lock +++ /dev/null @@ -1,48 +0,0 @@ -hash: b617c76661b399f586276767bb93ee67b65dd03cfd1348ecad409e372ea97b3e -updated: 2018-06-27T18:37:20.189962-07:00 -imports: -- name: github.com/codegangsta/cli - version: c6af8847eb2b7b297d07c3ede98903e95e680ef9 -- name: github.com/gdamore/encoding - version: b23993cbb6353f0e6aa98d0ee318a34728f628b9 -- name: github.com/gdamore/tcell - version: 0a0db94084dfe181108c18508ebd312f12d331fb - subpackages: - - encoding -- name: github.com/lucasb-eyer/go-colorful - version: c900de9dbbc73129068f5af6a823068fc5f2308c -- name: github.com/Masterminds/semver - version: 15d8430ab86497c5c0da827b748823945e1cf1e1 -- name: github.com/Masterminds/vcs - version: 6f1c6d150500e452704e9863f68c2559f58616bf -- name: github.com/mattn/go-isatty - version: 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8 -- name: github.com/mattn/go-runewidth - version: 14207d285c6c197daabb5c9793d63e7af9ab2d50 -- name: github.com/mattn/go-shellwords - version: 02e3cf038dcea8290e44424da473dd12be796a8a -- name: github.com/mitchellh/go-homedir - version: b8bc1bf767474819792c23f32d8286a45736f1c6 -- name: golang.org/x/crypto - version: 558b6879de74bc843225cde5686419267ff707ca - subpackages: - - ssh/terminal -- name: golang.org/x/sys - version: b90f89a1e7a9c1f6b918820b3daa7f08488c8594 - subpackages: - - unix -- name: golang.org/x/text - version: 4ee4af566555f5fbe026368b75596286a312663a - subpackages: - - encoding - - encoding/charmap - - encoding/internal - - encoding/internal/identifier - - encoding/japanese - - encoding/korean - - encoding/simplifiedchinese - - encoding/traditionalchinese - - transform -- name: gopkg.in/yaml.v2 - version: 287cf08546ab5e7e37d55a84f7ed3fd1db036de5 -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index e6dbb27..0000000 --- a/glide.yaml +++ /dev/null @@ -1,16 +0,0 @@ -package: github.com/junegunn/fzf -import: -- package: github.com/mattn/go-isatty - version: 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8 -- package: github.com/mattn/go-runewidth - version: 14207d285c6c197daabb5c9793d63e7af9ab2d50 -- package: github.com/mattn/go-shellwords - version: 02e3cf038dcea8290e44424da473dd12be796a8a -- package: github.com/gdamore/tcell - version: 0a0db94084dfe181108c18508ebd312f12d331fb - subpackages: - - encoding -- package: golang.org/x/crypto - version: 558b6879de74bc843225cde5686419267ff707ca - subpackages: - - ssh/terminal diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f103f17 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module github.com/junegunn/fzf + +require ( + github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635 // indirect + github.com/gdamore/tcell v0.0.0-20170915061752-0a0db94084df + github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect + github.com/jtolds/gls v4.2.1+incompatible // indirect + github.com/lucasb-eyer/go-colorful v0.0.0-20170223221042-c900de9dbbc7 // indirect + github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c + github.com/mattn/go-runewidth v0.0.0-20170201023540-14207d285c6c + github.com/mattn/go-shellwords v1.0.3 + github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect + github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect + golang.org/x/crypto v0.0.0-20170728183002-558b6879de74 + golang.org/x/sys v0.0.0-20170529185110-b90f89a1e7a9 // indirect + golang.org/x/text v0.0.0-20170530162606-4ee4af566555 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4a04cbe --- /dev/null +++ b/go.sum @@ -0,0 +1,26 @@ +github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635 h1:hheUEMzaOie/wKeIc1WPa7CDVuIO5hqQxjS+dwTQEnI= +github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635/go.mod h1:yrQYJKKDTrHmbYxI7CYi+/hbdiDT2m4Hj+t0ikCjsrQ= +github.com/gdamore/tcell v0.0.0-20170915061752-0a0db94084df h1:tLS1QD2puA1USLvkEnGfOt+Zp2ijtNIK3z2YFaIZZR4= +github.com/gdamore/tcell v0.0.0-20170915061752-0a0db94084df/go.mod h1:tqyG50u7+Ctv1w5VX67kLzKcj9YXR/JSBZQq/+mLl1A= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/lucasb-eyer/go-colorful v0.0.0-20170223221042-c900de9dbbc7 h1:G52I+Gk/wPD4HKvKT0Vxxp9OUPxqKs3OK6rffSPtNkA= +github.com/lucasb-eyer/go-colorful v0.0.0-20170223221042-c900de9dbbc7/go.mod h1:NXg0ArsFk0Y01623LgUqoqcouGDB+PwCCQlrwrG6xJ4= +github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c h1:3nKFouDdpgGUV/uerJcYWH45ZbJzX0SiVWfTgmUeTzc= +github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-runewidth v0.0.0-20170201023540-14207d285c6c h1:eFzthqtg3W6Pihj3DMTXLAF4f+ge5r5Ie5g6HLIZAF0= +github.com/mattn/go-runewidth v0.0.0-20170201023540-14207d285c6c/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-shellwords v1.0.3 h1:K/VxK7SZ+cvuPgFSLKi5QPI9Vr/ipOf4C1gN+ntueUk= +github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +golang.org/x/crypto v0.0.0-20170728183002-558b6879de74 h1:/0jf0Cx3u07Ma4EzUA6NIGuvk9hb3Br6i9V8atthkwk= +golang.org/x/crypto v0.0.0-20170728183002-558b6879de74/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/sys v0.0.0-20170529185110-b90f89a1e7a9 h1:wFe/9vW2TmDagagfMeC56pEcmhyMWEqvuwE9CDAePNo= +golang.org/x/sys v0.0.0-20170529185110-b90f89a1e7a9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.0.0-20170530162606-4ee4af566555 h1:pjwO9HxObpgZBurDvTLFbSinaf3+cKpTAjVfiGaHwrI= +golang.org/x/text v0.0.0-20170530162606-4ee4af566555/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=