Skip to content

Commit 0cb88b9

Browse files
authored
Merge pull request #182 from wp-cli/add/switch-testing-to-gha
2 parents b5d97f2 + 6a57a5f commit 0cb88b9

File tree

4 files changed

+163
-89
lines changed

4 files changed

+163
-89
lines changed

.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
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "dev-master"
15+
"wp-cli/wp-cli": "~2.5"
1616
},
1717
"require-dev": {
1818
"wp-cli/entity-command": "^1.3 || ^2",

src/DB_Command.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ public function query( $args, $assoc_args ) {
471471
* [--exclude_tables=<tables>]
472472
* : The comma separated list of specific tables that should be skipped from exporting. Excluding this parameter will export all tables in the database.
473473
*
474+
* [--include-tablespaces]
475+
* : Skips adding the default --no-tablespaces option to mysqldump.
476+
*
474477
* [--porcelain]
475478
* : Output filename for the exported database.
476479
*
@@ -547,17 +550,25 @@ public function export( $args, $assoc_args ) {
547550
$assoc_args['result-file'] = $result_file;
548551
}
549552

550-
$support_column_statistics = exec( 'mysqldump --help | grep "column-statistics"' );
553+
$mysqldump_binary = Utils\force_env_on_nix_systems( 'mysqldump' );
554+
555+
$support_column_statistics = exec( $mysqldump_binary . ' --help | grep "column-statistics"' );
551556

552-
$initial_command = sprintf( '/usr/bin/env mysqldump%s ', $this->get_defaults_flag_string( $assoc_args ) );
557+
$initial_command = sprintf( "{$mysqldump_binary}%s ", $this->get_defaults_flag_string( $assoc_args ) );
553558
WP_CLI::debug( "Running initial shell command: {$initial_command}", 'db' );
554559

560+
$default_arguments = [ '%s' ];
561+
555562
if ( $support_column_statistics ) {
556-
$command = $initial_command . '--skip-column-statistics %s';
557-
} else {
558-
$command = $initial_command . '%s';
563+
$default_arguments[] = '--skip-column-statistics';
559564
}
560565

566+
if ( ! Utils\get_flag_value( $assoc_args, 'include-tablespaces', false ) ) {
567+
$default_arguments[] = '--no-tablespaces';
568+
}
569+
570+
$command = $initial_command . implode( ' ', $default_arguments );
571+
561572
$command_esc_args = [ DB_NAME ];
562573

563574
if ( isset( $assoc_args['tables'] ) ) {

0 commit comments

Comments
 (0)