-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
100 lines (90 loc) · 2.64 KB
/
action.yml
File metadata and controls
100 lines (90 loc) · 2.64 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
90
91
92
93
94
95
96
97
98
99
100
name: 'PHPUnit/Pest Tests'
description: 'Run PHPUnit or Pest unit tests'
author: 'Zeroseven'
branding:
icon: 'check-square'
color: 'green'
inputs:
php-version:
description: 'PHP version to use'
required: false
default: '8.3'
config:
description: 'Path to phpunit.xml configuration file'
required: true
testsuite:
description: 'Test suite to run'
required: false
default: ''
group:
description: 'Test groups to run (comma-separated)'
required: false
default: ''
coverage:
description: 'Enable code coverage'
required: false
default: 'false'
coverage-format:
description: 'Coverage format (clover, html, text, xml)'
required: false
default: 'clover'
extensions:
description: 'PHP extensions to install'
required: false
default: 'mbstring, xml, json, pdo'
runs:
using: 'composite'
steps:
- name: Check config file exists
shell: bash
run: |
if [ ! -f "${{ inputs.config }}" ]; then
echo "::error::PHPUnit config file not found: ${{ inputs.config }}"
echo "::error::Please create a phpunit.xml file in your project root"
exit 1
fi
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
extensions: ${{ inputs.extensions }}
coverage: ${{ inputs.coverage == 'true' && 'xdebug' || 'none' }}
- name: Detect test runner
id: detect
shell: bash
run: |
if [ -x "vendor/bin/pest" ]; then
echo "runner=pest" >> $GITHUB_OUTPUT
else
echo "runner=phpunit" >> $GITHUB_OUTPUT
fi
- name: Run tests
shell: bash
env:
XDEBUG_MODE: ${{ inputs.coverage == 'true' && 'coverage' || 'off' }}
run: |
TEST_CMD="vendor/bin/${{ steps.detect.outputs.runner }} \
--configuration=${{ inputs.config }}"
if [ -n "${{ inputs.testsuite }}" ]; then
TEST_CMD="$TEST_CMD --testsuite=${{ inputs.testsuite }}"
fi
if [ -n "${{ inputs.group }}" ]; then
TEST_CMD="$TEST_CMD --group=${{ inputs.group }}"
fi
if [ "${{ inputs.coverage }}" = "true" ]; then
case "${{ inputs.coverage-format }}" in
clover)
TEST_CMD="$TEST_CMD --coverage-clover=coverage.xml"
;;
html)
TEST_CMD="$TEST_CMD --coverage-html=coverage"
;;
text)
TEST_CMD="$TEST_CMD --coverage-text"
;;
xml)
TEST_CMD="$TEST_CMD --coverage-xml=coverage-xml"
;;
esac
fi
$TEST_CMD