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

Bump WP Core version to 6.5 and 6.4.3 #155

Merged
merged 27 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
025223f
Bump WP Core version to 6.5 and 6.4.3
Apr 3, 2024
358c786
6.5.3 doesn't exist
jazzsequence Apr 3, 2024
70d8e88
add a new step that checks the latest wp version
jazzsequence Apr 3, 2024
b09f585
the current version should not be the latest
jazzsequence Apr 3, 2024
7b1c59b
use world_proc since wp isn't actually installed at behat runtime
jazzsequence Apr 3, 2024
dbf74ed
stdout isn't actually a method
jazzsequence Apr 3, 2024
e2980f2
simplify how we're invoking proc
jazzsequence Apr 3, 2024
e54475c
get stdout from the returned values
jazzsequence Apr 3, 2024
2e8072e
an array should be returned actually
jazzsequence Apr 3, 2024
c375e53
run the proc?
jazzsequence Apr 3, 2024
b1d8059
run is a method, not a property
jazzsequence Apr 3, 2024
26a86db
bump checkout version
jazzsequence Apr 3, 2024
139e219
remove the thing that's not working and replace with a long bash thing
jazzsequence Apr 3, 2024
c72f099
remove our bash thing
jazzsequence Apr 3, 2024
22ab598
store the state of wp version
jazzsequence Apr 3, 2024
c1eab79
add an exception to the stdout check
jazzsequence Apr 3, 2024
6fabb14
missing semicolon
jazzsequence Apr 3, 2024
e1c3292
fix the THEN where it should actually execute
jazzsequence Apr 3, 2024
d4a35ec
maybe force a different kind of end?
jazzsequence Apr 3, 2024
845c870
remove the exception
jazzsequence Apr 3, 2024
c6684c9
return after the check
jazzsequence Apr 3, 2024
1e6c04d
remove the check and just return
jazzsequence Apr 3, 2024
259fe4b
return after we set the wp version
jazzsequence Apr 3, 2024
6844831
that's not how check-updates works, instead return the latest version
jazzsequence Apr 3, 2024
597a6d7
move the version check to a utility function
jazzsequence Apr 3, 2024
f686069
tabs to spaces
jazzsequence Apr 3, 2024
1a10130
add error handling if the version-check api is unavailable for some r…
jazzsequence Apr 3, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
needs: [validate]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Download Phar
uses: actions/download-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
24 changes: 24 additions & 0 deletions features/bootstrap/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,3 +700,27 @@ function get_temp_dir() {

return $trailingslashit( $temp );
}

/**
* Get the latest WordPress version from the version check API endpoint.
*
* @access public
* @category System
* @throws Exception If the version check API fails to respond.
* @return string
*/
function get_wp_version() {
// Fetch the latest WordPress version info from the WordPress.org API
$url = 'https://api.wordpress.org/core/version-check/1.7/';
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved
$context = stream_context_create(['http' => ['timeout' => 5]]);
$json = file_get_contents($url, false, $context);
if ($json === false) {
throw new \Exception('Failed to fetch the latest WordPress version.');
}

$data = json_decode($json, true);

// Extract the latest version number
$latestVersion = $data['offers'][0]['current'];
return trim($latestVersion);
}
7 changes: 4 additions & 3 deletions features/general.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Feature: General tests of WP Launch Check
# This check is here to remind us to update versions when new releases are available.
Then STDOUT should contain:
"""
6.4.3
6.5
"""

When I run `wp launchcheck general`
Expand All @@ -60,8 +60,9 @@ Feature: General tests of WP Launch Check

Scenario: WordPress has a new minor version but no new major version
Given a WP install
And I run `wp core download --version=6.4 --force`
And I run `wp core download --version=6.5 --force`
And I run `wp theme activate twentytwentytwo`
And the current WP version is not the latest

When I run `wp launchcheck general`
Then STDOUT should contain:
Expand All @@ -71,7 +72,7 @@ Feature: General tests of WP Launch Check

Scenario: WordPress has a new major version but no new minor version
Given a WP install
And I run `wp core download --version=6.3.3 --force`
And I run `wp core download --version=6.4.3 --force`
And I run `wp theme activate twentytwentytwo`

When I run `wp launchcheck general`
Expand Down
21 changes: 20 additions & 1 deletion features/steps/given.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Behat\Gherkin\Node\TableNode,
WP_CLI\Process;

use function WP_CLI\Utils\get_wp_version;

$steps->Given( '/^an empty directory$/',
function ( $world ) {
$world->create_run_dir();
Expand Down Expand Up @@ -154,4 +156,21 @@ function($world) {

file_put_contents( $wp_config_path, $wp_config_code );
}
);
);

$steps->Given('/^the current WP version is not the latest$/', function ($world) {
// Use wp-cli to get the currently installed WordPress version.
$currentVersion = $world->proc('wp core version')->run();

// Normalize versions (remove new lines).
$currentVersion = trim($currentVersion->stdout);
$latestVersion = get_wp_version();

// If there's no update available or the current version is the latest, throw an exception to skip the test.
if (empty($latestVersion) || $currentVersion === $latestVersion) {
$world->isLatestWPVersion = true;
return;
}

$world->isLatestWPVersion = false;
});
5 changes: 4 additions & 1 deletion features/steps/then.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function ( $world, $return_code ) {

$steps->Then( '/^(STDOUT|STDERR) should (be|contain|not contain):$/',
function ( $world, $stream, $action, PyStringNode $expected ) {
// Conditional handling of WP version check.
if (isset($world->isLatestWPVersion) && $world->isLatestWPVersion) {
return;
}

$stream = strtolower( $stream );

Expand Down Expand Up @@ -189,4 +193,3 @@ function ( $world, $path, $type, $action, $expected = null ) {
}
}
);

Loading