Skip to content

Commit

Permalink
+ infection.json5
Browse files Browse the repository at this point in the history
* set `executionOrder` to `random` and enable `requireCoverageMetadata` & `beStrictAboutCoverageMetadata` @ phpunit.xml
* add attribute `#[CoversClass(BaseQuery::class)]` @ `Tests\Feature\App\Http\PostsQuery`
@ be

+ job `infection`
* upload output files of `--coverage-xml` & `--log-junit` to artifact @ job `phpunit`
@ .github/workflows/be_base.yml
  • Loading branch information
n0099 committed Sep 17, 2024
1 parent 99d1db6 commit f3b65dc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/be_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,36 @@ jobs:
coverage: xdebug
# https://github.com/shivammathur/setup-php/blob/2.31.1/README.md#problem-matchers
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- run: ./vendor/bin/phpunit --coverage-clover clover.xml
- run: >
./vendor/bin/phpunit
--coverage-clover=coverage/clover.xml
--coverage-xml=coverage/coverage-xml
--log-junit=coverage/junit.xml
# https://infection.github.io/guide/command-line-options.html#coverage
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ inputs.runs-on }}-clover.xml
path: be/clover.xml
name: coverage-${{ inputs.runs-on }}
path: be/coverage
compression-level: 9

infection:
runs-on: ${{ inputs.runs-on }}
needs: phpunit
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/be
- uses: shivammathur/setup-php@v2
with:
# https://bugs.php.net/bug.php?id=80608 https://github.com/swoole/swoole-src/issues/3986 https://github.com/php/php-src/pull/6640
# PHP Warning: JIT is incompatible with third party extensions that override zend_execute_ex(). JIT disabled.
ini-values: opcache.jit_buffer_size=0
coverage: xdebug
- id: download-artifact
uses: actions/download-artifact@v4
with:
name: coverage-${{ inputs.runs-on }}
- run: ./vendor/bin/infection --coverage=${{ steps.download-artifact.outputs.download-path }} --skip-initial-tests

phpstan:
runs-on: ${{ inputs.runs-on }}
steps:
Expand Down
10 changes: 10 additions & 0 deletions be/infection.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": ["."],
"excludes": ["vendor", "tests", ".phpstorm.meta.php", "/_ide_helper.*.php/", "bootstrap/cache/*"]
},
"mutators": {
"@default": true
}
}
3 changes: 3 additions & 0 deletions be/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
executionOrder="random"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
>
<testsuites>
<testsuite name="Unit">
Expand Down
2 changes: 2 additions & 0 deletions be/tests/Feature/App/Http/PostsQuery/BaseQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
use App\Http\PostsQuery\BaseQuery;
use Barryvdh\Debugbar\LaravelDebugbar;
use Illuminate\Pagination\Cursor;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

#[CoversClass(BaseQuery::class)]
class BaseQueryTest extends TestCase
{
private BaseQuery $sut;
Expand Down

0 comments on commit f3b65dc

Please sign in to comment.