11 Travis CI

11.1 basics

  • template
dist: bionic
language: minimal
git:
  depth: false
  submodules: false
  
script: skip

notifications:
  email: false
  • apt packages
addons:
  apt:
    update: true
    packages:
      - cmake
  • terminate build
script:
  - travis_terminate 0

11.2 extended features

  • trigger build

In Settings, add TRAVIS_TOKEN environment variable.

after_success:
  - user=dongzhuoer; repo=empty; body='{ "request":{"branch":"master", "message":"rebuilt $TRAVIS_REPO_SLUG"} }'
  - curl -s -X POST -H "Authorization:token $TRAVIS_TOKEN" -H "Content-Type:application/json" -H "Accept:application/json" -H "Travis-API-Version:3" -d "$body" "https://api.travis-ci.com/repo/$user%2F$repo/requests"
  • install latest GitHub release

Here we use pandoc as an example, for other software, one may need to custom the regexp.

RUN apt update && apt -y install wget gdebi-core \
    && wget -q -O - https://github.com/jgm/pandoc/releases/latest | grep -oP '([^"]+.deb)(?=")' | sed 's/^/https:\/\/github.com/' | xargs wget -q -O pandoc.deb && echo y | gdebi pandoc.deb && rm pandoc.deb \
    && apt -y purge wget gdebi-core && apt -y autoremove && rm -r /var/lib/apt/lists/
  • avoid log exceeding 4M

General strategy is to find the cause, then solve it.

Take R packages for example, one can search *source*, and examine right panel, big space between highlight indicate a verbose package; the left thing is quiet easy, quiet = TRUE.

11.3 automatically tasks template

Generally, we get input from GitHub, install needed software, build output, finally deploy to GitLab.

Refer to docker-rlang readme since I mainly use R markdown.