Skip to content

Commit

Permalink
[FEATURE] Added code coverage with Coveralls by introducing php-cover…
Browse files Browse the repository at this point in the history
…alls and merging with phpcov
  • Loading branch information
RinyVT committed Dec 19, 2024
1 parent 7d83656 commit bb628c6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,29 @@ jobs:
run: Build/Scripts/runTests.sh -t ${{ matrix.typo3 }} -p ${{ matrix.php }} -s functional

- name: Unit tests
run: Build/Scripts/runTests.sh -t ${{ matrix.typo3 }} -p ${{ matrix.php }} -s unit
run: Build/Scripts/runTests.sh -t ${{ matrix.typo3 }} -p ${{ matrix.php }} -s unit

- name: Functional tests coverage
if: matrix.php == '8.2' && matrix.typo3 == '13' && matrix.composerInstall == 'composerInstallHighest'
run: Build/Scripts/runTests.sh -t ${{ matrix.typo3 }} -p ${{ matrix.php }} -s unit -x -e "--coverage-php=.Build/coverage/functional.cov"

- name: Unit tests coverage
if: matrix.php == '8.2' && matrix.typo3 == '13' && matrix.composerInstall == 'composerInstallHighest'
run: Build/Scripts/runTests.sh -t ${{ matrix.typo3 }} -p ${{ matrix.php }} -s unit -x -e "--coverage-php=.Build/coverage/unit.cov"

- name: Composer require phpunit/phpcov for merging the code coverage
if: matrix.php == '8.2' && matrix.typo3 == '13' && matrix.composerInstall == 'composerInstallHighest'
run: Build/Scripts/runTests.sh -t ${{ matrix.typo3 }} -p ${{ matrix.php }} -s composer require --dev phpunit/phpcov

- name: Merge coverage
if: matrix.php == '8.2' && matrix.typo3 == '13' && matrix.composerInstall == 'composerInstallHighest'
run: ./.Build/bin/phpcov merge --clover=build/logs/clover.xml .Build/coverage

- name: Upload coverage
if: matrix.php == '8.2' && matrix.typo3 == '13' && matrix.composerInstall == 'composerInstallHighest'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
export PATH="$(composer config -g home)/vendor/bin:$PATH"
php-coveralls --coverage_clover=build/logs/clover.xml -v
12 changes: 5 additions & 7 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,14 @@ if ! type "docker" >/dev/null 2>&1 && ! type "podman" >/dev/null 2>&1; then
fi

# Option defaults
# @todo Consider to switch from cgl to help as default
TEST_SUITE="cgl"
TEST_SUITE="help"
TYPO3_VERSION="11"
EXTRA_TEST_OPTIONS=""
DATABASE_DRIVER=""
DBMS="sqlite"
DBMS_VERSION=""
PHP_VERSION="8.2"
PHP_XDEBUG_ON=0
PHP_XDEBUG_COVERAGE=0
PHP_XDEBUG_PORT=9003
CGLCHECK_DRY_RUN=0
CI_PARAMS="${CI_PARAMS:-}"
Expand Down Expand Up @@ -335,7 +334,7 @@ while getopts "a:b:d:i:s:p:e:t:xy:nhu" OPT; do
fi
;;
x)
PHP_XDEBUG_ON=1
PHP_XDEBUG_COVERAGE=1
;;
y)
PHP_XDEBUG_PORT=${OPTARG}
Expand Down Expand Up @@ -438,12 +437,11 @@ else
CONTAINER_DOCS_PARAMS="${CONTAINER_INTERACTIVE} ${DOCS_PARAMS} --rm --network ${NETWORK} -v ${ROOT_DIR}:/project"
fi

if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
if [ ${PHP_XDEBUG_COVERAGE} -eq 0 ]; then
XDEBUG_MODE="-e XDEBUG_MODE=off"
XDEBUG_CONFIG=" "
else
XDEBUG_MODE="-e XDEBUG_MODE=debug -e XDEBUG_TRIGGER=foo"
XDEBUG_CONFIG="client_port=${PHP_XDEBUG_PORT} client_host=${CONTAINER_HOST}"
XDEBUG_MODE="-e XDEBUG_MODE=coverage"
fi

# Suite execution
Expand Down
5 changes: 5 additions & 0 deletions Build/phpunit/FunctionalTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
<source>
<include>
<directory>../../Classes/</directory>
</include>
</source>
</phpunit>
5 changes: 5 additions & 0 deletions Build/phpunit/UnitTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@
<env name="TYPO3_CONTEXT" value="Testing"/>
<env name="HTTP_HOST" value="localhost"/>
</php>
<source>
<include>
<directory>../../Classes/</directory>
</include>
</source>
</phpunit>

0 comments on commit bb628c6

Please sign in to comment.