From ff53ebf56cd0f86d885042ed821a23439cd223a1 Mon Sep 17 00:00:00 2001 From: Sysix Date: Sat, 10 Feb 2024 21:45:27 +0100 Subject: [PATCH 1/2] add coverage setup + github worklow --- .github/workflows/coverage-report.yml | 54 +++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 8 +++- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage-report.yml diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml new file mode 100644 index 0000000..54988c8 --- /dev/null +++ b/.github/workflows/coverage-report.yml @@ -0,0 +1,54 @@ +name: Coverage Report + +on: + push: + branches: [ development ] + pull_request: + branches: [ development ] + +jobs: + coverage: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install dependencies + run: | + composer install --prefer-dist + + - name: Execute tests with coverage + run: vendor/bin/phpunit --configuration 'phpunit.xml' --coverage-clover=coverage.xml + + - if: ${{ github.event_name == 'pull_request' }} + name: Download artifact + uses: dawidd6/action-download-artifact@v3 + continue-on-error: true + with: + workflow: .github/workflows/coverage-report.yml + branch: development + name: coverage-report + path: tests/base + + - if: ${{ github.event_name != 'pull_request' }} + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: coverage.xml + + - if: ${{ github.event_name == 'pull_request' }} + name: Coverage Report as Comment (Clover) + uses: lucassabreu/comment-coverage-clover@main + with: + file: coverage.xml + base-file: test/base/coverage.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 745f268..df6f857 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /tests/cache/ +/coverage* # Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode,php-cs-fixer # Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux,composer,phpunit,phpstorm+all,visualstudiocode,php-cs-fixer diff --git a/Dockerfile b/Dockerfile index 95e746d..1122e9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,13 @@ FROM php:8.2-fpm +ENV XDEBUG_MODE='coverage' \ + XDEBUG_CONFIG='client_host=host.docker.internal output_dir=/var/www/tmp' # install non php modules RUN apt-get update \ && apt-get install --no-install-recommends -y \ libssl-dev \ + libcurl4-openssl-dev \ libzip-dev \ libxml2-dev \ libonig-dev \ @@ -16,13 +19,16 @@ RUN apt-get update \ git \ && rm -rf /var/lib/apt/lists/* -# Configure imap +# Install PHP Extension for PHPUnit und Composer RUN docker-php-ext-install \ zip \ mbstring \ xml \ curl +RUN pecl install xdebug \ + && docker-php-ext-enable xdebug; + COPY --from=composer /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html From 78ec136db0e08346fe75762182fdbfc577401571 Mon Sep 17 00:00:00 2001 From: Sysix Date: Sat, 10 Feb 2024 21:49:05 +0100 Subject: [PATCH 2/2] fix coverage report workflow --- .github/workflows/coverage-report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index 54988c8..72df124 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -20,8 +20,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} - coverage: none + php-version: 8.3 + coverage: xdebug - name: Install dependencies run: |