Skip to content

Commit b67695a

Browse files
authored
Merge pull request #128 from wp-cli/add/switch-to-github-actions
2 parents 8838c08 + 6946e5a commit b67695a

6 files changed

Lines changed: 157 additions & 92 deletions

File tree

‎.github/workflows/testing.yml‎

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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']
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: '5.6'
76+
wp: '3.7'
77+
test: "composer behat || composer behat-rerun || true"
78+
runs-on: ubuntu-latest
79+
80+
services:
81+
mysql:
82+
image: mysql:5.7
83+
env:
84+
MYSQL_DATABASE: wp_cli_test
85+
MYSQL_USER: root
86+
MYSQL_ROOT_PASSWORD: root
87+
ports:
88+
- 3306
89+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
90+
91+
steps:
92+
- name: Check out source code
93+
uses: actions/checkout@v2
94+
95+
- name: Check existence of composer.json & behat.yml files
96+
id: check_files
97+
uses: andstor/file-existence-action@v1
98+
with:
99+
files: "composer.json, behat.yml"
100+
101+
- name: Set up PHP envirnoment
102+
uses: shivammathur/setup-php@v2
103+
with:
104+
php-version: '${{ matrix.php }}'
105+
extensions: mysql, zip
106+
coverage: none
107+
tools: composer
108+
109+
- name: Get Composer cache Directory
110+
if: steps.check_files.outputs.files_exists == 'true'
111+
id: composer-cache
112+
run: |
113+
echo "::set-output name=dir::$(composer config cache-files-dir)"
114+
115+
- name: Use Composer cache
116+
if: steps.check_files.outputs.files_exists == 'true'
117+
uses: actions/cache@master
118+
with:
119+
path: ${{ steps['composer-cache'].outputs.dir }}
120+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
121+
restore-keys: |
122+
${{ runner.os }}-composer-
123+
124+
- name: Install dependencies
125+
if: steps.check_files.outputs.files_exists == 'true'
126+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
127+
128+
- name: Start MySQL server
129+
if: steps.check_files.outputs.files_exists == 'true'
130+
run: sudo service mysql start
131+
132+
- name: Prepare test database
133+
if: steps.check_files.outputs.files_exists == 'true'
134+
run: |
135+
export MYQSL_HOST=127.0.0.1
136+
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
137+
mysql -e 'CREATE DATABASE IF NOT EXISTS wp_cli_test;' -uroot -proot
138+
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"127.0.0.1" IDENTIFIED BY "password1"' -uroot -proot
139+
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test_scaffold.* TO "wp_cli_test"@"127.0.0.1" IDENTIFIED BY "password1"' -uroot -proot
140+
141+
- name: Run Behat
142+
if: steps.check_files.outputs.files_exists == 'true'
143+
env:
144+
WP_VERSION: '${{ matrix.wp }}'
145+
run: ${{ matrix.test }}
146+

‎.travis.yml‎

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

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"require": {
1515
"ext-json": "*",
1616
"composer/composer": ">=1.2.0 <1.7.0 || ^1.7.1 || ^2.0.0",
17-
"wp-cli/wp-cli": "dev-master"
17+
"wp-cli/wp-cli": "~2.5"
1818
},
1919
"require-dev": {
2020
"wp-cli/scaffold-command": "^1 || ^2",

‎features/package.feature‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Feature: Manage WP-CLI packages
5757
When I run `wp --require=bad-command.php package list`
5858
Then STDERR should be empty
5959

60-
@require-php-7.0
60+
@require-php-7.2
6161
Scenario: Revert the WP-CLI packages composer.json when fail to install/uninstall a package due to memory limit
6262
Given an empty directory
6363
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--dmemory_limit=10M -ddisable_functions=ini_set} package install danielbachhuber/wp-cli-reset-post-date-command`
@@ -96,7 +96,7 @@ Feature: Manage WP-CLI packages
9696
{MYPACKAGES_COMPOSER_JSON}
9797
"""
9898

99-
@require-php-7.0
99+
@require-php-7.2
100100
Scenario: Revert the WP-CLI packages composer.json when fail to install/uninstall a package due to memory limit
101101
Given an empty directory
102102
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--dmemory_limit=10M -ddisable_functions=ini_set} package install danielbachhuber/wp-cli-reset-post-date-command`

‎tests/test-composer-json.php‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
use WP_CLI\Utils;
44
use WP_CLI\ExitException;
55
use WP_CLI\Loggers\Execution;
6+
use WP_CLI\Tests\TestCase;
67

78
require_once VENDOR_DIR . '/wp-cli/wp-cli/php/utils.php';
89
require_once VENDOR_DIR . '/wp-cli/wp-cli/php/class-wp-cli.php';
910
require_once VENDOR_DIR . '/wp-cli/wp-cli/php/class-wp-cli-command.php';
1011

11-
class ComposerJsonTest extends PHPUnit_Framework_TestCase {
12+
class ComposerJsonTest extends TestCase {
1213

1314
private $logger = null;
1415
private $prev_logger = null;
1516
private $prev_capture_exit = null;
1617
private $temp_dir = null;
1718

18-
public function setUp() {
19-
parent::setUp();
19+
public function set_up() {
20+
parent::set_up();
2021

2122
// Save and set logger.
2223
$class_wp_cli_logger = new \ReflectionProperty( 'WP_CLI', 'logger' );
@@ -36,7 +37,7 @@ public function setUp() {
3637
mkdir( $this->temp_dir );
3738
}
3839

39-
public function tearDown() {
40+
public function tear_down() {
4041
// Restore logger.
4142
WP_CLI::set_logger( $this->prev_logger );
4243

@@ -47,7 +48,7 @@ public function tearDown() {
4748

4849
rmdir( $this->temp_dir );
4950

50-
parent::tearDown();
51+
parent::tear_down();
5152
}
5253

5354
public function test_create_default_composer_json() {

‎tests/test-json-manipulator.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
*/
1212

1313
use WP_CLI\JsonManipulator; // WP_CLI
14+
use WP_CLI\Tests\TestCase;
1415

15-
class JsonManipulatorTest extends \PHPUnit_Framework_TestCase
16+
class JsonManipulatorTest extends TestCase
1617
{
1718

1819
/**

0 commit comments

Comments
 (0)