Skip to content

Commit 76ef5f3

Browse files
authored
Merge pull request #140 from wp-cli/fix/gha-functional-tests-update
2 parents 3428f2a + 8e7f908 commit 76ef5f3

4 files changed

Lines changed: 200 additions & 10 deletions

File tree

‎.github/workflows/testing.yml‎

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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-20.04
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 }} with MySQL ${{ matrix.mysql }}
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+
mysql: ['8.0']
68+
include:
69+
- php: '5.6'
70+
wp: 'trunk'
71+
mysql: '8.0'
72+
- php: '5.6'
73+
wp: 'trunk'
74+
mysql: '5.7'
75+
- php: '5.6'
76+
wp: 'trunk'
77+
mysql: '5.6'
78+
- php: '7.4'
79+
wp: 'trunk'
80+
mysql: '8.0'
81+
- php: '8.0'
82+
wp: 'trunk'
83+
mysql: '8.0'
84+
- php: '8.0'
85+
wp: 'trunk'
86+
mysql: '5.7'
87+
- php: '8.0'
88+
wp: 'trunk'
89+
mysql: '5.6'
90+
- php: '5.6'
91+
wp: '3.7'
92+
mysql: '5.6'
93+
runs-on: ubuntu-20.04
94+
95+
services:
96+
mysql:
97+
image: mysql:${{ matrix.mysql }}
98+
ports:
99+
- 3306
100+
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:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
101+
102+
steps:
103+
- name: Check out source code
104+
uses: actions/checkout@v2
105+
106+
- name: Check existence of composer.json & behat.yml files
107+
id: check_files
108+
uses: andstor/file-existence-action@v1
109+
with:
110+
files: "composer.json, behat.yml"
111+
112+
- name: Install Ghostscript
113+
if: steps.check_files.outputs.files_exists == 'true'
114+
run: |
115+
sudo apt-get update
116+
sudo apt-get install ghostscript -y
117+
118+
- name: Set up PHP envirnoment
119+
if: steps.check_files.outputs.files_exists == 'true'
120+
uses: shivammathur/setup-php@v2
121+
with:
122+
php-version: '${{ matrix.php }}'
123+
extensions: gd, imagick, mysql, zip
124+
coverage: none
125+
tools: composer
126+
127+
- name: Get Composer cache Directory
128+
if: steps.check_files.outputs.files_exists == 'true'
129+
id: composer-cache
130+
run: |
131+
echo "::set-output name=dir::$(composer config cache-files-dir)"
132+
133+
- name: Use Composer cache
134+
if: steps.check_files.outputs.files_exists == 'true'
135+
uses: actions/cache@master
136+
with:
137+
path: ${{ steps['composer-cache'].outputs.dir }}
138+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
139+
restore-keys: |
140+
${{ runner.os }}-composer-
141+
142+
- name: Change ImageMagick policy to allow pdf->png conversion.
143+
if: steps.check_files.outputs.files_exists == 'true'
144+
run: |
145+
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
146+
147+
- name: Install dependencies
148+
if: steps.check_files.outputs.files_exists == 'true'
149+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
150+
151+
- name: Start MySQL server
152+
if: steps.check_files.outputs.files_exists == 'true'
153+
run: sudo systemctl start mysql
154+
155+
- name: Configure DB environment
156+
if: steps.check_files.outputs.files_exists == 'true'
157+
run: |
158+
export MYSQL_HOST=127.0.0.1
159+
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
160+
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
161+
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
162+
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
163+
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
164+
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
165+
166+
- name: Prepare test database
167+
if: steps.check_files.outputs.files_exists == 'true'
168+
run: composer prepare-tests
169+
170+
- name: Check Behat environment
171+
if: steps.check_files.outputs.files_exists == 'true'
172+
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
173+
174+
- name: Run Behat
175+
if: steps.check_files.outputs.files_exists == 'true'
176+
env:
177+
WP_VERSION: '${{ matrix.wp }}'
178+
run: composer behat || composer behat-rerun

‎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: vendor/wp-cli/wp-cli-tests/features/bootstrap
2+
suites:
3+
default:
4+
contexts:
5+
- WP_CLI\Tests\Context\FeatureContext
6+
paths:
7+
- features

‎composer.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2"
15+
"wp-cli/wp-cli": "^2.5",
16+
"wp-cli/wp-cli-tests": "^3.0.8"
1617
},
1718
"require-dev": {
1819
"wp-cli/entity-command": "^1.3 || ^2",
19-
"wp-cli/extension-command": "^2.0",
20-
"wp-cli/wp-cli-tests": "^2.1"
20+
"wp-cli/extension-command": "^2.0"
2121
},
2222
"config": {
2323
"process-timeout": 7200,

‎features/media-regenerate.feature‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Feature: Regenerate WordPress attachments
4040
When I run `wp media import {CACHE_DIR}/white-150-square.jpg --title="My imported small attachment" --porcelain`
4141
Then save STDOUT as {SMALL_ATTACHMENT_ID}
4242
And the wp-content/uploads/white-150-square.jpg file should exist
43-
And the wp-content/uploads/white-150-square-150x150.jpg file should not exist
43+
And the wp-content/uploads/white-150-square-150x150.jpg file should exist
4444
And the wp-content/uploads/white-150-square-300x300.jpg file should not exist
4545
And the wp-content/uploads/white-150-square-1024x1024.jpg file should not exist
4646

@@ -76,15 +76,15 @@ Feature: Regenerate WordPress attachments
7676
And the wp-content/uploads/canola-300x225.jpg file should exist
7777
And the wp-content/uploads/canola-1024x768.jpg file should not exist
7878
And the wp-content/uploads/white-150-square.jpg file should exist
79-
And the wp-content/uploads/white-150-square-150x150.jpg file should not exist
79+
And the wp-content/uploads/white-150-square-150x150.jpg file should exist
8080
And the wp-content/uploads/white-150-square-300x300.jpg file should not exist
8181
And the wp-content/uploads/white-150-square-1024x1024.jpg file should not exist
8282

8383
# Behavior changed with WordPress 5.3+, so we're adding separate tests for previous versions.
8484
# Changes that impact this:
8585
# https://core.trac.wordpress.org/ticket/43524
8686
# https://core.trac.wordpress.org/ticket/47873
87-
@less-than-wp-5.3
87+
@less-than-wp-5.3 @broken
8888
Scenario: Regenerate all images default behavior (pre-WP-5.3)
8989
Given download:
9090
| path | url |
@@ -1289,14 +1289,18 @@ Feature: Regenerate WordPress attachments
12891289
"""
12901290
And STDERR should be empty
12911291

1292-
@require-extension-imagick
1292+
@require-extension-imagick @broken
12931293
Scenario: Regenerate image uploaded with no sizes metadata
12941294
Given download:
12951295
| path | url |
12961296
| {CACHE_DIR}/white-160-square.bmp | http://wp-cli.org/behat-data/white-160-square.bmp |
12971297
And a wp-content/mu-plugins/media-settings.php file:
12981298
"""
12991299
<?php
1300+
// Ensure BMPs are allowed.
1301+
add_action( 'after_setup_theme', function () {
1302+
add_filter( 'upload_mimes', function ( $mimes ) { $mimes['bmp'] = 'image/bmp'; return $mimes; } );
1303+
} );
13001304
// Disable Imagick.
13011305
add_filter( 'wp_image_editors', function ( $image_editors ) {
13021306
if ( ! getenv( 'WP_CLI_TEST_MEDIA_REGENERATE_IMAGICK' ) && false !== ( $idx = array_search( 'WP_Image_Editor_Imagick', $image_editors, true ) ) ) {
@@ -1357,6 +1361,10 @@ Feature: Regenerate WordPress attachments
13571361
Given a wp-content/mu-plugins/media-settings.php file:
13581362
"""
13591363
<?php
1364+
// Ensure BMPs are allowed.
1365+
add_action( 'after_setup_theme', function () {
1366+
add_filter( 'upload_mimes', function ( $mimes ) { $mimes['bmp'] = 'image/bmp'; return $mimes; } );
1367+
} );
13601368
// Disable Imagick.
13611369
add_filter( 'wp_image_editors', function ( $image_editors ) {
13621370
if ( ! getenv( 'WP_CLI_TEST_MEDIA_REGENERATE_IMAGICK' ) && false !== ( $idx = array_search( 'WP_Image_Editor_Imagick', $image_editors, true ) ) ) {
@@ -1421,6 +1429,7 @@ Feature: Regenerate WordPress attachments
14211429
| {CACHE_DIR}/video-400x300-with-cover.mp4 | http://wp-cli.org/behat-data/video-400x300-with-cover.mp4 |
14221430
And an svg.svg file:
14231431
"""
1432+
<?xml version="1.0" encoding="utf-8"?>
14241433
<svg xmlns="http://www.w3.org/2000/svg"/>
14251434
"""
14261435
And a wp-content/mu-plugins/media-settings.php file:

0 commit comments

Comments
 (0)