Testing Add-on SDK Extensions on Travis CI

Recently Mozilla restricted access to ftp.mozilla.org, instead you can download nightlies from archive.mozilla.org. Sadly this broke existing methods to download Firefox nightly for automated unit tests on Travis CI. I’ve written a node module, that takes care of downloading nightly versions of Firefox desktop and Android.

.travis.yml for Desktop

sudo: false<br />
language: node_js<br />
node_js: stable<br />
env:<br />
  global:<br />
    - DISPLAY=:99.0<br />
    - JPM_FIREFOX_BINARY=$TRAVIS_BUILD_DIR/../firefox/firefox<br />
before_install:<br />
  - sh -e /etc/init.d/xvfb start<br />
  - npm i -g get-firefox<br />
  - get-firefox -ecb unbranded-release -t ../<br />
before_script:<br />
  - npm install -g jpm<br />
script:<br />
  - jpm test

Update: I changed the export commands to setting the variables with the .travis.yml env property, because it feels cleaner.

Update 2: Switched to the Firefox from travis.

Update 3: With unsigned builds being a thing and travis not supporting them yet, I’ve switched back to using get-firefox for desktop tests too.

.travis.yml for Android

Since jpm-mobile is currently broken, this clones a fixed version and installs it. Further, timing for the Android Emulator is somewhat important, so you might have to fiddle with the order and content of the before sections.

sudo: false<br />
language: android<br />
android:<br />
  components:<br />
    - platform-tools<br />
    - tools<br />
    - android-19<br />
    - sys-img-armeabi-v7a-android-19<br />
env:<br />
  global:<br />
    - DISPLAY=99.0<br />
    - JPM_FIREFOX_BINARY=fennec<br />
    - JPM_ADB_PATH=/usr/local/android-sdk/platform-tools/adb<br />
    - TMP_DIR=/tmp<br />
before_install:<br />
  - sh -e /etc/init.d/xvfb start<br />
  - mkdir -p $TMP_DIR/sdcard<br />
  - mksdcard -l jetpackSdCard 1024M $TMP_DIR/sdcard/jpmsdcard.img<br />
  - rm -f $TMP_DIR/sdcard/jpmsdcard.img.lock<br />
  - echo no | android create avd --force -n jpm -t android-19 --abi armeabi-v7a<br />
  - emulator -avd jpm -sdcard $TMP_DIR/sdcard/jpmsdcard.img -no-audio -gpu off -no-boot-anim -noskin &amp;amp;<br />
  - android-wait-for-emulator<br />
before_script:<br />
  - npm install -g get-firefox<br />
  - git clone --depth 1 -b fixes https://github.com/ncalexan/jpm-mobile.git $TMP_DIR/jpm-mobile<br />
  - cd $TMP_DIR/jpm-mobile<br />
  - npm link<br />
  - cd $TRAVIS_BUILD_DIR<br />
  - get-firefox -c -p android -t $TMP_DIR/fennec.apk<br />
  - adb wait-for-device<br />
  - adb emu input keyevent 82 &amp;amp;amp;<br />
  - adb install $TMP_DIR/fennec.apk<br />
script:<br />
  - jpm-mobile test -v --adb $JPM_ADB_PATH -b $JPM_FIREFOX_BINARY