17
17
strategy :
18
18
matrix :
19
19
php : ['8.2']
20
+ wp : ['latest']
21
+ coverage : [true]
20
22
runs-on : ubuntu-latest
21
23
services :
22
24
mysql :
@@ -43,19 +45,61 @@ jobs:
43
45
- name : Install composer packages
44
46
run : composer install
45
47
48
+ - name : Check Behat environment
49
+ env :
50
+ WP_VERSION : ' ${{ matrix.wp }}'
51
+ WP_CLI_TEST_DBUSER : wp_cli_test
52
+ WP_CLI_TEST_DBPASS : password1
53
+ WP_CLI_TEST_DBNAME : wp_cli_test
54
+ WP_CLI_TEST_DBHOST : 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
55
+ run : WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
56
+
46
57
- name : Run Behat
47
- run : composer behat
48
58
env :
59
+ WP_VERSION : ' ${{ matrix.wp }}'
49
60
WP_CLI_TEST_DBUSER : wp_cli_test
50
61
WP_CLI_TEST_DBPASS : password1
51
62
WP_CLI_TEST_DBNAME : wp_cli_test
52
63
WP_CLI_TEST_DBHOST : 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
64
+ WP_CLI_TEST_COVERAGE : ${{ matrix.coverage }}
65
+ run : |
66
+ ARGS=()
67
+
68
+ if [[ $WP_CLI_TEST_COVERAGE == 'true' ]]; then
69
+ ARGS+=("--xdebug")
70
+ fi
71
+
72
+ if [[ $RUNNER_DEBUG == '1' ]]; then
73
+ ARGS+=("--format=pretty")
74
+ fi
75
+
76
+ composer behat -- "${ARGS[@]}" || composer behat-rerun -- "${ARGS[@]}"
77
+
78
+ - name : Retrieve list of coverage files
79
+ id : coverage_files
80
+ if : ${{ matrix.coverage }}
81
+ run : |
82
+ FILES=$(find "$GITHUB_WORKSPACE/build/logs" -path '*.*' | paste -s -d "," -)
83
+ echo "files=$FILES" >> $GITHUB_OUTPUT
84
+
85
+ - name : Upload code coverage report
86
+ if : ${{ matrix.coverage }}
87
+ uses : codecov/codecov-action@v5.4.0
88
+ with :
89
+ # Because somehow providing `directory: build/logs` doesn't work for these files
90
+ files : ${{ steps.coverage_files.outputs.files }}
91
+ flags : feature
92
+ token : ${{ secrets.CODECOV_TOKEN }}
53
93
54
94
unit : # -----------------------------------------------------------------------
55
95
name : Unit test / PHP ${{ matrix.php }}
56
96
strategy :
57
97
matrix :
58
98
php : [ '8.2' ]
99
+ coverage : [ false ]
100
+ include :
101
+ - php : ' 8.3'
102
+ coverage : true
59
103
runs-on : ubuntu-latest
60
104
61
105
steps :
67
111
with :
68
112
php-version : ' ${{ matrix.php }}'
69
113
ini-values : zend.assertions=1, error_reporting=-1, display_errors=On
70
- coverage : none
114
+ coverage : ${{ matrix.coverage && 'xdebug' || ' none' }}
71
115
tools : composer,cs2pr
72
116
73
117
- name : Install Composer dependencies & cache dependencies
@@ -93,4 +137,17 @@ jobs:
93
137
run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
94
138
95
139
- name : Run PHPUnit
96
- run : composer phpunit
140
+ run : |
141
+ if [[ ${{ matrix.coverage == true }} == true ]]; then
142
+ composer phpunit -- --coverage-clover build/logs/unit-coverage.xml
143
+ else
144
+ composer phpunit
145
+ fi
146
+
147
+ - name : Upload code coverage report
148
+ if : ${{ matrix.coverage }}
149
+ uses : codecov/codecov-action@v5.4.0
150
+ with :
151
+ directory : build/logs
152
+ flags : unit
153
+ token : ${{ secrets.CODECOV_TOKEN }}
0 commit comments