In this article we will see how we can use a CI infrastructure like Travis in our add-on development process.
Before you proceed you should get familiar with how Travis work. You can find the relevant documentation here.
Before we can run our script for testing, we need to setup Firefox.
We will use the before_script section to download and install Firefox. We will use npm.
before_script: - npm install - npm install -g jpm - npm install -g mozilla-download
The script section, instead, will look like this:
script: - jpm test -v
Unfortunately we need something more. We need to specify the path of the Firefox binary.
The whole travis.yml file will look like:
language: node_js
node_js:
- "0.12"
env:
global:
- DISPLAY=:99.0
- JPM_FIREFOX_BINARY=firefox
- TMP_DIR=/tmp
before_install:
- sh -e /etc/init.d/xvfb start
before_script:
- npm install
- npm install -g jpm
- npm install -g mozilla-download
- pwd
- cd $TMP_DIR
- mozilla-download --branch mozilla-central --product firefox $TMP_DIR
- cd $TRAVIS_BUILD_DIR
- export JPM_FIREFOX_BINARY=$TMP_DIR/firefox/firefox
script:
- jpm test -v -b $JPM_FIREFOX_BINARY
notifications:
email:
on_failure: never
Some further details:
The env section define three variables:
- DISPLAY for the X server
- TMP_DIR the directory in which we download Firefox
- JPM_FIREFOX_BINARY the Firefox binary command
The before_script will install the necessary tool to download Firefox, it will install it and set the ENV variable JPM_FIREFOX_BINARY to the right path.
Finally the script section can run the test:
jpm test -v -b \$JPM_FIREFOX_BINARY
I hope this can be useful, please feel free to contribute.
More post about add-on development are coming. Stay tuned.