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