26

I want to test different builds of my .js framework against many browsers

I expected to write something like:

language: node_js
node_js:
- 0.11
env:
  matrix:
    - BUILD='nocompat'
    - BUILD='compat'
    - BUILD='default'

    - BROWSER='ie6'
    - BROWSER='ie7'
    # etc... about total 15 browsers/platforms

But the only way I got it working was specifying all combinations "by hand"...

Like:

env:
  matrix:
    - BROWSER='chrome_linux'    BUILD='default'
    - BROWSER='chrome_linux'    BUILD='compat'
    - BROWSER='chrome_linux'    BUILD='nocompat'
    - BROWSER='firefox'         BUILD='default'
    - BROWSER='firefox'         BUILD='compat'
    - BROWSER='firefox'         BUILD='nocompat'

    # etc ... and this is about 50 lines!

Is there another way to do this? Or is this the right way?

treeface
  • 13,270
  • 4
  • 51
  • 57
Sergio
  • 28,539
  • 11
  • 85
  • 132

2 Answers2

22

Looks like you can't DRY right now: travis-ci issue #1519

phadej
  • 11,947
  • 41
  • 78
2

I believe the syntax for travis-build matrix environmental variables is:

env:
  - STUFF=true
  - STUFF=false

The env: matrix: is used for specifying variables that stay in the build matrix when you have a env:global for variables that aren't used for the build matrix.

You can read up more on matrices here. As a note, 50 seperate builds for your project is a little crazy, in fact, I'm not sure travis-ci supports 50 different builds in a matrix. I would narrow it down to about 10-20 personally.

mloskot
  • 37,086
  • 11
  • 109
  • 136
joshua-anderson
  • 4,458
  • 5
  • 35
  • 56
  • Tried defining variables in outside the `env: matrix:` as suggested but got error: `expected , but found Key while parsing a block collection` – Sergio Mar 16 '14 at 08:24
  • Joshua, yes. __[And it works](https://travis-ci.org/SergioCrisostomo/mootools-core/builds/20853275)__, but I would like it to be more clean – Sergio Mar 16 '14 at 21:53
  • Sorry, I meant the yml with env variables set as I suggested. – joshua-anderson Mar 16 '14 at 23:44
  • Joshua, sorry for late reply. I still didn't find a better way. To answer your question: it doesn't work if the variables are directly under `env:` like you suggested – Sergio Mar 30 '14 at 12:57