-
Notifications
You must be signed in to change notification settings - Fork 53
163 lines (147 loc) · 5.12 KB
/
behat-test.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Behat Testing
on:
push:
branches:
- trunk
- 'release/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/behat-test.yml'
- '**.php'
- '**.feature'
- 'behat.yml'
- 'composer.json'
- 'composer.lock'
pull_request:
branches:
- trunk
- 'release/**'
- 'feature/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/behat-test.yml'
- '**.php'
- '**.feature'
- 'behat.yml'
- 'composer.json'
- 'composer.lock'
types:
- opened
- reopened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
behat-test:
name: PHP ${{ matrix.php }} - WP ${{ matrix.wordpress }}${{ matrix.experimental && ' (experimental)' || '' }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental == true }}
timeout-minutes: 20
services:
mysql:
image: mysql:8.0
ports:
- 3306/tcp
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
-e MYSQL_ROOT_PASSWORD=root
-e MYSQL_DATABASE=wp_cli_test
--entrypoint sh mysql:8.0
-c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
strategy:
fail-fast: true
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
wordpress: [ 'latest' ]
include:
- php: '8.2'
wordpress: 'latest'
coverage: true
- php: '7.4'
wordpress: '6.3'
- php: '8.3'
wordpress: 'trunk'
experimental: true
- php: '8.4'
wordpress: 'trunk'
experimental: true
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wordpress == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
extensions: mysql
tools: composer
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
ini-values: pcov.directory=.,pcov.exclude=~(vendor|tests)~
- name: Install PHP dependencies
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
composer-options: '--prefer-dist'
- name: Make Composer packages available globally
run: |
echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mkdir -p bin
mv wp-cli.phar bin/wp
echo "WP_CLI_BIN_DIR=${PWD}/bin" >> $GITHUB_ENV
- name: Update PHPUnit to get latest php-code-coverage library
if: ${{ matrix.coverage == true }}
# phpunit/phpunit has to be updated as the one in use provides an older version of phpunit/php-code-coverage,
# but we need the v9.x branch.
# It cannot be removed, as it is a requirement of wp-cli/wp-cli-tests as well.
run: |
composer require --dev --ignore-platform-reqs --update-with-all-dependencies phpunit/phpunit
- name: Start MySQL server
run: sudo systemctl start mysql
- name: Configure DB environment
run: |
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
- name: Prepare test database
run: composer prepare-behat-tests
- name: Check Behat environment
run: composer behat
env:
WP_CLI_TEST_DEBUG_BEHAT_ENV: 1
- name: Run tests
env:
BEHAT_CODE_COVERAGE: ${{ matrix.coverage }}
run: composer behat || composer behat-rerun
- name: Retrieve list of coverage files
id: coverage_files
if: ${{ matrix.coverage == true }}
run: |
FILES=$(ls -d -1 "$GITHUB_WORKSPACE/build/logs/clover-behat/"*.* | paste --serial --delimiters=",")
test -n "$FILES"
echo "Coverage files: $FILES"
echo "files=$FILES" >> $GITHUB_OUTPUT
- name: Upload code coverage report
if: ${{ matrix.coverage }}
uses: codecov/[email protected]
with:
files: ${{ steps.coverage_files.outputs.files }}
flags: feature
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}