Skip to content

Commit

Permalink
Try computing previous WordPress version
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Mar 22, 2023
1 parent 2dff77a commit bebcc0e
Showing 1 changed file with 28 additions and 2 deletions.
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
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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
Expand Down

0 comments on commit bebcc0e

Please sign in to comment.