Skip to content

Commit

Permalink
Merge pull request #146 from Sysix/coverage
Browse files Browse the repository at this point in the history
add coverage setup + github worklow
  • Loading branch information
Sysix authored Feb 10, 2024
2 parents 67724bb + 78ec136 commit b515170
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
@@ -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: 8.3
coverage: xdebug

- 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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

0 comments on commit b515170

Please sign in to comment.