Skip to content

Commit 240d91c

Browse files
committed
Collect Behat code coverage
1 parent 2601f39 commit 240d91c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

.github/workflows/testing.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
strategy:
1818
matrix:
1919
php: ['8.2']
20+
wp: ['latest']
21+
coverage: [true]
2022
runs-on: ubuntu-latest
2123
services:
2224
mysql:
@@ -43,13 +45,51 @@ jobs:
4345
- name: Install composer packages
4446
run: composer install
4547

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+
4657
- name: Run Behat
47-
run: composer behat
4858
env:
59+
WP_VERSION: '${{ matrix.wp }}'
4960
WP_CLI_TEST_DBUSER: wp_cli_test
5061
WP_CLI_TEST_DBPASS: password1
5162
WP_CLI_TEST_DBNAME: wp_cli_test
5263
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 }}
5393

5494
unit: #-----------------------------------------------------------------------
5595
name: Unit test / PHP ${{ matrix.php }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
wp-cli.local.yml
3+
build/
34
node_modules/
45
vendor/
56
src/vendor/

0 commit comments

Comments
 (0)