Skip to content

Commit

Permalink
Revert dynamic test matrix code (#86)
Browse files Browse the repository at this point in the history
* Revert "Merge pull request #85 from wp-cli/fix/reusable-action-path"

This reverts commit 1a90b46, reversing
changes made to b31e027.

* Revert "Dynamically create test matrix (#78)"

This reverts commit b31e027.
  • Loading branch information
danielbachhuber authored Nov 1, 2023
1 parent 1a90b46 commit 7de022f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 196 deletions.
108 changes: 66 additions & 42 deletions .github/workflows/reusable-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,31 @@ concurrency:
cancel-in-progress: true

jobs:
prepare-unit:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Set matrix
id: set-matrix
run: echo "matrix=$(jq -c '.include |= map(with_entries(select(.key == "php"))) | .include |= map(select(.php >= "${{ inputs.minimum-php }}"))' < ${{ github.action_path }}/matrix.json)" >> $GITHUB_OUTPUT

unit: #-----------------------------------------------------------------------
name: Unit test / PHP ${{ matrix.php }}
needs: prepare-unit
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-unit.outputs.matrix) }}
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
runs-on: ubuntu-20.04

continue-on-error: ${{ matrix.php == '8.3' }}

steps:
- name: Check out source code
if: ${{ matrix.php >= inputs.minimum-php }}
uses: actions/checkout@v4

- name: Check existence of composer.json file
if: ${{ matrix.php >= inputs.minimum-php }}
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "composer.json, phpunit.xml.dist"

- name: Set up PHP environment (PHP 5.6 - 7.1)
if: ${{ matrix.php < '7.2' && steps.check_files.outputs.files_exists == 'true'}}
if: ${{ matrix.php >= inputs.minimum-php && matrix.php < '7.2' && steps.check_files.outputs.files_exists == 'true'}}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
Expand All @@ -60,7 +51,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up PHP environment (PHP 7.2+)
if: ${{ matrix.php >= '7.2' && steps.check_files.outputs.files_exists == 'true'}}
if: ${{ matrix.php >= inputs.minimum-php && matrix.php >= '7.2' && steps.check_files.outputs.files_exists == 'true'}}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
Expand All @@ -70,7 +61,7 @@ jobs:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Composer dependencies & cache dependencies
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
uses: "ramsey/composer-install@v2"
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
Expand All @@ -79,31 +70,62 @@ jobs:
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Setup problem matcher to provide annotations for PHPUnit
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && 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' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
run: composer phpunit

prepare-functional: #---------------------------------------------------------
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Set matrix
id: set-matrix
run: echo "matrix=$(jq -c '.include |= map(select(.php >= "${{ inputs.minimum-php }}"))' < ${{ github.action_path }}/matrix.json)" >> $GITHUB_OUTPUT

functional: #-----------------------------------------------------------------
functional: #----------------------------------------------------------------------
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with ${{ matrix.dbtype != 'sqlite' && format('MySQL {0}', matrix.mysql) || 'SQLite' }}
needs: prepare-functional
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-functional.outputs.matrix) }}
matrix:
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
wp: ['latest']
mysql: ['8.0']
dbtype: ['mysql', 'sqlite']
include:
- php: '7.0'
wp: 'trunk'
mysql: '8.0'
- php: '7.0'
wp: 'trunk'
mysql: '5.7'
- php: '7.0'
wp: 'trunk'
mysql: '5.6'
- php: '7.4'
wp: 'trunk'
mysql: '8.0'
- php: '8.0'
wp: 'trunk'
mysql: '8.0'
- php: '8.0'
wp: 'trunk'
mysql: '5.7'
- php: '8.0'
wp: 'trunk'
mysql: '5.6'
- php: '8.1'
wp: 'trunk'
mysql: '8.0'
- php: '8.2'
wp: 'trunk'
mysql: '8.0'
- php: '5.6'
wp: '3.7'
mysql: '5.6'
- php: '5.6'
wp: '6.2'
mysql: '8.0'
- php: '8.3'
wp: 'trunk'
mysql: '8.0'
- php: '8.2'
wp: 'trunk'
dbtype: 'sqlite'
runs-on: ubuntu-20.04

continue-on-error: ${{ matrix.php == '8.3' || matrix.dbtype == 'sqlite' }}
Expand All @@ -118,22 +140,24 @@ jobs:

steps:
- name: Check out source code
if: ${{ matrix.php >= inputs.minimum-php }}
uses: actions/checkout@v4

- name: Check existence of composer.json & behat.yml files
if: ${{ matrix.php >= inputs.minimum-php }}
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "composer.json, behat.yml"

- name: Install Ghostscript
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
run: |
sudo apt-get update
sudo apt-get install ghostscript -y
- name: Set up PHP environment
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
Expand All @@ -144,12 +168,12 @@ jobs:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Change ImageMagick policy to allow pdf->png conversion.
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
- name: Install Composer dependencies & cache dependencies
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
uses: "ramsey/composer-install@v2"
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
Expand All @@ -158,11 +182,11 @@ jobs:
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Start MySQL server
if: ${{ matrix.dbtype != 'sqlite' && steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.dbtype != 'sqlite' && matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
run: sudo systemctl start mysql

- name: Configure DB environment
if: ${{ matrix.dbtype != 'sqlite' && steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.dbtype != 'sqlite' && matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
run: |
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
Expand All @@ -174,18 +198,18 @@ jobs:
echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
- name: Prepare test database
if: ${{ matrix.dbtype != 'sqlite' && steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.dbtype != 'sqlite' && matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
run: composer prepare-tests

- name: Check Behat environment
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
env:
WP_VERSION: '${{ matrix.wp }}'
WP_CLI_TEST_DBTYPE: ${{ matrix.dbtype || 'mysql' }}
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat

- name: Run Behat
if: ${{ steps.check_files.outputs.files_exists == 'true' }}
if: ${{ matrix.php >= inputs.minimum-php && steps.check_files.outputs.files_exists == 'true' }}
env:
WP_VERSION: '${{ matrix.wp }}'
WP_CLI_TEST_DBTYPE: ${{ matrix.dbtype || 'mysql' }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sync-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
^.editorconfig
^.github/workflows/code-quality.yml
^.github/workflows/regenerate-readme.yml
^.github/workflows/testing.yml
TARGET_REPOS: |
wp-cli/admin-command
wp-cli/cache-command
Expand Down
154 changes: 0 additions & 154 deletions matrix.json

This file was deleted.

0 comments on commit 7de022f

Please sign in to comment.