diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 000000000..abe115dfc --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,69 @@ +version: "2" + +prepare: + fetch: + - url: "https://git.drupalcode.org/project/drupal/raw/8.7.x/.csslintrc" + path: ".csslintrc" + - url: "https://git.drupalcode.org/project/drupal/raw/8.7.x/core/.eslintrc.json" + path: ".eslintrc.json" + - url: "https://git.drupalcode.org/project/drupal/raw/8.7.x/core/.eslintignore" + path: ".eslintignore" + +checks: + argument-count: + enabled: false + complex-logic: + enabled: false + file-lines: + enabled: false + method-complexity: + enabled: false + method-count: + enabled: false + method-lines: + enabled: false + nested-control-flow: + config: + threshold: 16 + return-statements: + config: + threshold: 16 + similar-code: + config: + threshold: # language-specific defaults. an override will affect all languages. + identical-code: + config: + threshold: # language-specific defaults. an override will affect all languages. + +plugins: + phpcodesniffer: + enabled: true + config: + standard: "Drupal,DrupalPractice" + file_extensions: "php,inc,module,install" + phpmd: + enabled: false + csslint: + enabled: true + eslint: + enabled: true + duplication: + enabled: true + config: + languages: + php: + javascript: + fixme: + enabled: true + markdownlint: + enabled: true + issue_override: + severity: minor + +exclude_patterns: +- "config/" +- "translations/" +- "**/vendor/**/*" +- "**/.idea/**/*" +- "**/tests/**/*" +- "**/*.settings.php" diff --git a/.travis.yml b/.travis.yml index c9a113c28..dfc86df89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,10 +30,9 @@ mysql: encoding: utf8 before_script: - # Remove Xdebug as we don't need it and it causes "PHP Fatal error: Maximum - # function nesting level of '256' reached." - # We also don't care if that file exists or not on PHP 7. - - phpenv config-rm xdebug.ini || true + # Disable Xdebug to speed up Travis. + - cp $HOME/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini /tmp + - phpenv config-rm xdebug.ini # Make sure Composer is up to date. - composer self-update @@ -76,4 +75,15 @@ before_script: # Export database variable for kernel tests. - export SIMPLETEST_DB=mysql://root:@127.0.0.1/og + # Get the CodeClimate test reporter. + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build + + # Re-enable xdebug to support PHPUnit code coverage. + # - if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "${TEST_SUITE}" != "PHP_CodeSniffer" ]; then phpenv config-add /tmp/xdebug.ini; fi + script: DRUPAL_DIR=$DRUPAL_DIR MODULE_DIR=$MODULE_DIR $MODULE_DIR/scripts/travis-ci/run-test.sh $TEST_SUITE + +after_script: + - if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "${TEST_SUITE}" != "PHP_CodeSniffer" ]; then ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT; fi diff --git a/scripts/travis-ci/run-test.sh b/scripts/travis-ci/run-test.sh index 07797a6a9..104dcc66e 100755 --- a/scripts/travis-ci/run-test.sh +++ b/scripts/travis-ci/run-test.sh @@ -27,7 +27,7 @@ case "$1" in EXIT=0 for i in ${TEST_DIRS[@]}; do echo " > Executing tests from $i" - ./vendor/bin/phpunit -c ./core/phpunit.xml.dist $i || EXIT=1 + ./vendor/bin/phpunit -c ./core/phpunit.xml.dist $i --coverage-clover "$TRAVIS_BUILD_DIR/build/logs/clover.xml" || EXIT=1 done exit $EXIT esac