cozy-labs/cozy-desktop

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
---
dist: trusty
language: node_js
node_js: 12.14.1
osx_image: xcode11
addons:
  apt:
      sources:
          - ubuntu-toolchain-r-test
      packages:
          - gcc-8
          - g++-8
          - jq
services:
  - docker
cache:
  yarn: true
  directories:
      - $HOME/.cache/electron
      - $HOME/.cache/electron-builder
      - $HOME/bin
os:
    - linux
    - osx
env:
    global:
        - COZY_DESKTOP_DIR=/tmp/cozy-desktop
        - COZY_URL="http://localhost:8080"
        - COZY_PASSPHRASE="cozy"
        - COZY_STACK_STORAGE="$HOME/storage"
        - GOPATH="$HOME"
        - GOPROXY="https://proxy.golang.org"
        - GO111MODULE=on
        # FIXME: Homebrew 1.7.3 fails to install cask apache-couchdb
        - HOMEBREW_NO_AUTO_UPDATE=1
        - MOCHA_TIMEOUT="240000"
        - NO_BREAKPOINTS=1
        - NODE_ENV=test
        - NPM_CONFIG_PROGRESS=false
        - COZY_DESKTOP_HEARTBEAT=1000
    matrix:
        - JOB=unit COZY_DESKTOP_FS=APFS
        - JOB=scenarios COZY_DESKTOP_FS=APFS
        - JOB=scenarios COZY_DESKTOP_FS=HFS+
        - JOB=stopped_scenarios COZY_DESKTOP_FS=APFS
        - JOB=dist COZY_DESKTOP_FS=APFS
        - JOB=unit CC=gcc-8 CXX=g++-8
        - JOB=scenarios CC=gcc-8 CXX=g++-8
        - JOB=stopped_scenarios CC=gcc-8 CXX=g++-8
        - JOB=dist CC=gcc-8 CXX=g++-8

branches:
    only:
        - master
jobs:
    fast_finish: true
    exclude:
        - if: os = linux
          env: JOB=unit COZY_DESKTOP_FS=APFS
        - if: os = linux
          env: JOB=scenarios COZY_DESKTOP_FS=APFS
        - if: os = linux
          env: JOB=stopped_scenarios COZY_DESKTOP_FS=APFS
        - if: os = linux
          env: JOB=dist COZY_DESKTOP_FS=APFS
        - if: os = linux
          env: JOB=scenarios COZY_DESKTOP_FS=HFS+
        - if: os = osx
          env: JOB=unit CC=gcc-8 CXX=g++-8
        - if: os = osx
          env: JOB=scenarios CC=gcc-8 CXX=g++-8
        - if: os = osx
          env: JOB=stopped_scenarios CC=gcc-8 CXX=g++-8
        - if: os = osx
          env: JOB=dist CC=gcc-8 CXX=g++-8
script: travis_wait ./dev/ci/script.sh

before_install: | # install cozy stack for integration test
    # CouchDB
    if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
      travis_retry docker run -d -p 5984:5984 --name couch apache/couchdb:2.3.1;
    fi
    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      wget https://dl.bintray.com/apache/couchdb/mac/2.3.1/Apache-CouchDB-2.3.1.zip
      unzip Apache-CouchDB-2.3.1.zip
      mv "Apache CouchDB.app" /Applications/
      #travis_retry brew cask install https://raw.githubusercontent.com/Homebrew/homebrew-cask/master/Casks/apache-couchdb.rb;
      printf "\n[log]\nlevel = warn\n" >> /Applications/Apache\ CouchDB.app/Contents/Resources/couchdbx-core/etc/local.ini;
      ulimit -S -n 1024;
      (/Applications/Apache\ CouchDB.app/Contents/Resources/couchdbx-core/bin/couchdb >couchdb.log 2>&1 &);
    fi
    sleep 8
    curl -X PUT http://127.0.0.1:5984/{_users,_replicator,_global_changes}

    # Cozy-stack
    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      travis_retry brew install gimme;
      travis_retry brew install imagemagick;
    fi
    if [[ ! -f $GOPATH/bin/cozy-stack ]]; then
      travis_retry gimme 1.14;
      source ~/.gimme/envs/go1.14.env;
      travis_retry go get github.com/cozy/cozy-stack;
    fi

    # Create a local instance and an OAuth client
    mkdir -p "$COZY_STACK_STORAGE"
    ($GOPATH/bin/cozy-stack serve --fs-url "file://$COZY_STACK_STORAGE" --log-level warning >cozy-stack.log 2>&1 &);
    sleep 1
    travis_retry $GOPATH/bin/cozy-stack instances add --dev --passphrase "$COZY_PASSPHRASE" localhost:8080
    export COZY_CLIENT_ID=$($GOPATH/bin/cozy-stack instances client-oauth localhost:8080 http://localhost/ test github.com/cozy-labs/cozy-desktop)
    export COZY_STACK_TOKEN=$($GOPATH/bin/cozy-stack instances token-oauth localhost:8080 "$COZY_CLIENT_ID" io.cozy.files io.cozy.settings)

    # COZY_DESKTOP_DIR
    if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
      hdiutil create -megabytes 50 -fs "$COZY_DESKTOP_FS" -volname cozy-desktop "$COZY_DESKTOP_DIR";
      hdiutil attach "${COZY_DESKTOP_DIR}.dmg" -mountpoint "$COZY_DESKTOP_DIR";
    else
      mkdir -p "$COZY_DESKTOP_DIR";
    fi

    # Dummy .env.test (all variables are already set)
    # env-cmd ignores the file when empty
    echo "NODE_ENV=test" > "${TRAVIS_BUILD_DIR}/.env.test"

after_failure: ./dev/ci/after_failure.sh