Repository navigation
89 lines (82 loc) · 2.76 KB
/
Copy pathphpunit-coverage.yaml
File metadata and controls
89 lines (82 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Run PHPUnit tests coverage
on:
workflow_call:
inputs:
php-version:
description: PHP versions used for coverage
required: false
default: '8.1'
type: string
runs-on:
description: The "runs-on" platform config
required: false
default: 'ubuntu-latest'
type: string
php-extensions:
description: PHP extensions to install
required: false
default: ''
type: string
publish-summary:
description: Whether to publish test coverage summaries
required: false
default: false
type: boolean
coverage-thresholds:
description: Minimum and target coverage percentages (e.g., '60 80')
required: false
default: '60 80'
type: string
working-directory:
description: Working directory for the workflow
default: .
required: false
type: string
phpunit-bin:
description: Path to PHPUnit binary
required: false
default: 'vendor/bin/simple-phpunit'
type: string
jobs:
tests_coverage:
name: PHP ${{ inputs.php-version }}
runs-on: ${{ inputs.runs-on }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: ${{ inputs.php-version }}
extensions: ${{ inputs.php-extensions }}
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
composer-options: --no-progress --prefer-dist
working-directory: ${{ inputs.working-directory }}
- name: Tests
working-directory: ${{ inputs.working-directory }}
env:
EXTRA_ARGS: ${{ true == inputs.publish-summary && ' --coverage-cobertura coverage.cobertura.xml' || '' }}
run: ${{ inputs.phpunit-bin }} $EXTRA_ARGS
- name: Code Coverage Report
if: ${{ true == inputs.publish-summary }}
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ${{ inputs.working-directory }}/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: ${{ inputs.coverage-thresholds }}
continue-on-error: true # Ensure this step regardless of previous failures
- name: Publish Summary
if: ${{ true == inputs.publish-summary }}
working-directory: ${{ inputs.working-directory }}
run: |
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
continue-on-error: true # Ensure this step regardless of previous failures