Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Try computing previous WordPress version
  • Loading branch information
ockham committed Apr 4, 2023
commit 62e4dc13000472aa11dd9340dffaca9ca6b1e767
30 changes: 28 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,34 @@ jobs:
- name: Running the date tests
run: npm run test:unit:date -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache"

compute-previous-wordpress-version:
name: Compute previous WordPress version
runs-on: ubuntu-latest
outputs:
previous-wordpress-version: ${{ steps.get-previous-wordpress-version.outputs.previous-wordpress-version }}

steps:
- name: Get previous WordPress version
id: get-previous-wordpress-version
run: |
curl \
-H "Accept: application/json" \
-o versions.json \
"http://api.wordpress.org/core/stable-check/1.0/"
LATEST_WP_VERSION=$(jq --raw-output 'with_entries(select(.value=="latest"))|keys[]' versions.json)
IFS='.' read LATEST_WP_MAJOR LATEST_WP_MINOR LATEST_WP_PATCH <<< "${LATEST_WP_VERSION}"
if [[ ${LATEST_WP_MINOR} == "0" ]]; then
PREVIOUS_WP_SERIES="$((LATEST_WP_MAJOR - 1)).9"
else
PREVIOUS_WP_SERIES="${LATEST_WP_MAJOR}.$((LATEST_WP_MINOR - 1))"
fi
PREVIOUS_WP_VERSION=$(jq --raw-output --arg series "${PREVIOUS_WP_SERIES}" 'with_entries(select(.key|startswith($series)))|keys[-1]' versions.json)
echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> $GITHUB_OUTPUT
rm versions.json

test-php:
name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.wordpress != '' && format( ' (WP {0}) ', matrix.wordpress ) || '' }} on ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

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

A problem with having the WordPress version in the name is that each time the version changes, someone has to update the required jobs in the repo settings. This slack thread discusses a situation where it happened today:
https://wordpress.slack.com/archives/C02QB2JS7/p1719295939361199

It'd be good to think about possible solutions to this. Only including the major version number (e.g. 6.4.x) might be one option.

needs: compute-previous-wordpress-version
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
Expand All @@ -73,11 +99,11 @@ jobs:
include:
# Test with the previous WP version.
- php: '7.4'
wordpress: '6.0'
wordpress: ${{ needs.compute-previous-wordpress-version.outputs.previous-wordpress-version }}

env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: WordPress/WordPress${{ matrix.wordpress != '' && format( '#{0}-branch', matrix.wordpress ) || '' }}
WP_ENV_CORE: ${{ matrix.wordpress == '' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-#{0}.zip', matrix.wordpress ) }}

steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
Expand Down