From a43239003ac3ce94f5c260dcbb26d5c72bf7e24e Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 21 Aug 2024 10:00:48 +0200 Subject: [PATCH] Re-enable code coverage analysis as PHPUnit 11 is now supported by `infection/infection` --- .github/workflows/ci.yml | 68 ++++++++++++++++++++-------------------- Dockerfile | 5 +++ Makefile | 3 +- composer.json | 1 + 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad5205cf..e837a95e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,40 +83,40 @@ jobs: timeout-minutes: 3 run: "vendor/bin/phpunit --no-coverage --no-logging" -# code-coverage: -# name: "Code Coverage" -# runs-on: "ubuntu-latest" -# strategy: -# matrix: -# php-version: -# - "8.2" -# -# steps: -# - uses: "actions/checkout@v4" -# - uses: "shivammathur/setup-php@v2" -# with: -# coverage: "pcov" -# php-version: "${{ matrix.php-version }}" -# ini-values: "${{ env.INI_VALUES }}" -# - uses: "ramsey/composer-install@v2" -# -# - name: "Gather base branch for diff" -# if: ${{ github.event_name == 'pull_request' }} -# run: git fetch origin --no-tags --prune --depth=1 ${{ github.base_ref }} ${{ github.event.pull_request.base.sha }} -# -# - name: "Infection on DIFF" -# if: ${{ github.event_name == 'pull_request' }} -# timeout-minutes: 30 -# run: make code-coverage INFECTION_ARGS="--logger-github" -# env: -# BASE_BRANCH: origin/${{ github.base_ref }} -# -# - name: "Infection on complete code base" -# if: ${{ github.event_name != 'pull_request' && !startsWith(github.ref_name, 'renovate/') }} -# timeout-minutes: 30 -# run: "vendor/bin/infection run --ansi --threads=$(nproc) --skip-initial-tests --coverage=coverage" -# env: -# INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} + code-coverage: + name: "Code Coverage" + runs-on: "ubuntu-latest" + strategy: + matrix: + php-version: + - "8.2" + + steps: + - uses: "actions/checkout@v4" + - uses: "shivammathur/setup-php@v2" + with: + coverage: "pcov" + php-version: "${{ matrix.php-version }}" + ini-values: "${{ env.INI_VALUES }}" + - uses: "ramsey/composer-install@v2" + + - name: "Gather base branch for diff" + if: ${{ github.event_name == 'pull_request' }} + run: git fetch origin --no-tags --prune --depth=1 ${{ github.base_ref }} ${{ github.event.pull_request.base.sha }} + + - name: "Infection on DIFF" + if: ${{ github.event_name == 'pull_request' }} + timeout-minutes: 30 + run: make code-coverage INFECTION_ARGS="--logger-github" + env: + BASE_BRANCH: origin/${{ github.base_ref }} + + - name: "Infection on complete code base" + if: ${{ github.event_name != 'pull_request' && !startsWith(github.ref_name, 'renovate/') }} + timeout-minutes: 30 + run: "vendor/bin/infection run --ansi --threads=$(nproc) --skip-initial-tests --coverage=coverage" + env: + INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} coding-standards: name: "Coding Standards" diff --git a/Dockerfile b/Dockerfile index e15a2816..638a042e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ FROM php:8.3 +# git needed for Infection +RUN apt-get update \ + && apt-get -y install --no-install-recommends \ + git + ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN install-php-extensions @composer pcov diff --git a/Makefile b/Makefile index 63947501..7b4c7e62 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,7 @@ ifeq ($(strip $(LOCAL_BASE_BRANCH)),) endif BASE_BRANCH ?= $(LOCAL_BASE_BRANCH) -#all: csfix static-analysis code-coverage -all: csfix static-analysis test +all: csfix static-analysis code-coverage @echo "Done." .env: /etc/passwd /etc/group Makefile diff --git a/composer.json b/composer.json index 0ca67c41..97a884ad 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,7 @@ "ext-pcov": "*", "ext-posix": "*", "doctrine/coding-standard": "^12.0.0", + "infection/infection": "^0.29.6", "phpstan/phpstan": "^1.11.11", "phpstan/phpstan-deprecation-rules": "^1.2.0", "phpstan/phpstan-phpunit": "^1.4.0",