在 Travis CI 自动构建 Go 的 tip 版本时使用 Godep 出现错误。

huangapple go评论82阅读模式
英文:

Error using Godep on Travis CI automated build for tip version of Go

问题

我正在使用Travis CI来自动构建和测试我的Go项目。

./Godeps/Godeps.json文件的内容如下:

{
    "ImportPath": "github.com/my_project_path",
    "GoVersion": "go1.5",
    "Packages": [
        "./..."
    ],
    "Deps": [
        {
            "ImportPath": "github.com/Sirupsen/logrus",
            "Comment": "v0.8.7-53-g446d1c1",
            "Rev": "446d1c146faa8ed3f4218f056fcd165f6bcfda81"
        }
    ]
}

.travis.yml文件的内容如下:

language: go

go: 
 - 1.3.3
 - 1.4.2
 - 1.5.1
 - release
 - tip

before_install:
 - go get github.com/my_project_path
 - go get github.com/tools/godep

install:
 - godep restore

script:
 - go test -v ./...

除了tip之外,所有其他构建都正常,因为go version的问题。

Travis CI日志中tip的最后几行内容如下:

$ go version

go version devel +e4dcf5c Thu Dec 24 06:55:33 2015 +0000 linux/amd64
go.env

$ go env

GOARCH="amd64"

GOBIN=""

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="linux"

GOOS="linux"

GOPATH="/home/travis/gopath"

GORACE=""

GOROOT="/home/travis/.gimme/versions/go"

GOTOOLDIR="/home/travis/.gimme/versions/go/pkg/tool/linux_amd64"

GO15VENDOREXPERIMENT="1"

CC="gcc"

GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"

CXX="g++"

CGO_ENABLED="1"
before_install.1

3.52s$ go get github.com/my_project_path
before_install.2

3.34s$ go get github.com/tools/godep

0.02s$ godep restore

godep: Error determing major go version from: "devel"

The command "godep restore" failed and exited with 1 during .

Your build has been stopped.

我该如何解决这个问题?我只能使用go get ./...吗?

编辑: 看起来有人提出了一个拉取请求来修复这个问题。

编辑2: 看起来这个拉取请求已经合并。我会尽快测试是否已经修复。

英文:

I'm using Travis CI to automate builds and tests on my Go project.

The ./Godeps/Godeps.json looks like this :

{
	"ImportPath": "github.com/my_project_path",
	"GoVersion": "go1.5",
	"Packages": [
		"./..."
	],
	"Deps": [
		{
			"ImportPath": "github.com/Sirupsen/logrus",
			"Comment": "v0.8.7-53-g446d1c1",
			"Rev": "446d1c146faa8ed3f4218f056fcd165f6bcfda81"
		}
	]
}

The .travis.yml file looks like this :

language: go

go: 
 - 1.3.3
 - 1.4.2
 - 1.5.1
 - release
 - tip

before_install:
 - go get github.com/my_project_path
 - go get github.com/tools/godep

install:
 - godep restore

script:
 - go test -v ./...

All other builds work except for tip because of go version.

The last few lines of the Travis CI log for tip are :

$ go version

go version devel +e4dcf5c Thu Dec 24 06:55:33 2015 +0000 linux/amd64
go.env

$ go env

GOARCH="amd64"

GOBIN=""

GOEXE=""

GOHOSTARCH="amd64"

GOHOSTOS="linux"

GOOS="linux"

GOPATH="/home/travis/gopath"

GORACE=""

GOROOT="/home/travis/.gimme/versions/go"

GOTOOLDIR="/home/travis/.gimme/versions/go/pkg/tool/linux_amd64"

GO15VENDOREXPERIMENT="1"

CC="gcc"

GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"

CXX="g++"

CGO_ENABLED="1"
before_install.1

3.52s$ go get github.com/my_project_path
before_install.2

3.34s$ go get github.com/tools/godep

0.02s$ godep restore

godep: Error determing major go version from: "devel"

The command "godep restore" failed and exited with 1 during .

Your build has been stopped.

How can I fix this? Am I just stuck with using go get ./...?

EDIT: It seems someone made a pull request to fix this.

EDIT2: Seems the pull request was merged. Will test if it's fixed soonish.

答案1

得分: 1

所以我在2015年12月24日提出了这个问题。

2015年12月29日,GitHub用户zchee提出了一个拉取请求,修复了我问题中提到的问题。

2016年1月4日,该拉取请求被合并到了godepmaster分支中。因此,问题现在已经解决了,为了让Travis CI使用godep restore并针对Gotip版本测试你的项目,你的.travis.yml文件应该像问题中那样,即:

language: go

go: 
 - 1.3.3
 - 1.4.2
 - 1.5.1
 - release
 - tip

before_install:
 - go get github.com/my_project_path
 - go get github.com/tools/godep

install:
 - godep restore

script:
 - go test -v ./...
英文:

So I asked this question on December 24 2015.

On December 29 2015, github user zchee opened a pull request that fixed the issue mentioned in my question.

On January 4 2016, the pull request was merged into the master branch of godep. So essentially the issue is now fixed and in order for Travis CI to use godep restore and test your project against the tip version of Go, your .travis.yml file should look like it does in the question, i.e.:

language: go

go: 
 - 1.3.3
 - 1.4.2
 - 1.5.1
 - release
 - tip

before_install:
 - go get github.com/my_project_path
 - go get github.com/tools/godep

install:
 - godep restore

script:
 - go test -v ./...

huangapple
  • 本文由 发表于 2015年12月24日 17:31:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/34450483.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定