Browse Source

Update travis

Vadim Markovtsev 7 years ago
parent
commit
546675dfc1
4 changed files with 48 additions and 31 deletions
  1. 13 8
      .travis.yml
  2. 8 2
      Makefile
  3. 20 17
      cmd/hercules/main.go
  4. 7 4
      pipeline_test.go

+ 13 - 8
.travis.yml

@@ -18,20 +18,25 @@ go:
 go_import_path: gopkg.in/src-d/hercules.v3
 
 before_install:
+  - wget http://mirrors.kernel.org/ubuntu/pool/main/m/make-dfsg/make_4.1-9.1_amd64.deb
+  - dpkg -x make_4.1-9.1_amd64.deb ~ && rm make_4.1-9.1_amd64.deb
   - wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py --user && rm get-pip.py
-  - export PATH=$PATH:~/.local/bin
-  - pip3 install --user -r requirements.txt
-  - pip3 install --user tensorflow
+  - export PATH=~/.local/bin:~/usr/bin:$PATH
+  - make --version
+  - pip3 --version
+
+install:
+  - make dependencies
+  - go get -t -v -ldflags "-X gopkg.in/src-d/hercules.v3.GIT_HASH=$(git rev-parse HEAD)" ./...
+  - pip3 install --user -r requirements.txt tensorflow
   - docker run -d --privileged -p 9432:9432 --name bblfshd bblfsh/bblfshd
   - docker exec -it bblfshd bblfshctl driver install --all
-  - git clone https://github.com/bblfsh/libuast
-  - cd libuast && cmake -DCMAKE_BUILD_TYPE=Release . && make && ln -s src libuast && cd ..
-  - export CGO_CFLAGS="-I$(pwd)/libuast -I$(pwd)/libuast/libuast" && export CGO_LDFLAGS="-luast -L$(pwd)/libuast/lib -Wl,-rpath -Wl,$(pwd)/libuast/lib"
   
 script:
   - go test -v -cpu=1,2 -coverprofile=coverage.txt -covermode=count gopkg.in/src-d/hercules.v3
-  - $GOPATH/bin/hercules -files -people -couples https://github.com/src-d/hercules | python3 labours.py -m all -o out --backend Agg --disable-projector
-  - $GOPATH/bin/hercules -files -people -couples -pb https://github.com/src-d/hercules | python3 labours.py -f pb -m all -o out --backend Agg --disable-projector
+  - $GOPATH/bin/hercules -version
+  - $GOPATH/bin/hercules -burndown -burndown-files -burndown-people -couples https://github.com/src-d/hercules | python3 labours.py -m all -o out --backend Agg --disable-projector
+  - $GOPATH/bin/hercules -burndown -burndown-files -burndown-people -couples -pb https://github.com/src-d/hercules | python3 labours.py -f pb -m all -o out --backend Agg --disable-projector
 
 after_success:
   - bash <(curl -s https://codecov.io/bash)

+ 8 - 2
Makefile

@@ -1,11 +1,17 @@
-all: ${GOPATH}/src/gopkg.in/bblfsh/client-go.v2 ${GOPATH}/bin/hercules
+ifneq (oneshell, $(findstring oneshell, $(.FEATURES)))
+  $(error GNU make 3.82 or later is required)
+endif
+
+all: dependencies ${GOPATH}/bin/hercules
 
 test: all
 	go test gopkg.in/src-d/hercules.v3
 
+dependencies: ${GOPATH}/src/gopkg.in/bblfsh/client-go.v2
+
 .ONESHELL:
 ${GOPATH}/src/gopkg.in/bblfsh/client-go.v2:
-	go get -v gopkg.in/bblfsh/client-go.v2/...
+	go get -v gopkg.in/bblfsh/client-go.v2/... || true
 	cd $$GOPATH/src/gopkg.in/bblfsh/client-go.v2
 	make dependencies
 

+ 20 - 17
cmd/hercules/main.go

@@ -52,6 +52,7 @@ import (
 	"github.com/vbauerster/mpb"
 	"github.com/vbauerster/mpb/decor"
 	"github.com/gogo/protobuf/proto"
+	"golang.org/x/crypto/ssh/terminal"
 )
 
 type OneLineWriter struct {
@@ -179,24 +180,26 @@ func main() {
 	// core logic
 	pipeline := hercules.NewPipeline(repository)
 	pipeline.SetFeaturesFromFlags()
-	progress := mpb.New(mpb.Output(os.Stderr))
-	defer progress.Stop()
-	var bar *mpb.Bar
-	pipeline.OnProgress = func(commit, length int) {
-		if bar == nil {
-			width := len(strconv.Itoa(length)) * 2 + 3
-			bar = progress.AddBar(int64(length + 1),
-				mpb.PrependDecorators(decor.DynamicName(
-					func (stats *decor.Statistics) string {
-						if stats.Current < stats.Total {
-							return fmt.Sprintf("%d / %d", stats.Current, length)
-						}
-						return "finalizing"
-					}, width, 0)),
-				mpb.AppendDecorators(decor.ETA(4, 0)),
-			)
+	if terminal.IsTerminal(int(os.Stderr.Fd())) {
+		progress := mpb.New(mpb.Output(os.Stderr))
+		defer progress.Stop()
+		var bar *mpb.Bar
+		pipeline.OnProgress = func(commit, length int) {
+			if bar == nil {
+				width := len(strconv.Itoa(length))*2 + 3
+				bar = progress.AddBar(int64(length+1),
+					mpb.PrependDecorators(decor.DynamicName(
+						func(stats *decor.Statistics) string {
+							if stats.Current < stats.Total {
+								return fmt.Sprintf("%d / %d", stats.Current, length)
+							}
+							return "finalizing"
+						}, width, 0)),
+					mpb.AppendDecorators(decor.ETA(4, 0)),
+				)
+			}
+			bar.Incr(commit - int(bar.Current()))
 		}
-		bar.Incr(commit - int(bar.Current()))
 	}
 
 	var commits []*object.Commit

+ 7 - 4
pipeline_test.go

@@ -4,12 +4,12 @@ import (
 	"errors"
 	"io"
 	"io/ioutil"
+	"flag"
 	"os"
 	"path"
 	"reflect"
 	"testing"
 
-	"flag"
 	"github.com/stretchr/testify/assert"
 	"gopkg.in/src-d/go-git.v4"
 	"gopkg.in/src-d/go-git.v4/plumbing"
@@ -113,9 +113,12 @@ func TestPipelineItemRegistrySummon(t *testing.T) {
 func TestPipelineItemRegistryAddFlags(t *testing.T) {
 	reg := getRegistry()
 	reg.Register(&testPipelineItem{})
+	flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
 	facts, deployed := reg.AddFlags()
-	assert.Len(t, facts, 1)
+	assert.Len(t, facts, 3)
 	assert.IsType(t, 0, facts[(&testPipelineItem{}).ListConfigurationOptions()[0].Name])
+	assert.Contains(t, facts, ConfigPipelineDryRun)
+	assert.Contains(t, facts, ConfigPipelineDumpPath)
 	assert.Len(t, deployed, 1)
 	assert.Contains(t, deployed, (&testPipelineItem{}).Name())
 	assert.NotNil(t, flag.Lookup((&testPipelineItem{}).Flag()))
@@ -142,9 +145,9 @@ func (item *dependingTestPipelineItem) Requires() []string {
 
 func (item *dependingTestPipelineItem) ListConfigurationOptions() []ConfigurationOption {
 	options := [...]ConfigurationOption{{
-		Name:        "TestOption",
+		Name:        "TestOption2",
 		Description: "The option description.",
-		Flag:        "test-option",
+		Flag:        "test-option2",
 		Type:        IntConfigurationOption,
 		Default:     10,
 	}}