~ancarda/coverage-enforcer

380feec425b57e732c52e7e10f1b779751a00983 — Mark Dain 1 year, 9 months ago d383322 1.0.1
Build on PHP 8.1
5 files changed, 25 insertions(+), 27 deletions(-)

R .builds/{php8_0.yml => php8_1.yml}
M composer.lock
M infection.json
M src/Auditor.php
M tests/AuditorTest.php
R .builds/php8_0.yml => .builds/php8_1.yml +6 -11
@@ 1,19 1,16 @@
---
image: debian/sid
image: debian/bookworm

sources:
  - https://git.sr.ht/~ancarda/coverage-enforcer

packages:
  - php8.0-cli
  - php8.1-cli
  - composer

  # PHP 8.0 on debian/sid does not come with mbstring by default?
  # See: https://builds.sr.ht/~ancarda/job/453331
  - php8.0-mbstring
  - php8.1-mbstring

  # some dev tools use XML config files
  - php8.0-xml
  - php8.1-xml

  # for code coverage (phpunit and infection)
  - php-xdebug


@@ 30,7 27,5 @@ tasks:
  - analyze:     cd $DIR && composer run-script analyze
  - check-style: cd $DIR && composer run-script check-style
  - test:        cd $DIR && composer run-script test

  # coverage is not yet working on PHP 8.0
  # See: https://builds.sr.ht/~ancarda/job/453338#task-check-tests
  # - check-tests: cd $DIR && composer run-script check-tests
  - check-cov:   cd $DIR && composer run-script check-coverage
  - check-tests: cd $DIR && composer run-script check-tests

M composer.lock => composer.lock +10 -6
@@ 1862,16 1862,16 @@
        },
        {
            "name": "phpstan/phpstan",
            "version": "0.12.82",
            "version": "0.12.99",
            "source": {
                "type": "git",
                "url": "https://github.com/phpstan/phpstan.git",
                "reference": "3920f0fb0aff39263d3a4cb0bca120a67a1a6a11"
                "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3920f0fb0aff39263d3a4cb0bca120a67a1a6a11",
                "reference": "3920f0fb0aff39263d3a4cb0bca120a67a1a6a11",
                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7",
                "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7",
                "shasum": ""
            },
            "require": {


@@ 1902,7 1902,7 @@
            "description": "PHPStan - PHP Static Analysis Tool",
            "support": {
                "issues": "https://github.com/phpstan/phpstan/issues",
                "source": "https://github.com/phpstan/phpstan/tree/0.12.82"
                "source": "https://github.com/phpstan/phpstan/tree/0.12.99"
            },
            "funding": [
                {


@@ 1910,6 1910,10 @@
                    "type": "github"
                },
                {
                    "url": "https://github.com/phpstan",
                    "type": "github"
                },
                {
                    "url": "https://www.patreon.com/phpstan",
                    "type": "patreon"
                },


@@ 1918,7 1922,7 @@
                    "type": "tidelift"
                }
            ],
            "time": "2021-03-19T06:08:17+00:00"
            "time": "2021-09-12T20:09:55+00:00"
        },
        {
            "name": "phpstan/phpstan-phpunit",

M infection.json => infection.json +6 -1
@@ 8,7 8,12 @@
        "text": "var/infection.log"
    },
    "mutators": {
        "@default": true
        "@default": true,
        "CastInt": {
            "ignore": [
                "Ancarda\\CodeCoverage\\Auditor::assertStatementsCovered"
            ]
        }
    },
    "minCoveredMsi": 100
}

M src/Auditor.php => src/Auditor.php +2 -2
@@ 61,8 61,8 @@ final class Auditor
    {
        $clover = self::loadXML($filePath);

        $stmtCovered = $clover->project->metrics['coveredstatements'];
        $stmtCount   = $clover->project->metrics['statements'];
        $stmtCovered = (int) $clover->project->metrics['coveredstatements'];
        $stmtCount   = (int) $clover->project->metrics['statements'];
        $coverage = ($stmtCovered / $stmtCount) * 100;

        if ($target > $coverage) {

M tests/AuditorTest.php => tests/AuditorTest.php +1 -7
@@ 43,13 43,7 @@ final class AudiorTest extends TestCase
        $filePath = __DIR__ . '/files/parse-failure.xml';

        $this->expectException(RuntimeException::class);

        // LibXML error messages are different on PHP 7.3.x.
        if (PHP_VERSION_ID < 70400) {
            $this->expectExceptionMessage('Parse Error: Premature end of data');
        } else {
            $this->expectExceptionMessage('Parse Error: EndTag: \'</\' not found');
        }
        $this->expectExceptionMessage('Parse Error');

        Auditor::assertStatementsCovered($filePath, 100);
    }