Commit 6e888fe4 authored by Jonathan Smith's avatar Jonathan Smith Committed by Tim Rohaly
Browse files

Issue #3317081 by jonathan1055: Add Travis test at 9.5 and fix phpcs installed_paths

parent 93f228ea
Loading
Loading
Loading
Loading
+28 −19
Changes for .travis.yml: 28 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -16,13 +16,14 @@ jobs:
  include:
    - php: 7.3
      env:
        # Run tests at core 9.1 as this is the minimum supported by Typed Data.
        - DRUPAL_CORE=9.1.x
        # --- Remaining self deprecation notices (0)
        # --- Remaining direct deprecation notices (0)
        - DEPRECATIONS=0
    - php: 7.4
      env:
        - DRUPAL_CORE=9.4.x
        - DRUPAL_CORE=9.5.x
        # --- Remaining self deprecation notices (0)
        # --- Remaining direct deprecation notices (0)
        - DEPRECATIONS=0
@@ -43,16 +44,15 @@ before_script:
  # We also don't care if that file exists or not on PHP 7.
  - phpenv config-rm xdebug.ini || true

  # Save the starting directory, which is where the module code is located.
  - TESTDIR=$(pwd)
  - echo $TESTDIR
  # Navigate up to prevent blown stack by recursive module lookup.
  # Navigate up out of $TRAVIS_BUILD_DIR to prevent blown stack on recursive module lookup.
  - pwd
  - cd ..

  # Create database.
  - mysql -e "create database $MODULE"
  # Export database variable for kernel tests.
  - export SIMPLETEST_DB=mysql://root:@127.0.0.1/$MODULE

  # Download Drupal core from the Github mirror because it is faster.
  - travis_retry git clone --branch $DRUPAL_CORE --depth 1 https://github.com/drupal/drupal.git
  - cd drupal
@@ -60,16 +60,23 @@ before_script:
  - DRUPAL_ROOT=$(pwd)
  - echo $DRUPAL_ROOT

  # Create a link in /modules to the actual module source.
  - ln -s $TESTDIR modules/$MODULE
  # Make a directory for our module and copy the built source into it.
  - mkdir $DRUPAL_ROOT/modules/$MODULE
  - cp -R $TRAVIS_BUILD_DIR/* $DRUPAL_ROOT/modules/$MODULE/

  # Install the site dependencies via Composer.
  # At job start-up Composer is installed at 1.8.4 then self-update is run. From
  # 24 October 2020 this bumped the version to Composer 2.
  - composer --version
  - travis_retry composer install

  # Coder is already installed as part of composer install. We just need to set
  # the installed_paths to pick up the Drupal standards.
  - $DRUPAL_ROOT/vendor/bin/phpcs --config-set installed_paths $DRUPAL_ROOT/vendor/drupal/coder/coder_sniffer
  # Coder is already installed as part of composer install. For Coder versions
  # up to 8.3.13 (Core 9.3) we need to set the installed_paths to pick up the
  # Drupal standards. From 8.3.14 (Core 9.4+) this is done at install time.
  - |
    if [[ "$DRUPAL_CORE" == "9.1.x" ]]; then
      $DRUPAL_ROOT/vendor/bin/phpcs --config-set installed_paths $DRUPAL_ROOT/vendor/drupal/coder/coder_sniffer
    fi

  # Start a web server on port 8888, run in the background.
  - php -S localhost:8888 &
@@ -85,17 +92,19 @@ script:
  # Run the PHPUnit tests which also include the kernel tests.
  - ./vendor/bin/phpunit -c ./core/phpunit.xml.dist ./modules/$MODULE/tests/

  # Check for coding standards. First change directory to our module.
  # Check for coding standards. First show the versions.
  - composer show drupal/coder | egrep 'name |vers'
  - composer show squizlabs/php_codesniffer | egrep 'name |vers'
  - $DRUPAL_ROOT/vendor/bin/phpcs --version
  - $DRUPAL_ROOT/vendor/bin/phpcs --config-show installed_paths

  # Change into $MODULE directory to avoid having to add --standard=$DRUPAL_ROOT/modules/$MODULE/phpcs.xml.dist
  - cd $DRUPAL_ROOT/modules/$MODULE

  # List all the sniffs that were used.
  - $DRUPAL_ROOT/vendor/bin/phpcs --version
  - $DRUPAL_ROOT/vendor/bin/phpcs --config-show
  # List the standards and the sniffs that are used.
  - $DRUPAL_ROOT/vendor/bin/phpcs -i
  - $DRUPAL_ROOT/vendor/bin/phpcs -e

  # Show the violations in detail and do not fail for any errors or warnings.
  - $DRUPAL_ROOT/vendor/bin/phpcs --report-width=130 --colors --runtime-set ignore_warnings_on_exit 1 --runtime-set ignore_errors_on_exit 1 .

  # Run again to give a summary and total count.
  - $DRUPAL_ROOT/vendor/bin/phpcs --report-width=130 --colors --runtime-set ignore_warnings_on_exit 1 --runtime-set ignore_errors_on_exit 1 --report=summary .
  # Show the coding standards faults in detail, and with summary and source
  # reports. Switch -s shows the sniff names.
  - $DRUPAL_ROOT/vendor/bin/phpcs --report-width=130 --colors -s --report-full --report-summary --report-source .