Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composer packages; Bump PHP to 7.4 and WP to 5.3 #7613

Merged
merged 42 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
45a72f2
Bump `yoast/wp-test-utils` from 1.0.5 to 1.1.0
thelovekesh Sep 3, 2023
2e61c07
Update composer dev packages to latest versions
thelovekesh Sep 3, 2023
1d0474b
Update composer lockfile
thelovekesh Sep 3, 2023
ce53dca
Update sniffs as per latest WPCS version
thelovekesh Sep 3, 2023
00ea890
Remove errors from phpstan baseline which are fixed upstream
thelovekesh Sep 3, 2023
c146468
Add ecosystem-data to be ignored by phpcs
thelovekesh Sep 3, 2023
39176c1
Bump platform PHP version from 7.0.8 to 7.2
thelovekesh Sep 3, 2023
273e95f
Bump automattic/vipwpcs from ^2.0 to ^3.0
thelovekesh Sep 5, 2023
5372062
Bump minimum required PHP version to 7.4
thelovekesh Sep 5, 2023
f8645b1
Bump google/cloud-storage to ^1.0
thelovekesh Sep 5, 2023
9d2b4d1
Update composer lockfile
thelovekesh Sep 5, 2023
2c9fd1e
Bump PHP to 7.4 and minimum WP version to 5.3
thelovekesh Sep 5, 2023
f282d63
Bump PHP to 7.4
thelovekesh Sep 5, 2023
f3e5b60
Remove support for PHP 5.6 from SimpleInjector
thelovekesh Sep 5, 2023
67e89f5
Remove samesite cookies workaround as we have bumped to PHP 7.4
thelovekesh Sep 5, 2023
d5b7cdc
Remove PHPUnit patches as they are fixed upstream
thelovekesh Sep 5, 2023
49e829c
Remove workflows for PHP < 7.4
thelovekesh Sep 5, 2023
2436565
Update composer lockfile
thelovekesh Sep 5, 2023
c02c4c4
Fix PHPUnit version in workflows matrix
thelovekesh Sep 5, 2023
06d5930
Restore composer install step
thelovekesh Sep 5, 2023
cead962
Update phpunit bootstrap file to autoload early before WP CLI logger
thelovekesh Sep 6, 2023
3a668b4
Update workflow to remove locally installed PHPUnit
thelovekesh Sep 6, 2023
15f5a46
Update PHPUnit version for PHP 7.4 and WP 5.3
thelovekesh Sep 6, 2023
5c35b03
Fix PHPUnit external testsuite command
thelovekesh Sep 6, 2023
ff8cfc4
Merge branch 'develop' into update/composer-packages
thelovekesh Sep 6, 2023
46b7286
Remove `@data-replyto` attribute from comments sanitizer
thelovekesh Sep 6, 2023
ee2c662
Skip block validation script tests on WP < 5.6
thelovekesh Sep 6, 2023
90678dd
Update test cases for validation manager when WP < 5.5
thelovekesh Sep 6, 2023
a720194
Update feature tests workflow to run with WP 5.3
thelovekesh Sep 6, 2023
d258088
Update test for URL validation rest controller
thelovekesh Sep 7, 2023
436f4aa
Fix test cases due to addition of `wp_pattern_category` taxonomy
thelovekesh Sep 7, 2023
0c2c672
Remove skipped tests for WP < 5.3 versions
thelovekesh Sep 7, 2023
7c96246
Remove unsused data from dataProvider
thelovekesh Sep 7, 2023
9c60ad6
Remove duplicate test matrix and add PHP 8.3 in tests matrix
thelovekesh Sep 7, 2023
c1b1971
Increase navigation timeout for e2e tests to 30000 ms
thelovekesh Sep 7, 2023
108049c
Remove experimental from unit tests with PHP 8.2 and WP trunk
thelovekesh Sep 7, 2023
056f613
Fix code comment formatting; Remove duplicated LOC
thelovekesh Sep 8, 2023
9b700ff
Update var override with ternary operator
thelovekesh Sep 8, 2023
6925bef
Disable PHPCS errors due to latest WPCS
thelovekesh Sep 8, 2023
aed0343
Fix PHPCS errors due to CS updates
thelovekesh Sep 8, 2023
a2904df
Update `get_posts_by_type` to avoid post__not_in with WP_Query
thelovekesh Sep 11, 2023
3eb015a
Update e2e tests artifacts to GitHub in case of failure
thelovekesh Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 71 additions & 102 deletions .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ jobs:

- name: Install Node dependencies
run: npm ci
env:
CI: true
westonruter marked this conversation as resolved.
Show resolved Hide resolved

- name: Detect coding standard violations (stylelint)
run: npm run lint:css
Expand All @@ -126,8 +124,6 @@ jobs:

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Validate package.json
run: npm run lint:pkg-json
Expand Down Expand Up @@ -300,8 +296,6 @@ jobs:

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Run unit tests (with coverage)
run: npm run test:js -- --ci --cacheDirectory="$HOME/.jest-cache" --collectCoverage
Expand Down Expand Up @@ -351,8 +345,6 @@ jobs:

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction
Expand All @@ -374,6 +366,13 @@ jobs:
env:
COMPOSE_INTERACTIVE_NO_CLI: true

- name: Upload artifacts
uses: actions/upload-artifact@v3
if: failure()
with:
name: amp-e2e-artifacts
path: artifacts

#-----------------------------------------------------------------------------------------------------------------------

# Adapted from workflow for running PHP unit tests on google/web-stories-wp.
Expand Down Expand Up @@ -405,52 +404,51 @@ jobs:
install-pwa-plugin: [true]
coverage: [false]
include:
- php: '8.0'
- php: '8.3'
wp: 'trunk'
multisite: true
phpunit: '9.6'
experimental: true

- php: '8.2'
wp: 'trunk'
phpunit: '9.6'

- php: '8.1'
wp: 'trunk'
experimental: true
phpunit: '9.6'

- php: '8.2'
- php: '8.0'
wp: 'trunk'
experimental: true
phpunit: '9.3'
multisite: true

- php: '8.0'
wp: 'latest'
phpunit: '9.3'
coverage: true

- php: '8.0'
wp: 'latest'
phpunit: '9.3'
external-http: true

- php: '7.4'
multisite: true
wp: 'latest'
phpunit: '9.3'
multisite: true

- php: '7.4'
wp: 'latest'
phpunit: '9.3'
external-http: true

- php: '7.3'
wp: 'latest'

- php: '7.2'
wp: 'latest'

- php: '7.1'
wp: 'latest'

- php: '7.0'
wp: '5.1'

- php: '7.0'
wp: '5.0'
- php: '7.4'
wp: '5.3'
phpunit: '7'

- php: '7.0'
wp: '4.9'
- php: '7.4'
wp: '5.3'
phpunit: '7'
external-http: true

steps:
Expand All @@ -472,6 +470,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: curl, date, dom, gd, iconv, json, libxml, mysql, spl
tools: phpunit:${{ matrix.phpunit }}
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}

- name: Shutdown default MySQL service
Expand Down Expand Up @@ -508,55 +507,20 @@ jobs:

- name: Install Composer dependencies
if: needs.pre-run.outputs.changed-php-count > 0
run: |
# phpdocumentor/reflection has to be removed as it makes use of an outdated dependency.
composer remove --dev phpdocumentor/reflection
composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction
run: composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction

# See https://github.com/wp-cli/wp-cli/issues/5484
- name: Remove conflicting Requests library
if: needs.pre-run.outputs.changed-php-count > 0
run: composer remove --dev --ignore-platform-reqs --no-interaction --no-scripts roave/security-advisories wp-cli/export-command wp-cli/extension-command wp-cli/wp-cli wp-cli/wp-cli-tests

# Installs a different PHPUnit version depending on the WP/PHP version combo we're testing against.
#
# | WP / PHP | PHPUnit |
# |-----------|---------|
# | 5.0 / 7.0 | 6 |
# | 5.7 / 7.1 | 7 |
# | 5.9 / 7.2 | 8 |
# | 5.9 / 7.4 | 9 |
# | * / 8 | 9 |
#
# See https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/
- name: Update PHPUnit
# Since locally installed PHPUnit classes are loaded into the classmap, running tests with globally
# installed PHPUnit requires removing locally installed PHPUnit. Additionally, using the workflow matrix
# makes it simple for us to maintain different PHPUnit versions for various PHP versions.
- name: Remove locally installed PHPUnit
if: needs.pre-run.outputs.changed-php-count > 0
run: |
if [[ $PHP_VERSION == "7.1" ]]; then
echo "Installing PHPUnit 7.5.x"
composer require --ignore-platform-reqs --no-interaction --no-scripts phpunit/phpunit:^7.5 --with-dependencies
elif [[ $PHP_VERSION == "7.2" ]]; then
echo "Installing PHPUnit 8.5.x"
composer require --ignore-platform-reqs --no-interaction --no-scripts phpunit/phpunit:^8.5 --with-dependencies
echo "Downgrading phpunit/php-token-stream because the latest version requires PHP 7.3"
composer require --ignore-platform-reqs --no-interaction --no-scripts phpunit/php-token-stream:^3.1.3 --with-dependencies
elif [[ $PHP_VERSION == "7.3" || $PHP_VERSION == "7.4" || $PHP_VERSION == "8.0" ]]; then
echo "Installing PHPUnit 9.3"
composer update --ignore-platform-reqs --no-interaction --no-scripts yoast/phpunit-polyfills --with-dependencies
composer require --dev --ignore-platform-reqs phpunit/phpunit:"9.3.*" --with-dependencies
elif [[ $WP_VERSION == "latest" || $WP_VERSION == "trunk" || $PHP_VERSION == "8.1" || $PHP_VERSION == "8.2" ]]; then
echo "Installing latest version of PHPUnit"
composer update --ignore-platform-reqs --no-interaction --no-scripts yoast/phpunit-polyfills --with-dependencies
fi
env:
WP_VERSION: ${{ matrix.wp }}
PHP_VERSION: ${{ matrix.php }}
rm -rf vendor/phpunit
composer dump-autoload -o
Comment on lines +518 to +519
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better than doing composer remove phpunit/phpunit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composer remove phpunit/phpunit is unable to run it as PHPUnit is required by many other packages, and I am unable to find a way to ignore PHPUnit in the class map so it doesn't collide with global PHPUnit.


- name: Install Node dependencies
if: needs.pre-run.outputs.changed-php-count > 0
run: npm ci
env:
CI: true

- name: Build plugin
if: needs.pre-run.outputs.changed-php-count > 0
Expand Down Expand Up @@ -586,29 +550,37 @@ jobs:

- name: Run tests
if: ${{ matrix.coverage == false && needs.pre-run.outputs.changed-php-count > 0 }}
run: vendor/bin/phpunit --verbose
run: |
phpunit --version
phpunit --verbose
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib

- name: Run multisite tests
if: ${{ matrix.multisite == true && needs.pre-run.outputs.changed-php-count > 0 }}
run: vendor/bin/phpunit --verbose
run: |
phpunit --version
phpunit --verbose
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib
WP_MULTISITE: 1

- name: Run tests with coverage
if: ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
run: vendor/bin/phpunit --verbose --coverage-clover ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp/build/logs/clover.xml
run: |
phpunit --version
phpunit --verbose --coverage-clover ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp/build/logs/clover.xml
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib

- name: Run external HTTP tests
if: ${{ matrix.external-http == true && needs.pre-run.outputs.changed-php-count > 0 }}
run: vendor/bin/phpunit --testsuite external-http
run: |
phpunit --version
phpunit --testsuite external-http --verbose
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib
Expand Down Expand Up @@ -645,27 +617,27 @@ jobs:
strategy:
fail-fast: false
matrix:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should 8.3 be added experimentally? I understand that WordPress trunk is now compatible.

# @TODO: Revisit this if we want to enable code coverage for feature tests.
coverage: [false]
php: ['7.4', '7.3', '7.2', '7.1']
php: ['7.4']
wp: ['latest']
include:
- php: '8.1'
- php: '8.3'
wp: 'trunk'
experimental: true
coverage: false

- php: '8.2'
wp: 'trunk'
experimental: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be experimental?

Suggested change
experimental: true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP 8.2 is still in beta for WP 6.3. Should we remove it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tests currently pass in 6.2 I'd say remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing with PHP 8.2 on WP 6.2, so experimental flag.


- php: '8.1'
wp: 'trunk'

- php: '8.0'
wp: 'latest'
coverage: false

# TODO: Enable this once codecov upload merging works as expected.
# - php: '7.4'
# wp: 'latest'
# coverage: true

- php: '7.0'
wp: '5.1'
coverage: false
- php: '7.4'
wp: '5.3'

steps:
- name: Checkout
Expand Down Expand Up @@ -711,21 +683,20 @@ jobs:

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Build plugin
run: npm run build:js

- name: Update PHPUnit to get latest php-code-coverage library
if: ${{ matrix.coverage == true }}
# phpdocumentor/reflection has to be removed as it makes use of an outdated dependency.
# phpunit/phpunit has to be updated as the one in use provides an older version of phpunit/php-code-coverage,
# but we need the v9.x branch.
# It cannot be removed, as it is a requirement of wp-cli/wp-cli-tests as well.
run: |
composer remove --dev phpdocumentor/reflection
composer require --dev --ignore-platform-reqs --update-with-all-dependencies phpunit/phpunit
# @TODO: Revisit this if we want to enable code coverage for feature tests.
# - name: Update PHPUnit to get latest php-code-coverage library
# if: ${{ matrix.coverage == true }}
# # phpdocumentor/reflection has to be removed as it makes use of an outdated dependency.
# # phpunit/phpunit has to be updated as the one in use provides an older version of phpunit/php-code-coverage,
# # but we need the v9.x branch.
# # It cannot be removed, as it is a requirement of wp-cli/wp-cli-tests as well.
# run: |
# composer remove --dev phpdocumentor/reflection
# composer require --dev --ignore-platform-reqs --update-with-all-dependencies phpunit/phpunit
Comment on lines +690 to +699
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code coverage wasn't working for feature tests anyway, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as we are unable to merge coverage reports. I need to check if our coverage logic is working as expected or not.


- name: Configure DB environment
run: |
Expand Down Expand Up @@ -786,7 +757,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.0'
php-version: '7.4'

- name: Setup Node
uses: actions/setup-node@v3.8.1
Expand All @@ -813,8 +784,6 @@ jobs:

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Create destination directories
run: mkdir -p builds/${{ matrix.build }}
Expand Down
Loading