diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 34c288d9c3750f6725ec338559e9c844afed919c..7c823c75858442ba7f54b52023066574681a0b39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,6 +52,38 @@ variables: OPT_IN_TEST_NEXT_MINOR: 1 OPT_IN_TEST_NEXT_MAJOR: 1 OPT_IN_TEST_MAX_PHP: 1 + _PHPUNIT_CONCURRENT: 0 + +phpunit (coverage): + extends: phpunit + rules: + - if: '$SKIP_PHPUNIT == "1"' + when: never + - when: on_success + before_script: + # Install and enable PCOV. + - echo -e '[pcov]\npcov.directory=.' > /usr/local/etc/php/conf.d/pcov.ini + - docker-php-ext-enable pcov + variables: + REPORT_COVERAGE: "true" + _PHPUNIT_EXTRA: + value: --coverage-cobertura $CI_PROJECT_DIR/coverage.xml --coverage-text --colors=never --coverage-html $CI_PROJECT_DIR/public/coverage + coverage: /^\s*Lines:\s*\d+.\d+\%/ + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml + paths: + - junit.xml + - apache.access.log.txt + - $BROWSERTEST_OUTPUT_DIRECTORY + - coverage.xml + - public + +phpunit: + rules: + - when: never ################################################################################### diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..df6fd710808887ec074edd6ac890e31daf6f1ee6 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" + bootstrap="web/core/tests/bootstrap.php" + executionOrder="depends,defects" + beStrictAboutOutputDuringTests="true" + failOnRisky="false" + failOnWarning="false"> + + <php> + <!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "goog:chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" --> + <env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chromedriver:9515"]'/> + </php> + + <extensions> + <!-- Functional tests HTML output logging. --> + <bootstrap class="Drupal\TestTools\Extension\HtmlLogging\HtmlOutputLogger"> + <!-- The directory where the browser output will be stored. If a relative + path is specified, it will be relative to the current working directory + of the process running the PHPUnit CLI. In CI environments, this can be + overridden by the value set for the "BROWSERTEST_OUTPUT_DIRECTORY" + environment variable. + --> + <parameter name="outputDirectory" value="sites/simpletest/browser_output"/> + <!-- By default browser tests print the individual links in the test run + report. To avoid overcrowding the output in CI environments, you can + set the "verbose" parameter or the "BROWSERTEST_OUTPUT_VERBOSE" + environment variable to "false". In GitLabCI, the output is saved + anyway as an artifact that can be browsed or downloaded from Gitlab. + --> + </bootstrap> + </extensions> + + <source> + <include> + <directory>web/modules/custom/*</directory> + <directory suffix=".module">web/modules/custom/*</directory> + <directory suffix=".install">web/modules/custom/*</directory> + + </include> + <exclude> + <directory>web/modules/custom/*/tests</directory> + <directory suffix=".module">web/modules/custom/*/tests</directory> + <directory>web/modules/custom/*/modules/*/tests</directory> + <directory suffix=".module">web/modules/custom/*/modules/*/tests</directory> + <directory suffix=".api.php">web/modules/custom/*</directory> + </exclude> + </source> +</phpunit>