Skip to content

Commit

Permalink
Add updated GHA testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Mar 3, 2021
1 parent 08d7220 commit 60d39a9
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 3 deletions.
172 changes: 172 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
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-20.04

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 }} with MySQL ${{ matrix.mysql }}
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
wp: ['latest']
mysql: ['8.0']
test: ["composer behat || composer behat-rerun"]
include:
- php: '5.6'
wp: 'trunk'
mysql: '8.0'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: 'trunk'
mysql: '5.7'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: 'trunk'
mysql: '5.6'
test: "composer behat || composer behat-rerun"
- php: '7.4'
wp: 'trunk'
mysql: '8.0'
test: "composer behat || composer behat-rerun"
- php: '8.0'
wp: 'trunk'
mysql: '8.0'
test: "composer behat || composer behat-rerun"
- php: '8.0'
wp: 'trunk'
mysql: '5.7'
test: "composer behat || composer behat-rerun"
- php: '8.0'
wp: 'trunk'
mysql: '5.6'
test: "composer behat || composer behat-rerun"
- php: '5.6'
wp: '3.7'
mysql: '5.6'
test: "composer behat || composer behat-rerun"
runs-on: ubuntu-20.04

services:
mysql:
image: mysql:${{ matrix.mysql }}
ports:
- 3306
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"

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
if: steps.check_files.outputs.files_exists == 'true'
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 systemctl start mysql

- name: Configure DB environment
if: steps.check_files.outputs.files_exists == 'true'
run: |
export MYSQL_HOST=127.0.0.1
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
- name: Prepare test database
if: steps.check_files.outputs.files_exists == 'true'
run: composer prepare-tests

- name: Run Behat
if: steps.check_files.outputs.files_exists == 'true'
env:
WP_VERSION: '${{ matrix.wp }}'
run: ${{ matrix.test }}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
],
"require": {
"php": "^5.6 || ^7.0",
"wp-cli/wp-cli": "dev-master"
"wp-cli/wp-cli": "dev-master",
"wp-cli/wp-cli-tests": "^3.0.1"
},
"require-dev": {
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^2.1"
"wp-cli/extension-command": "^1.2 || ^2"
},
"config": {
"process-timeout": 7200,
Expand Down

0 comments on commit 60d39a9

Please sign in to comment.