codeformunich/Muenchen-Transparent

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
language: php
sudo: false

php:
  - '7.3'

env:
  - TRAVIS_NODE_VERSION="6"

cache:
  apt: true
  yarn: true
  directories:
    - node_modules
    - vendor
    - $HOME/.composer/cache

services:
  - mysql

addons:
  apt:
    packages:
      - nginx

branches:
  only:
    - master

install:
  # PHP
  - cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
  - phpenv config-rm xdebug.ini # Speeds up build
  - phpenv config-add docs/travis/custom.php.ini
  - cp docs/travis/www.conf ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/ # Fix the php 7 config https://www.marcus-povey.co.uk/2016/02/16/travisci-with-php-7-on-apache-php-fpm/
  - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm

  # MySql
  - mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql # load timezone names
  - mysql -uroot --execute="SET GLOBAL time_zone = 'Europe/Berlin'"; # set the correct timezone (this has to match DEFAULT_TIMEZONE in the yii config)
  - docs/travis/mysql-5-5-schema-workaround.sh
  ## Import the testing data
  - mysql -e 'create database `mt-test`;'
  - cat docs/schema.sql tests/_data/data.sql docs/triggers.sql | mysql -utravis mt-test
  ## Import the example data
  - mysql -e 'create database muenchen_transparent;'
  - cat docs/schema.sql docs/beispieldaten.sql docs/triggers.sql | mysql -uroot muenchen_transparent

  # nginx
  - ln -s `pwd` /tmp/muenchen-transparent
  - nginx -c `pwd`/docs/nginx-test.conf

  # Preparation for the ba-geojson script
  - cp protected/config/main-test.php protected/config/main-production.php
  - mkdir html/js/build

  # dependencies
  ## Get the chosen node version
  - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
  - chmod 644 vendor/heise/shariff/index.php || true # Prevent a weird "has uncommitted changes" error message when updating shariff
  - composer install --prefer-source # --prefer-source fixes github's limits
  - yarn
  - node_modules/.bin/gulp

script:
  - vendor/bin/codecept run --env nohtmlvalidation # nohtmlvalidation is a workaround for the missing java 8

after_failure:
  - vendor/bin/codecept run --debug --env nohtmlvalidation
  - cat protected/runtime/application.log
  - cat /tmp/error.log
  - cat /tmp/access.log
  - cat tests/_output/*

after_script:
  - git checkout -- docs/schema.sql
  - docs/travis/require-clean-working-tree.sh # git shouldn't recognize any altered files after installing the dependencies and running the tests
  - nginx -c `pwd`/docs/travis/nginx-test.conf -s stop