Skip to content

Commit

Permalink
Merge branch 'master' into glasser-glasser/virtualgo-root
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Mar 13, 2018
2 parents cccfd77 + 8fda430 commit c7cee21
Show file tree
Hide file tree
Showing 30 changed files with 669 additions and 122 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@

/vendor/
/.installed-deps
/testbins
/releases/
26 changes: 25 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: go
go:
- 1.8.3
- 1.9.x
- 1.10rc1

dist: trusty
sudo: false
Expand All @@ -14,4 +15,27 @@ before_install:

install:
- make get-deps
- make clean
- make all
- git diff --exit-code # Check if bindata file is up to date

script:
- make cover

after_success:
- bash <(curl -s https://codecov.io/bash)

before_deploy:
- make release-all

deploy:
provider: releases
api_key:
secure: k20D3kkJWVd6EgZpIviTD5qkeAd2ZBURY5Q0mMqStEdEpX85rSvcDmBP/84RW6DX8VYwz0mEgeLrIZwOhvS1UFu6yrQoM+s1ariOGqefMVYxWLkP7obDoojGTEcveZqDP9MgBWAEZFqmWuQdIdWhItQf4Z6Z6/LBH1ejG20nF0420StS3/gZ+ocwjb5qaAwB+Odld52zjGBeLGo56gLGNUl6O4envNo79DV1P9rzAwxvcXyGjUIOK7KHNalFsI0rBSJcNXiyUA/fkmIPZI6O14mqjXQDrnI8HlBKUiT8cADZCNlym8Gbijv+ymX3nFWrW6Aj5iO2QP1lEtCPad4ITU9bwJc9CStVvmgZA+lYsILype6Al84MjF7pHNchff/54Mnlj4Kyvsdamm+xH87N7vUYtt0ELHtrn6ElZBTSg2blz5/cuHn3uOjNovK5LtD0W2JQdoPvuP3W5EzeO9RZKozl4eoZZC8dlhlyX6CdGTNl4aCK7SwVWWCrRRmWRH9r+WXOAdA8E7wZDHjR06Ga2RbqW2B0+CAkK1awzI2+fQGFTv68KLfj+7tTf6Vq9sltM6iLIqtjzmQGfO6n0KKdBJWWvflH62/H6QgCmdwEISVpXS3PLpIpN7tQmhggi+wRT0VPrNBeroCbL5IeO7psxa1GgLxwJY/An1VoTWtzalI=
file:
- releases/*
file_glob: true
skip_cleanup: true # make sure travis doesn't cleanup needed files
on:
repo: GetStream/vg
tags: true
81 changes: 75 additions & 6 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@

required = [
'github.com/jteeuwen/go-bindata/go-bindata',
'github.com/spf13/cobra/cobra'
'github.com/spf13/cobra/cobra',
'github.com/haya14busa/goverage',
'github.com/wadey/gocovmerge',
]

[[constraint]]
branch = "master"
source = "github.com/GetStream/go-bindata"
name = "github.com/jteeuwen/go-bindata"

[[constraint]]
Expand All @@ -106,3 +109,13 @@ required = [
[[constraint]]
branch = "master"
name = "github.com/spf13/cobra"

[[constraint]]
branch = "subtest-helper"
name = "github.com/stretchr/testify"
source = "github.com/GetStream/testify"

[[override]]
branch = "subtest-helper"
name = "github.com/stretchr/testify"
source = "github.com/GetStream/testify"
52 changes: 45 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
SHELL=/bin/bash
GO_FILES = $(shell find . -name "*.go" | grep -v "^./vendor/" |grep -v "_test.go$$" | xargs)

BIN ?= vg
BIN_PACKAGE = .

REPO=github.com/GetStream/vg

RELEASE_DIR = releases

CURRENT_VERSION_MAJOR = 0
CURRENT_VERSION_MINOR = 7
CURRENT_VERSION_BUG = 1
CURRENT_VERSION_MINOR = 8
CURRENT_VERSION_BUG = 0

BINDATA = cmd/bindata.go

Expand All @@ -16,17 +23,19 @@ endif

LAST_ENSURE = $(VIRTUALGO_PATH)/last-ensure

DEPS = $(LAST_ENSURE) $(GO_FILES) $(BINDATA)

all: install
get-deps: $(LAST_ENSURE)

install: $(LAST_ENSURE) $(GO_FILES) $(BINDATA)
go install github.com/GetStream/vg
install: $(DEPS)
go install $(REPO)
@# install vg executable globally as well
cp $(GOBIN)/vg $(_VIRTUALGO_OLDGOBIN)/vg

bindata: $(BINDATA) .installed-deps
$(BINDATA): data/*
go-bindata -o cmd/bindata.go -pkg cmd data/*
go-bindata -nometadata -o cmd/bindata.go -pkg cmd data/*

$(LAST_ENSURE): Gopkg.lock Gopkg.toml
vg ensure -- -v
Expand All @@ -39,7 +48,7 @@ publish: $(BINDATA)
$(eval new_major = $(word 1, $(dots)))
$(eval new_minor = $(word 2, $(dots)))
$(eval new_bug = $(word 3, $(dots)))
sed -i.bak -e 's/\(\tVersion string = \).*/\1"$(VERSION)"/g' cmd/version.go
sed -i.bak -e 's/\(\tVersion string = \).*/\1"$(VERSION)-dev"/g' cmd/version.go
sed -i.bak -e 's/^\(CURRENT_VERSION_MAJOR = \).*/\1$(new_major)/g' Makefile
sed -i.bak -e 's/^\(CURRENT_VERSION_MINOR = \).*/\1$(new_minor)/g' Makefile
sed -i.bak -e 's/^\(CURRENT_VERSION_BUG = \).*/\1$(new_bug)/g' Makefile
Expand All @@ -60,4 +69,33 @@ publish-minor: update-master
publish-bug: update-master
make publish VERSION=$(CURRENT_VERSION_MAJOR).$(CURRENT_VERSION_MINOR).$$(($(CURRENT_VERSION_BUG) + 1))

test: install
publish-staging: $(DEPS)
@if [ "$(SUFFIX)" = "" ]; then echo You should define the version like so: make publish SUFFIX=test-ratelimit; exit 1; fi
@git diff --exit-code --cached || { git status; echo You have changes that are staged but not committed ; false ; };
@git diff --exit-code || { git status; echo You have changes that are not committed ; false ; };
$(eval VERSION := $(CURRENT_VERSION_MAJOR).$(CURRENT_VERSION_MINOR).$(CURRENT_VERSION_BUG)-$(SUFFIX))
git tag -a -m "RELEASED BY: $$(git config user.name)" v$(VERSION)
git push --follow-tags

test:
go test $(REPO)/internal/...
./test.bash

cover: $(DEPS)
goverage -covermode=count -coverprofile=coverage-unit-tests.out $(REPO)/internal/...
./test.bash
gocovmerge coverages/*.out coverage-unit-tests.out > coverage.out
rm coverage-unit-tests.out
rm -r coverages

release-all: $(DEPS)
GOOS=linux GOARCH=amd64 make release
GOOS=windows GOARCH=amd64 make release
GOOS=darwin GOARCH=amd64 make release

release: $(DEPS)
mkdir -p $(RELEASE_DIR)
go build $(BUILD_FLAGS) -ldflags="-w -s -X github.com/GetStream/vg/cmd.Version=`git describe`" -o "$(RELEASE_DIR)/$(BIN)-`go env GOOS`-`go env GOARCH`" $(BIN_PACKAGE)

clean:
rm $(BINDATA)
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@



# virtualgo [![Build Status](https://travis-ci.org/GetStream/vg.svg?branch=master)](https://travis-ci.org/GetStream/vg)
# virtualgo [![Build Status](https://travis-ci.org/GetStream/vg.svg?branch=master)](https://travis-ci.org/GetStream/vg) [![codecov](https://codecov.io/gh/GetStream/vg/branch/master/graph/badge.svg)](https://codecov.io/gh/GetStream/vg) [![Go Report Card](https://goreportcard.com/badge/github.com/GetStream/vg)](https://goreportcard.com/report/github.com/GetStream/vg)

Virtualgo (or `vg` for short) is a tool which provides workspace based
development for Go. Its main feature set that makes it better than other
Expand Down Expand Up @@ -324,17 +324,26 @@ here, [please report them](https://github.com/GetStream/vg/issues/new).
##### Relative packages in commands

The first set of issues happen when using relative reference to packages in
commands. For instance `go list ./...` will return weirdly formatted paths, such
as `_/home/stream/go/src/github.com/GetStream/vg`. Also, running
`go test ./...`, might cause an `init` function to be executed twice. This can
all easily be worked around by using absolute package paths for these commands.
commands. Some examples of this are:

- `go list ./...` will return weirdly formatted paths, such
as `_/home/stream/go/src/github.com/GetStream/vg`.
- `go test ./...`, might cause an `init` function to be executed twice.
- `go build ./...` won't work when an `internal` package is present in the
directory. Here you can expect an error saying `use of internal package not
allowed`.

Luckily, this can all easily be worked around by using absolute package paths
for these commands.
So for the `vg` repo you would use the following alternatives:

```bash
# go list ./...
go list github.com/GetStream/vg/...
# go test ./...
go test github.com/GetStream/vg/...`
go test github.com/GetStream/vg/...
# go build ./...
go build github.com/GetStream/vg/...
```

##### `dep` commands
Expand All @@ -347,8 +356,8 @@ there's an easy workaround for this as well. You can simply use `vg globalExec`,
to execute commands from your regular `GOPATH`, which fixes the issue:

```bash
vg globalExec -- vg init
vg globalExec -- vg status
vg globalExec dep init
vg globalExec dep status
```

#### Without `bindfs` installed
Expand All @@ -366,7 +375,7 @@ package. Other than that there are also issues when using `delve`
is NOT RECOMMENDED to use virtualgo in full isolation mode without `bindfs`
installed.

## Using a virtualgo workspace with an IDE (e.g. Gogland)
## Using a virtualgo workspace with an IDE (e.g. GoLand)

Because virtualgo is just a usability wrapper around changing your `GOPATH` for
a specific project it is usually quite easy to use it in combination with an
Expand All @@ -380,7 +389,7 @@ $ echo $GOPATH
```

If you can set this full string directly that is fine. For
[Gogland](https://www.jetbrains.com/go/) you have to add the first one first and
[GoLand](https://www.jetbrains.com/go/) you have to add the first one first and
then the second one.

When using a workspace in full isolation mode it's even easier to set up as
Expand Down
2 changes: 1 addition & 1 deletion cmd/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ optional argument like this:
vg activate my-personal-env
`,
RunE: func(cmd *cobra.Command, args []string) error {
return errors.New("You haven't eval-ed `vg eval` yet")
return errors.New(noEvalError)
},
}

Expand Down
Loading

0 comments on commit c7cee21

Please sign in to comment.