Skip to content

Commit eb22994

Browse files
authored
Merge pull request #163 from wp-cli/add/gha-workflows
2 parents b89a63c + 7727029 commit eb22994

17 files changed

+253
-130
lines changed

.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: 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

.travis.yml

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

behat.yml

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

command.php

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

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"name": "wp-cli/profile-command",
33
"type": "wp-cli-package",
44
"description": "Quickly identify what's slow with WordPress.",
5-
"homepage": "https://runcommand.io/wp/profile/",
5+
"homepage": "https://github.com/wp-cli/profile-command/",
66
"license": "MIT",
77
"authors": [],
88
"require": {
9-
"php": ">=5.4",
10-
"wp-cli/wp-cli": "^2"
9+
"php": ">=5.6",
10+
"wp-cli/wp-cli": "dev-master"
1111
},
1212
"require-dev": {
13-
"wp-cli/wp-cli-tests": "^2.1"
13+
"wp-cli/wp-cli-tests": "^3"
1414
},
1515
"config": {
1616
"process-timeout": 7200,
@@ -39,8 +39,11 @@
3939
}
4040
},
4141
"autoload": {
42+
"psr-4": {
43+
"WP_CLI\\Profile\\": "src/"
44+
},
4245
"files": [
43-
"command.php"
46+
"profile-command.php"
4447
]
4548
},
4649
"minimum-stability": "dev",

features/profile-eval-file.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Feature: Profile arbitary file execution
55
And a lame-function.php file:
66
"""
77
<?php
8-
function runcommand_do_nothing() {
8+
function wp_cli_do_nothing() {
99
1010
}
11-
runcommand_do_nothing();
11+
wp_cli_do_nothing();
1212
"""
1313

1414
When I run `wp profile eval-file lame-function.php --fields=query_time,query_count,cache_ratio,cache_hits,cache_misses,request_time,request_count`
@@ -21,7 +21,7 @@ Feature: Profile arbitary file execution
2121
And a http-request.php file:
2222
"""
2323
<?php
24-
wp_remote_get( "http://apple.com" );
24+
wp_remote_get( "https://www.apple.com/" );
2525
"""
2626

2727
When I run `wp profile eval-file http-request.php --fields=request_count`

features/profile-eval.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ Feature: Profile arbitary code execution
55
And a wp-content/mu-plugins/lame-function.php file:
66
"""
77
<?php
8-
function runcommand_do_nothing() {
8+
function wp_cli_do_nothing() {
99
1010
}
1111
"""
1212

13-
When I run `wp profile eval 'runcommand_do_nothing();' --fields=query_time,query_count,cache_ratio,cache_hits,cache_misses,request_time,request_count`
13+
When I run `wp profile eval 'wp_cli_do_nothing();' --fields=query_time,query_count,cache_ratio,cache_hits,cache_misses,request_time,request_count`
1414
Then STDOUT should be a table containing rows:
1515
| query_time | query_count | cache_ratio | cache_hits | cache_misses | request_time | request_count |
1616
| 0s | 0 | | 0 | 0 | 0s | 0 |
1717

1818
Scenario: Profile a function that makes one HTTP request
1919
Given a WP install
2020

21-
When I run `wp profile eval 'wp_remote_get( "http://apple.com" );' --fields=request_count`
21+
When I run `wp profile eval 'wp_remote_get( "https://www.apple.com/" );' --fields=request_count`
2222
Then STDOUT should be a table containing rows:
2323
| request_count |
2424
| 1 |

0 commit comments

Comments
 (0)