From f77a99afe50aa5ae0472042f562dfb324d651fa6 Mon Sep 17 00:00:00 2001 From: Steven Ayers <5614-bluegeek9@users.noreply.drupalcode.org> Date: Sat, 29 Mar 2025 17:17:51 +0000 Subject: [PATCH] Issue #3516242: Code Coverage Metrics --- .gitlab-ci.yml | 32 +++++++++++++++++++++++++++++++ phpunit.xml.dist | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 34c288d..7c823c7 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 0000000..df6fd71 --- /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> -- GitLab