mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-10 00:16:13 +01:00

[FEATURE] Calculate code coverage (#266)

This commit is contained in:
Łukasz Uznański 2021-10-06 16:23:35 +02:00 committed by GitHub
parent 4ff6bbfc46
commit 9bf78a580b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71894 additions and 2 deletions

2
.ddev/php/custom-php.ini Normal file
View file

@ -0,0 +1,2 @@
[PHP]
xdebug.mode=coverage

67
.github/workflows/codecoverage.yml vendored Normal file
View file

@ -0,0 +1,67 @@
---
# This GitHub Actions workflow is calculating code coverage of extension and creates a badge for it.
name: Code coverage
on:
push:
branches:
- main
jobs:
code-coverage:
name: "Calculate code coverage"
runs-on: ubuntu-18.04
steps:
- name: "Checkout"
uses: actions/checkout@v2
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: xdebug
extensions: xdebug, mysqli
tools: composer:v2
- name: "Show Composer version"
run: composer --version
- name: "Cache dependencies installed with composer"
uses: actions/cache@v1
with:
key: "php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}"
path: ~/.cache/composer
restore-keys: "php${{ matrix.php-version }}-composer-\n"
- env:
TYPO3: "${{ matrix.typo3-version }}"
name: "Install TYPO3 Core"
run: |
composer require --no-progress typo3/minimal:"$TYPO3"
composer show
- name: "Start MySQL"
run: "sudo /etc/init.d/mysql start"
- name: "Run functional tests with coverage"
run: |
export typo3DatabaseName="typo3";
export typo3DatabaseHost="127.0.0.1";
export typo3DatabaseUsername="root";
export typo3DatabasePassword="root";
composer ci:coverage:functional
- name: "Run unit tests with coverage"
run: composer ci:coverage:unit
- name: "Merge coverage results"
run: composer ci:coverage:merge
- name: "Generate coverage badge"
uses: timkrase/phpunit-coverage-badge@v1.2.0
with:
report: './coverage/clover.xml'
coverage_badge_path: './coverage/badge.svg'
- name: "Commit PHPUnit coverage results"
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: code-coverage-badge
FOLDER: coverage
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
php-version:
- 7.4
typo3-version:
- ^10.4

1
.gitignore vendored
View file

@ -7,5 +7,6 @@
/Resources/Private/yarn-error.log
/Resources/Private/yarn.lock
/composer.lock
/clover.xml
/nbproject
/var

View file

@ -3,6 +3,7 @@
[![GitHub CI status](https://github.com/TYPO3-Documentation/tea/workflows/CI/badge.svg?branch=main)](https://github.com/TYPO3-Documentation/tea/actions)
[![GitLab CI status](https://gitlab.typo3.org/qa/example-extension/badges/main/pipeline.svg)](https://gitlab.typo3.org/qa/example-extension/-/pipelines)
[![Latest stable version](https://poser.pugx.org/ttn/tea/v/stable.svg)](https://packagist.org/packages/ttn/tea)
[![Code Coverage Badge](https://github.com/TYPO3-Documentation/tea/blob/code-coverage-badge/badge.svg)](https://github.com/TYPO3-Documentation/tea/blob/code-coverage-badge/clover.xml)
[![Total downloads](https://poser.pugx.org/ttn/tea/downloads.svg)](https://packagist.org/packages/ttn/tea)
[![Latest unstable version](https://poser.pugx.org/ttn/tea/v/unstable.svg)](https://packagist.org/packages/ttn/tea)
[![License](https://poser.pugx.org/ttn/tea/license.svg)](https://packagist.org/packages/ttn/tea)

View file

@ -88,6 +88,13 @@
"@ci:static"
],
"ci:composer:normalize": "@composer normalize --dry-run",
"ci:coverage": [
"@ci:coverage:unit",
"@ci:coverage:functional"
],
"ci:coverage:functional": ".Build/vendor/bin/phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml --whitelist Classes --coverage-php=coverage/functional.cov Tests/Functional",
"ci:coverage:merge": "@php tools/phpcov merge --clover=./coverage/clover.xml coverage/",
"ci:coverage:unit": ".Build/vendor/bin/phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml --whitelist Classes --coverage-php=coverage/unit.cov Tests/Unit",
"ci:dynamic": [
"@ci:tests"
],
@ -163,6 +170,9 @@
"scripts-descriptions": {
"ci": "Runs all dynamic and static code checks.",
"ci:composer:normalize": "Checks the composer.json.",
"ci:coverage:functional": "Generates the code coverage report for functional tests.",
"ci:coverage:merge": "Merges the code coverage reports for unit and functional tests.",
"ci:coverage:unit": "Generates the code coverage report for unit tests.",
"ci:dynamic": "Runs all PHPUnit tests (unit and functional).",
"ci:json:lint": "Lints the JSON files.",
"ci:php": "Runs all static checks for the PHP files.",

View file

@ -2,4 +2,5 @@
<phive xmlns="https://phar.io/phive">
<phar name="phar-io/phive" version="^0.14.5" installed="0.14.5" location="./tools/phive" copy="true"/>
<phar name="phpcpd" version="^6.0.3" installed="6.0.3" location="./tools/phpcpd" copy="true"/>
<phar name="phpcov" version="^5.0.0" installed="5.0.0" location="./tools/phpcov" copy="true"/>
</phive>

71810
tools/phpcov Normal file

File diff suppressed because one or more lines are too long