From 06d20fe65cc333d72d2be8c4ac3e4676164b0547 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 11 Jun 2024 15:12:26 -0400 Subject: [PATCH] ci: Skip plugin setup with composer.json `.require.php` (#37803) We moved most other stuff to checking that, but forgot this. --- .github/files/setup-wordpress-env.sh | 6 ++++++ .../update-skip-plugin-setup-by-composer-require-php | 4 ++++ projects/plugins/crm/tests/action-skip-test-php.sh | 5 ----- .../update-skip-plugin-setup-by-composer-require-php | 4 ++++ projects/plugins/inspect/composer.json | 1 - projects/plugins/inspect/tests/action-skip-test-php.sh | 6 ------ 6 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 projects/plugins/crm/changelog/update-skip-plugin-setup-by-composer-require-php create mode 100644 projects/plugins/inspect/changelog/update-skip-plugin-setup-by-composer-require-php delete mode 100755 projects/plugins/inspect/tests/action-skip-test-php.sh diff --git a/.github/files/setup-wordpress-env.sh b/.github/files/setup-wordpress-env.sh index ac8daea09f9e5..480eec5565827 100755 --- a/.github/files/setup-wordpress-env.sh +++ b/.github/files/setup-wordpress-env.sh @@ -70,6 +70,12 @@ for PLUGIN in projects/plugins/*/composer.json; do echo "::group::Installing plugin $NAME into WordPress" + if php -r 'exit( preg_match( "/^>=\\s*(\\d+\\.\\d+)$/", $argv[1], $m ) && version_compare( PHP_VERSION, $m[1], "<" ) ? 0 : 1 );' "$( jq -r '.require.php // ""' "$DIR/composer.json" )"; then + echo "::endgroup::" + echo "Skipping install of plugin $NAME, requires PHP $( jq -r '.require.php // ""' "$DIR/composer.json" )" + continue + fi + if jq --arg script "skip-$TEST_SCRIPT" -e '.scripts[$script] // false' "$DIR/composer.json" > /dev/null; then { composer --working-dir="$DIR" run "skip-$TEST_SCRIPT"; CODE=$?; } || true if [[ $CODE -eq 3 ]]; then diff --git a/projects/plugins/crm/changelog/update-skip-plugin-setup-by-composer-require-php b/projects/plugins/crm/changelog/update-skip-plugin-setup-by-composer-require-php new file mode 100644 index 0000000000000..c87095264addb --- /dev/null +++ b/projects/plugins/crm/changelog/update-skip-plugin-setup-by-composer-require-php @@ -0,0 +1,4 @@ +Significance: patch +Type: removed + +Remove obsolete PHP version check in `tests/action-skip-test-php.sh`. No change to the plugin itself. diff --git a/projects/plugins/crm/tests/action-skip-test-php.sh b/projects/plugins/crm/tests/action-skip-test-php.sh index db03e744fa2ed..486e0e7079d7f 100755 --- a/projects/plugins/crm/tests/action-skip-test-php.sh +++ b/projects/plugins/crm/tests/action-skip-test-php.sh @@ -1,10 +1,5 @@ #!/bin/bash -if php -r 'exit( version_compare( PHP_VERSION, "7.4.0", "<" ) ? 0 : 1 );'; then - echo "PHP version is too old to run tests. 7.4 is required, but $(php -r 'echo PHP_VERSION;') is installed. Skipping."; - exit 3 -fi - # Uncomment the below snippet to disable tests on WP trunk # if [[ "$WP_BRANCH" == 'trunk' ]]; then # echo "Codeception tests against WP trunk are temporarily disabled." diff --git a/projects/plugins/inspect/changelog/update-skip-plugin-setup-by-composer-require-php b/projects/plugins/inspect/changelog/update-skip-plugin-setup-by-composer-require-php new file mode 100644 index 0000000000000..981f89c1d1eed --- /dev/null +++ b/projects/plugins/inspect/changelog/update-skip-plugin-setup-by-composer-require-php @@ -0,0 +1,4 @@ +Significance: patch +Type: removed + +Remove obsolete `skip-test-php` composer script. No change to the plugin itself. diff --git a/projects/plugins/inspect/composer.json b/projects/plugins/inspect/composer.json index 3f37f7fa5bb34..08eb62aad6609 100644 --- a/projects/plugins/inspect/composer.json +++ b/projects/plugins/inspect/composer.json @@ -38,7 +38,6 @@ "phpunit": [ "./vendor/phpunit/phpunit/phpunit --colors=always" ], - "skip-test-php": "tests/action-skip-test-php.sh", "test-php": [ "@composer phpunit" ], diff --git a/projects/plugins/inspect/tests/action-skip-test-php.sh b/projects/plugins/inspect/tests/action-skip-test-php.sh deleted file mode 100755 index e80157348bb33..0000000000000 --- a/projects/plugins/inspect/tests/action-skip-test-php.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -if php -r 'exit( version_compare( PHP_VERSION, "7.4.0", "<" ) ? 0 : 1 );'; then - echo "PHP version is too old to run tests. 7.4 is required, but $(php -r 'echo PHP_VERSION;') is installed. Skipping."; - exit 3 -fi