17

Golang持续集成服务之Travis教程

 4 years ago
source link: https://studygolang.com/articles/28204
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

我们向github提交代码时, 我们得保证我们的代码是能运行的, 我们会写测试用例, 保证我们的代码功能能正常使用.常见大神们的开源项目都一个绿色图标"build|passing 表示构建OK

如何使用Travis服务呢

打开这个网站 travis-ci.org/ 点击登陆, 使用github登陆.目前似也只支持github

1. 添加仓库

rmyEFnn.png!web

2. 开启集成

YBBB3uu.png!web

3. 项目根目录添加.travis.yml文件

cd ~/github_webhook
touch .travis.yml 
复制代码

4. 编写.travis.yml文件

language: go
go - 1.14
sudo:required
os
install
script

以下是个测试空命令文件, 可以拿测试.看看能不能运行

language: go
go:
  - 1.14

sudo: required

os:
  - linux
  - osx

install:
  - echo "install"

script:
  - echo "script"
复制代码

以下是一个正式的集成测试文件

language: go
go:
  - 1.14

sudo: required

os:
  - linux
  - osx

install:
  - echo "install"
  - go get -u github.com/go-bindata/go-bindata/...

script:
  - echo "script"
  - make dev
复制代码
  • 将.travis.yml提交到github代码仓库里.
  • 以后每次push都会有结果的.如果通过集成,则图标是绿色的.

3. 查看集成的结果

点击你刚才开启的仓库名称, 进入监听页面.

E7ZJJbj.png!web

以下是linux环境下的运行结果,很详细的步骤,哪里出错,你就对应的修改.如果测试不通过. 不会显示 小绿图标

AjMruyz.png!web

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK