英文:
Creating a TravisCI config for automated testing of a Go application
问题
我想创建一个.travis.yml配置文件,实现以下功能:
- 从Github获取Go应用程序的源代码,
- 使用
go get
安装其他所需的库, - 使用
go build
尝试构建Go应用程序, - 使用
go test
运行测试。
我对使用TravisCI进行Go应用程序测试还不熟悉,因此我会感激任何人能够给我提供帮助或示例。
英文:
I would like to create a .travis.yml config that performes the following:
- fetches a Go application source code from Github,
- installs the other required libraries with
go get
- attempts to build the go application with
go build
- run tests with
go test
I new to Go application testing with TravisCI, therefore I would appreciate any help or examples someone could point me to.
答案1
得分: 0
- 在你的代码库根目录下添加一个
.travis.yml
文件; - 将你的GitHub账号连接到TravisCI;
- 打开开关,使得在提交和拉取请求时运行构建。
以下是我在一些Gorilla工具包代码库中使用的配置:
language: go
sudo: false
matrix:
include:
- go: 1.2
- go: 1.3
- go: 1.4
- go: 1.5
- go: 1.6
- go: tip
install:
- go get golang.org/x/tools/cmd/vet
script:
- go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d .)
- go tool vet .
- go test -v -race ./...
(来源: https://github.com/gorilla/csrf/blob/master/.travis.yml)
英文:
- Add a
.travis.yml
to the root of your repository; - Connect your GitHub account to TravisCI
- Flick the switch to run builds on commits and pull requests.
Here's what I'm using for some of the Gorilla toolkit repos:
language: go
sudo: false
matrix:
include:
- go: 1.2
- go: 1.3
- go: 1.4
- go: 1.5
- go: 1.6
- go: tip
install:
- go get golang.org/x/tools/cmd/vet
script:
- go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d .)
- go tool vet .
- go test -v -race ./...
(source: https://github.com/gorilla/csrf/blob/master/.travis.yml)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论