浏览代码

Add travis file

Laurent Destailleur 2 年之前
父节点
当前提交
4914fa5982
共有 1 个文件被更改,包括 220 次插入0 次删除
  1. 220 0
      .travis.yml

+ 220 - 0
.travis.yml

@@ -0,0 +1,220 @@
+# This script is used by Travis CI to run automatically Continuous test integration
+# from Dolibarr GitHub repository.
+# For syntax, see https://docs.travis-ci.com/user/languages/php/
+
+# We use dist: bionic = 18.04
+os: linux
+dist: bionic
+
+language: php
+
+git:
+  depth: 1
+
+# Start on every boot
+services:
+- mysql
+
+
+before_install:
+- |
+  echo "Add ondrej PPA"
+  sudo add-apt-repository -y ppa:ondrej/php
+  sudo apt-get update
+  echo "Disabling Xdebug for composer"
+  export PHP_VERSION_NAME=$(phpenv version-name)
+  echo $PHP_VERSION_NAME
+  ls ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/
+  cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini
+  phpenv config-rm xdebug.ini
+  phpenv rehash
+  echo
+
+addons:
+  # Force postgresql version
+  postgresql: '10'
+  apt:
+    sources:
+    - sourceline: 'ppa:ondrej/php'
+    packages:
+    - php
+    - php7.1-pgsql
+    - php7.1-mysqli
+    - php7.1-xml
+    - php7.1-intl
+    - php8.1-pgsql
+    - php8.1-mysqli
+    - php8.1-xml
+    - php8.1-intl
+    
+env:
+  global:
+  # Set to true for very verbose output
+  - DEBUG=false
+
+jobs:
+  fast_finish: true
+  #allow_failures:
+  #- php: nightly
+  include:
+    - stage: PHP 7.0-8.1
+      if: type = pull_request OR type = push
+      php: '8.1'
+      env: DB=mysql
+    - stage: PHP Dev
+      if: type = push AND branch = master
+      php: nightly
+      env: DB=mysql
+
+notifications:
+  email:
+    on_success: never # [always|never|change] default: change
+    on_failure: never # [always|never|change] default: always
+
+
+install:
+- |
+  echo "Updating Composer"
+  rm $TRAVIS_BUILD_DIR/composer.json
+  rm $TRAVIS_BUILD_DIR/composer.lock
+  composer -V
+  composer self-update
+  composer -n init
+  composer -n config vendor-dir htdocs/includes
+  composer -n config -g vendor-dir htdocs/includes
+  echo
+
+- |
+  echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION"
+  if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then
+    composer -n require phpunit/phpunit ^6 \
+                        php-parallel-lint/php-parallel-lint ^1 \
+                        php-parallel-lint/php-console-highlighter ^0 \
+                        php-parallel-lint/php-var-dump-check ~0.4 \
+                        squizlabs/php_codesniffer ^3
+  fi
+  if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
+    composer -n require phpunit/phpunit ^7 \
+                        php-parallel-lint/php-parallel-lint ^1.2 \
+                        php-parallel-lint/php-console-highlighter ^0 \
+                        php-parallel-lint/php-var-dump-check ~0.4 \
+                        squizlabs/php_codesniffer ^3
+  fi
+  # phpunit 9 is required for php 8
+  if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
+      composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \
+                                                 php-parallel-lint/php-parallel-lint ^1.2 \
+                                                 php-parallel-lint/php-console-highlighter ^0 \
+                                                 php-parallel-lint/php-var-dump-check ~0.4 \
+                                                 squizlabs/php_codesniffer ^3
+  fi
+  echo
+
+- |
+  echo "Adding path of binaries tools installed by composer to the PATH"
+  export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH"
+  echo $PATH
+  ls $TRAVIS_BUILD_DIR/vendor
+  ls $TRAVIS_BUILD_DIR/htdocs/includes/bin
+  echo
+
+
+
+before_script:
+  - |
+    echo Start travis
+    echo Current dir is `pwd`
+    echo Home dir is `echo ~`
+    echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR
+
+  - |
+    echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit"
+    phpenv config-add /tmp/xdebug.ini
+    echo
+
+  - |
+    echo "Setting up PHP"
+    echo
+    echo "Set timezone"
+    echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
+    phpenv rehash
+    echo
+
+  - |
+    echo "Versions information"
+    echo
+    # Check PHP
+    echo "PHP version"
+    php -i | head -
+    # Check Parallel-lint version
+    echo "Parallel-lint version"
+    which parallel-lint
+    parallel-lint -V
+    # Check PHP CodeSniffer version
+    echo "PHPCS version"
+    which phpcs
+    phpcs --version | head -
+    phpcs -i | head -
+    # Check PHP Vardump check version
+    echo "PHP Vardump check version"
+    which var_dump_check
+    var_dump_check --version
+    # Check PHPUnit version
+    echo "PHPUnit version"
+    which phpunit
+    phpunit --version | head -
+    echo
+
+script:
+- |
+  echo "Checking PHP syntax errors (only 1 version to not overload travis and avoid duplicate tests)"
+  # Ensure we catch errors
+  set -e
+  #parallel-lint --exclude htdocs/includes --blame .
+  # Exclusions are defined in the ruleset.xml file
+  if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+    parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \
+      --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \
+      --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \
+      --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \
+      --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --exclude htdocs/includes/webklex --blame .
+  fi
+  set +e
+  echo
+
+- |
+  echo "Checking coding style (only for Pull Requests builds and 1 version to not overload travis and avoid duplicate tests)"
+  # Ensure we catch errors
+  set -e
+  # Exclusions are defined in the ruleset.xml file
+  if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+    phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .;
+  fi
+  set +e
+  echo
+
+- |
+  echo "Checking missing debug"
+  # Ensure we catch errors
+  set -e
+  # Exclusions are defined in the ruleset.xml file
+  if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then
+     var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php .
+  fi
+  set +e
+  echo
+
+after_success:
+- |
+  echo Success
+
+after_failure:
+- |
+  echo Failure detected, so we show samples of log to help diagnose
+  # This part of code is executed only if the command that fails are enclosed with set +e
+  # Show upgrade log files
+  for ficlog in `ls $TRAVIS_BUILD_DIR/*.log`
+  do
+    echo "Debugging informations for file $ficlog"
+    #cat $ficlog
+  done