使用 Travis CI 来自动测试代码

  1. 登录 Travis CI 网站,https://travis-ci.org/,以 github 账号的方式登录。
  2. 然后选择一个自己找自动测试的代码目录,将 General 选项中的 Build only if .travis.yml is present 选中。
  3. 在 master 分支中新建一个 travis.yml, 写上自动测试的脚本。
    比如,使用 Travis CI 来自动生成 Hugo 网页, 可采用如下的方式
language: python
python: 2.7

branches:
  only:
  - master

install:
  - curl -L https://raw.githubusercontent.com/seisman/install/master/install-hugo.sh | bash
  - pip install pygments

script:
  - ./hugo

deploy:
  provider: pages
  skip_cleanup: true
  github_token: ${GH_TOKEN}
  local_dir: public
  1. 然后在 Travis CI 的项目依赖中添加 github_token 的环境变量即可。

Environment Variables
Notice that the values are not escaped when your builds are executed. Special characters (for bash) should be escaped accordingly.

你可能感兴趣的:(使用 Travis CI 来自动测试代码)