KevCaz's Website

Matrix build is a very powerful feature of Travis CI: it allows you to define a list of custom environments wherein your software will be built. For instead, I check rcites on 4 different environments (note that Travis offers 3 different Ubuntu version, several MacOSX images and that the support for Windows is in early stage).

A few days ago, the matrix build I used for another R 📦 failed with the following error (see https://travis-ci.com/mangal-wg/rmangal/jobs/211574578 for the log):

$ if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get --yes --force-yes update -qq; fi
W: GPG error: https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6B05F25D762E3157
W: The repository 'https://packagecloud.io/github/git-lfs/ubuntu trusty InRelease' is not signed.

which was caused by the lines below I used in .travis.yml:

1
2
3
4
5
before_install:
  - if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo add-apt-repository ppa:ubuntugis/ppa --yes; fi
  - if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get --yes --force-yes update -qq; fi
  - if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev; fi
  - R -e 'install.packages("rgdal", repos=c("http://R-Forge.R-project.org", "http://cran.rstudio.com"))'

Well, I could have traced back where the apt-get-related issue stemmed from, but I decided otherwise: I reviewed .travis.yml to properly use the matrix build. The [documentation about it is good] but, IMHO, it lacks a couple of examples. That said, such examples are actually available in the zillion of repositories that use Travis! Even even Travis developers refer to these examples! So, after I had a look at this .travis.yml example, here is what I ended up doing:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
matrix:
  include:
    - os: linux
      dist: trusty
      r: release
      env: NOT_CRAN=true
      addons:
        apt:
          sources:
            - sourceline: 'ppa:opencpu/jq'
            - sourceline: 'ppa:ubuntugis/ubuntugis-unstable'
          packages:
            - libudunits2-dev
            - libproj-dev
            - libgeos-dev
            - libgdal-dev
    - os: osx
      r: release
      env: NOT_CRAN=true
    - os: linux
      dist: xenial
      r: devel
      env: NOT_CRAN=false
      addons:
        apt:
          packages:
            - libudunits2-dev
            - libproj-dev
            - libgeos-dev
            - libgdal-dev