Skip to content

Commit

Permalink
Merge pull request #182 from wp-cli/add/switch-testing-to-gha
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera authored Dec 7, 2020
2 parents b5d97f2 + 6a57a5f commit 0cb88b9
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 89 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Testing

on: pull_request

jobs:

unit: #-----------------------------------------------------------------------
name: Unit test / PHP ${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
runs-on: ubuntu-latest

steps:
- name: Check out source code
uses: actions/checkout@v2

- name: Check existence of composer.json file
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "composer.json, phpunit.xml.dist"

- name: Set up PHP environment
if: steps.check_files.outputs.files_exists == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
coverage: none
tools: composer,cs2pr

- name: Get Composer cache Directory
if: steps.check_files.outputs.files_exists == 'true'
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer cache
if: steps.check_files.outputs.files_exists == 'true'
uses: actions/cache@master
with:
path: ${{ steps['composer-cache'].outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
if: steps.check_files.outputs.files_exists == 'true'
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest

- name: Setup problem matcher to provide annotations for PHPUnit
if: steps.check_files.outputs.files_exists == 'true'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
if: steps.check_files.outputs.files_exists == 'true'
run: composer phpunit

functional: #----------------------------------------------------------------------
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
wp: ['latest']
test: ["composer behat || composer behat-rerun"]
include:
- php: '5.6'
wp: 'trunk'
test: "composer behat || composer behat-rerun"
- php: '7.4'
wp: 'trunk'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: '3.7'
test: "composer behat || composer behat-rerun || true"
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: wp_cli_test
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Check out source code
uses: actions/checkout@v2

- name: Check existence of composer.json & behat.yml files
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "composer.json, behat.yml"

- name: Set up PHP envirnoment
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: mysql, zip
coverage: none
tools: composer

- name: Get Composer cache Directory
if: steps.check_files.outputs.files_exists == 'true'
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer cache
if: steps.check_files.outputs.files_exists == 'true'
uses: actions/cache@master
with:
path: ${{ steps['composer-cache'].outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
if: steps.check_files.outputs.files_exists == 'true'
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest

- name: Start MySQL server
if: steps.check_files.outputs.files_exists == 'true'
run: sudo service mysql start

- name: Prepare test database
if: steps.check_files.outputs.files_exists == 'true'
run: |
export MYQSL_HOST=127.0.0.1
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
mysql -e 'CREATE DATABASE IF NOT EXISTS wp_cli_test;' -uroot -proot
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"127.0.0.1" IDENTIFIED BY "password1"' -uroot -proot
mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test_scaffold.* TO "wp_cli_test"@"127.0.0.1" IDENTIFIED BY "password1"' -uroot -proot
- name: Run Behat
if: steps.check_files.outputs.files_exists == 'true'
env:
WP_VERSION: '${{ matrix.wp }}'
run: ${{ matrix.test }}

83 changes: 0 additions & 83 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"wp-cli/wp-cli": "dev-master"
"wp-cli/wp-cli": "~2.5"
},
"require-dev": {
"wp-cli/entity-command": "^1.3 || ^2",
Expand Down
21 changes: 16 additions & 5 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ public function query( $args, $assoc_args ) {
* [--exclude_tables=<tables>]
* : The comma separated list of specific tables that should be skipped from exporting. Excluding this parameter will export all tables in the database.
*
* [--include-tablespaces]
* : Skips adding the default --no-tablespaces option to mysqldump.
*
* [--porcelain]
* : Output filename for the exported database.
*
Expand Down Expand Up @@ -547,17 +550,25 @@ public function export( $args, $assoc_args ) {
$assoc_args['result-file'] = $result_file;
}

$support_column_statistics = exec( 'mysqldump --help | grep "column-statistics"' );
$mysqldump_binary = Utils\force_env_on_nix_systems( 'mysqldump' );

$support_column_statistics = exec( $mysqldump_binary . ' --help | grep "column-statistics"' );

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

$default_arguments = [ '%s' ];

if ( $support_column_statistics ) {
$command = $initial_command . '--skip-column-statistics %s';
} else {
$command = $initial_command . '%s';
$default_arguments[] = '--skip-column-statistics';
}

if ( ! Utils\get_flag_value( $assoc_args, 'include-tablespaces', false ) ) {
$default_arguments[] = '--no-tablespaces';
}

$command = $initial_command . implode( ' ', $default_arguments );

$command_esc_args = [ DB_NAME ];

if ( isset( $assoc_args['tables'] ) ) {
Expand Down

0 comments on commit 0cb88b9

Please sign in to comment.