Skip to content

Commit a4970b8

Browse files
authored
Merge pull request #102 from wp-cli/switch-to-behat-3
2 parents 581872f + f77ec17 commit a4970b8

19 files changed

+1088
-976
lines changed

.github/workflows/code-quality.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ jobs:
66

77
lint: #-----------------------------------------------------------------------
88
name: Lint PHP files
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
913
runs-on: ubuntu-latest
1014
steps:
1115
- name: Check out source code
@@ -21,7 +25,8 @@ jobs:
2125
if: steps.check_composer_file.outputs.files_exists == 'true'
2226
uses: shivammathur/setup-php@v2
2327
with:
24-
php-version: '7.4'
28+
php-version: '${{ matrix.php }}'
29+
coverage: none
2530
tools: cs2pr
2631

2732
- name: Get Composer cache directory
@@ -72,6 +77,7 @@ jobs:
7277
uses: shivammathur/setup-php@v2
7378
with:
7479
php-version: '7.4'
80+
coverage: none
7581
tools: cs2pr
7682

7783
- name: Get Composer cache directory

.github/workflows/testing.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Testing
2+
3+
on: pull_request
4+
5+
jobs:
6+
7+
unit: #-----------------------------------------------------------------------
8+
name: Unit test / PHP ${{ matrix.php }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Check out source code
17+
uses: actions/checkout@v2
18+
19+
- name: Check existence of composer.json file
20+
id: check_files
21+
uses: andstor/file-existence-action@v1
22+
with:
23+
files: "composer.json, phpunit.xml.dist"
24+
25+
- name: Set up PHP environment
26+
if: steps.check_files.outputs.files_exists == 'true'
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: '${{ matrix.php }}'
30+
coverage: none
31+
tools: composer,cs2pr
32+
33+
- name: Get Composer cache Directory
34+
if: steps.check_files.outputs.files_exists == 'true'
35+
id: composer-cache
36+
run: |
37+
echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
39+
- name: Use Composer cache
40+
if: steps.check_files.outputs.files_exists == 'true'
41+
uses: actions/cache@master
42+
with:
43+
path: ${{ steps['composer-cache'].outputs.dir }}
44+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-composer-
47+
48+
- name: Install dependencies
49+
if: steps.check_files.outputs.files_exists == 'true'
50+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
51+
52+
- name: Setup problem matcher to provide annotations for PHPUnit
53+
if: steps.check_files.outputs.files_exists == 'true'
54+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
55+
56+
- name: Run PHPUnit
57+
if: steps.check_files.outputs.files_exists == 'true'
58+
run: composer phpunit
59+
60+
functional: #----------------------------------------------------------------------
61+
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }}
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
66+
wp: ['latest']
67+
test: ["composer behat || composer behat-rerun"]
68+
include:
69+
- php: '5.6'
70+
wp: 'trunk'
71+
test: "composer behat || composer behat-rerun"
72+
- php: '7.4'
73+
wp: 'trunk'
74+
test: "composer behat || composer behat-rerun"
75+
- php: '8.0'
76+
wp: 'trunk'
77+
test: "composer behat || composer behat-rerun"
78+
- php: '5.6'
79+
wp: '3.7'
80+
test: "composer behat || composer behat-rerun"
81+
runs-on: ubuntu-latest
82+
83+
services:
84+
mysql:
85+
image: mysql:5.7
86+
env:
87+
MYSQL_DATABASE: wp_cli_test
88+
MYSQL_USER: root
89+
MYSQL_ROOT_PASSWORD: root
90+
ports:
91+
- 3306
92+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
93+
94+
steps:
95+
- name: Check out source code
96+
uses: actions/checkout@v2
97+
98+
- name: Check existence of composer.json & behat.yml files
99+
id: check_files
100+
uses: andstor/file-existence-action@v1
101+
with:
102+
files: "composer.json, behat.yml"
103+
104+
- name: Set up PHP envirnoment
105+
if: steps.check_files.outputs.files_exists == 'true'
106+
uses: shivammathur/setup-php@v2
107+
with:
108+
php-version: '${{ matrix.php }}'
109+
extensions: mysql, zip
110+
coverage: none
111+
tools: composer
112+
113+
- name: Get Composer cache Directory
114+
if: steps.check_files.outputs.files_exists == 'true'
115+
id: composer-cache
116+
run: |
117+
echo "::set-output name=dir::$(composer config cache-files-dir)"
118+
119+
- name: Use Composer cache
120+
if: steps.check_files.outputs.files_exists == 'true'
121+
uses: actions/cache@master
122+
with:
123+
path: ${{ steps['composer-cache'].outputs.dir }}
124+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
125+
restore-keys: |
126+
${{ runner.os }}-composer-
127+
128+
- name: Install dependencies
129+
if: steps.check_files.outputs.files_exists == 'true'
130+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
131+
132+
- name: Start MySQL server
133+
if: steps.check_files.outputs.files_exists == 'true'
134+
run: sudo systemctl start mysql
135+
136+
- name: Prepare test database
137+
if: steps.check_files.outputs.files_exists == 'true'
138+
run: |
139+
export MYSQL_HOST=127.0.0.1
140+
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
141+
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
142+
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
143+
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
144+
mysql -e "CREATE DATABASE IF NOT EXISTS \`wp_cli_test\`;" -uroot -proot
145+
mysql -e "GRANT ALL PRIVILEGES ON \`wp_cli_test\`.* TO 'wp_cli_test'@'%' IDENTIFIED BY 'password1';" -uroot -proot
146+
mysql -e "GRANT ALL PRIVILEGES ON \`wp_cli_test_scaffold\`.* TO 'wp_cli_test'@'%' IDENTIFIED BY 'password1';" -uroot -proot
147+
148+
- name: Run Behat
149+
if: steps.check_files.outputs.files_exists == 'true'
150+
env:
151+
WP_VERSION: '${{ matrix.wp }}'
152+
run: ${{ matrix.test }}

.travis.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

behat.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
default:
2-
paths:
3-
features: features
4-
bootstrap: features/bootstrap
2+
suites:
3+
default:
4+
contexts:
5+
- WP_CLI\Tests\Context\FeatureContext
6+
paths:
7+
- features

bin/rerun-behat-tests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ BEHAT_ROOT="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
2727
export BEHAT_ROOT
2828

2929
# Set Behat environment variables
30-
BEHAT_PARAMS="paths[bootstrap]=$(php -r "echo urlencode('$BEHAT_ROOT/features/bootstrap');")"
30+
BEHAT_PARAMS="{\"suites\":{\"default\":{\"contexts\":[\"WP_CLI\\\\Tests\\\\Context\\\\FeatureContext\"],\"paths\":[\"features\"]}}}"
3131
export BEHAT_PARAMS
3232

3333
# Generate the tags to apply environment-specific filters
3434
BEHAT_TAGS=$(php "$BEHAT_ROOT"/utils/behat-tags.php)
3535

3636
# Run the functional tests
37-
vendor/bin/behat --format progress "$BEHAT_TAGS" --strict --ansi --rerun=".behat-progress.log" "$@"
37+
vendor/bin/behat --format progress "$BEHAT_TAGS" --strict --rerun "$@"

bin/run-behat-tests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ BEHAT_ROOT="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
2929
export BEHAT_ROOT
3030

3131
# Set Behat environment variables
32-
BEHAT_PARAMS="paths[bootstrap]=$(php -r "echo urlencode('$BEHAT_ROOT/features/bootstrap');")"
32+
BEHAT_PARAMS="{\"suites\":{\"default\":{\"contexts\":[\"WP_CLI\\\\Tests\\\\Context\\\\FeatureContext\"],\"paths\":[\"features\"]}}}"
3333
export BEHAT_PARAMS
3434

3535
# Generate the tags to apply environment-specific filters
3636
BEHAT_TAGS=$(php "$BEHAT_ROOT"/utils/behat-tags.php)
3737

3838
# Run the functional tests
39-
vendor/bin/behat --format progress "$BEHAT_TAGS" --strict --ansi --rerun=".behat-progress.log" "$@"
39+
vendor/bin/behat --format progress "$BEHAT_TAGS" --strict --rerun "$@"

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@
1010
"type" : "phpcodesniffer-standard",
1111
"require": {
1212
"php": ">=5.6",
13-
"behat/behat": "^2.5.5",
14-
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || ^0.5 || ^0.6.2 || ^0.7",
13+
"behat/behat": "^3.7",
14+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || ^0.5 || ^0.6.2 || ^0.7.1",
1515
"php-parallel-lint/php-console-highlighter": "^0.5",
16-
"php-parallel-lint/php-parallel-lint": "^1",
17-
"phpcompatibility/php-compatibility": "^9",
18-
"phpunit/phpunit": "^5 | ^6 |^7 | ^8 | ^9",
16+
"php-parallel-lint/php-parallel-lint": "^1.2",
17+
"phpcompatibility/php-compatibility": "^9.3",
1918
"wp-cli/config-command": "^1 || ^2",
2019
"wp-cli/core-command": "^1 || ^2",
2120
"wp-cli/eval-command": "^1 || ^2",
2221
"wp-cli/wp-cli": "^2",
23-
"wp-coding-standards/wpcs": "^2.1",
24-
"yoast/phpunit-polyfills": "^0.2.0"
22+
"wp-coding-standards/wpcs": "^2.3",
23+
"yoast/phpunit-polyfills": "^0.2"
2524
},
2625
"require-dev": {
2726
"roave/security-advisories": "dev-master"
@@ -45,6 +44,11 @@
4544
"show_powered_by": false
4645
}
4746
},
47+
"autoload": {
48+
"psr-4": {
49+
"WP_CLI\\Tests\\": "src"
50+
}
51+
},
4852
"minimum-stability": "dev",
4953
"prefer-stable": true,
5054
"bin": [

0 commit comments

Comments
 (0)