Skip to content

Change connection test page capabilities to manage_woocommerce #3144

Change connection test page capabilities to manage_woocommerce

Change connection test page capabilities to manage_woocommerce #3144

Workflow file for this run

name: PHP Unit Tests
on:
push:
branches:
- trunk
- develop
paths:
- "**.php"
- composer.json
- composer.lock
- .github/workflows/php-unit-tests.yml
pull_request:
paths:
- "**.php"
- composer.json
- composer.lock
- .github/workflows/php-unit-tests.yml
workflow_dispatch:
inputs:
php-version:
description: 'PHP Version'
default: '8.2'
wp-rc-version:
description: 'WordPress version for Release Candidate (ex. 6.5-RC3)'
default: 'latest'
wc-rc-version:
description: 'WooCommerce version for Release Candidate (ex. 8.7.0-rc.1)'
default: 'latest'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
GetMatrix:
if: github.event_name != 'workflow_dispatch'
name: Get WP and WC version Matrix
runs-on: ubuntu-latest
outputs:
wp-versions: ${{ steps.wp.outputs.versions }}
wc-versions: ${{ steps.wc.outputs.versions }}
latest-wc-version: ${{ fromJson(steps.wc.outputs.versions)[0] }}
steps:
- name: Get Release versions from Wordpress
id: wp
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: wordpress
- name: Get Release versions from WooCommerce
id: wc
uses: woocommerce/grow/get-plugin-releases@actions-v2
with:
slug: woocommerce
UnitTests:
if: github.event_name != 'workflow_dispatch'
name: PHP unit tests - PHP ${{ matrix.php }}, WP ${{ matrix.wp-version || 'latest' }}, WC ${{ matrix.wc-versions || 'latest' }}
needs: GetMatrix
runs-on: ubuntu-latest
env:
WP_CORE_DIR: "/tmp/wordpress/src"
WP_TESTS_DIR: "/tmp/wordpress/tests/phpunit"
generate_coverage: 'false'
strategy:
matrix:
php: [ 8.2 ]
wp-version: [ latest ]
wc-versions: ${{ fromJson(needs.GetMatrix.outputs.wc-versions) }}
include:
- php: 8.3
wp-version: latest
wc-versions: latest
- php: 7.4
wp-version: ${{ fromJson(needs.GetMatrix.outputs.wp-versions)[2] }} # L-2 WP Version support
wc-versions: ${{ fromJson(needs.GetMatrix.outputs.wc-versions)[2] }} # L-2 WC Version support
steps:
- name: Checkout repository
uses: actions/checkout@v4
- if: matrix.wc-versions == needs.GetMatrix.outputs.latest-wc-version && matrix.php == 8.2
name: Set condition to generate coverage report (only on latest versions)
run: echo "generate_coverage=true" >> $GITHUB_ENV
- name: Prepare PHP
uses: woocommerce/grow/prepare-php@actions-v2
with:
php-version: "${{ matrix.php }}"
coverage: "${{ env.generate_coverage == 'true' && 'xdebug' || 'none' }}"
- name: Prepare MySQL
uses: woocommerce/grow/prepare-mysql@actions-v2
- name: Install WP tests
run: ./bin/install-wp-tests.sh wordpress_test root root localhost ${{ matrix.wp-version }} ${{ matrix.wc-versions }}
- if: env.generate_coverage != 'true'
name: Run PHP unit tests
run: composer test-unit
- if: env.generate_coverage == 'true'
name: Run PHP unit tests (with code coverage)
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover=tests/php-coverage/report.xml
- if: env.generate_coverage == 'true'
name: Upload PHP unit coverage report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: tests/php-coverage/report.xml
flags: php-unit-tests
name: php-coverage-report
ReleaseCandidateUnitTests:
if: github.event_name == 'workflow_dispatch'
name: PHP unit tests (for Release Candidates)
runs-on: ubuntu-latest
env:
WP_CORE_DIR: "/tmp/wordpress/src"
WP_TESTS_DIR: "/tmp/wordpress/tests/phpunit"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare PHP
uses: woocommerce/grow/prepare-php@actions-v2
with:
php-version: "${{ inputs.php-version }}"
- name: Prepare MySQL
uses: woocommerce/grow/prepare-mysql@actions-v2
- name: Install WP tests
env:
INPUT_WP_RC_VERSION: ${{ inputs.wp-rc-version }}
INPUT_WC_RC_VERSION: ${{ inputs.wc-rc-version }}
run: ./bin/install-wp-tests.sh wordpress_test root root localhost "${INPUT_WP_RC_VERSION}" "${INPUT_WC_RC_VERSION}"
- name: Run PHP unit tests
run: composer test-unit