Skip to content

Instantly share code, notes, and snippets.

@mmcc007
Created November 2, 2018 00:32
Show Gist options
  • Save mmcc007/33297e799c2e7b0f7ca4e5363b8a7081 to your computer and use it in GitHub Desktop.
Save mmcc007/33297e799c2e7b0f7ca4e5363b8a7081 to your computer and use it in GitHub Desktop.
Running Flutter unit, widget and integration tests on Travis
jobs:
include:
- stage: Unit Testing
language: generic
os: linux
env: running unit and widget tests with code coverage
before_script:
- sudo apt-get install -y --no-install-recommends lib32stdc++6 libstdc++6 > /dev/null
- git clone https://github.com/flutter/flutter.git -b beta
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
- flutter precache
- flutter doctor -v
- pub global activate coverage
script: flutter test --coverage
after_success: bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info
- &integration-test-stage
stage: Integration Testing
sudo: true
dist: trusty
language: generic
os: linux
env: running driver on emulator
# Run integration tests on android
before_install:
- sudo apt-get install -y --no-install-recommends lib32stdc++6 libstdc++6 > /dev/null
# Install the Android SDK Dependency.
- export ANDROID_HOME=/opt/android-sdk-linux
- cd /opt
- wget -q https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -O android-sdk-tools.zip
- unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}
- rm android-sdk-tools.zip
- cd -
- PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
# Silence warning.
- mkdir -p ~/.android
- touch ~/.android/repositories.cfg
# Accept licenses before installing components, no need to echo y for each component
- yes | sdkmanager --licenses
# Platform tools
- sdkmanager "emulator" "tools" "platform-tools" > /dev/null
- sdkmanager --list | head -15
# install older packages (for emulator)
- sdkmanager "build-tools;25.0.2" "platforms;android-25" > /dev/null
# Create and start emulator.
- EMULATOR_API_LEVEL=22
- ANDROID_ABI="default;armeabi-v7a"
- sdkmanager "system-images;android-$EMULATOR_API_LEVEL;$ANDROID_ABI" > /dev/null
- sdkmanager --list | head -15
- echo no | avdmanager create avd --force -n test -k "system-images;android-$EMULATOR_API_LEVEL;$ANDROID_ABI"
- $ANDROID_HOME/emulator/emulator -avd test -no-audio -no-window -gpu swiftshader &
# install flutter
- git clone https://github.com/flutter/flutter.git -b beta
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
- flutter precache
- flutter doctor -v
# Wait for emulator to finish startup.
- ./script/android-wait-for-emulator.sh
- adb shell input keyevent 82
- flutter devices
script: travis_retry flutter drive
- <<: *integration-test-stage
os: osx
# use oldest flutter supported version of xcode
osx_image: xcode8.0
env: running driver on simulator
# Run integration tests on ios
before_install:
- open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
- brew update
- brew install libimobiledevice
- brew install ideviceinstaller
- brew install ios-deploy
- brew install cocoapods || echo 'ignore exit(1)'
- brew link --overwrite cocoapods
- git clone https://github.com/flutter/flutter.git -b beta
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- export PATH=`pwd`/flutter/bin:`pwd`/flutter/bin/cache/dart-sdk/bin:$PATH
- flutter precache
- flutter doctor -v
- flutter devices
- stage: Ready to deploy
os: osx
language: generic
env: not implemented 🤓
script: echo "Deploying to store ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment