4545 if : success() || failure()
4646 run : npm run lint:pkg-json
4747
48+ compute-previous-wordpress-version :
49+ name : Compute previous WordPress version
50+ runs-on : ubuntu-latest
51+ permissions : {}
52+ outputs :
53+ previous-wordpress-version : ${{ steps.get-previous-wordpress-version.outputs.previous-wordpress-version }}
54+
55+ steps :
56+ - name : Get previous WordPress version
57+ id : get-previous-wordpress-version
58+ run : |
59+ curl \
60+ -H "Accept: application/json" \
61+ -o versions.json \
62+ "http://api.wordpress.org/core/stable-check/1.0/"
63+ LATEST_WP_VERSION="$(jq --raw-output 'with_entries(select(.value=="latest"))|keys[]' versions.json)"
64+ # shellcheck disable=SC2034
65+ IFS='.' read -r LATEST_WP_MAJOR LATEST_WP_MINOR LATEST_WP_PATCH <<< "${LATEST_WP_VERSION}"
66+ if [[ "${LATEST_WP_MINOR}" == "0" ]]; then
67+ PREVIOUS_WP_SERIES="$((LATEST_WP_MAJOR - 1)).9"
68+ else
69+ PREVIOUS_WP_SERIES="${LATEST_WP_MAJOR}.$((LATEST_WP_MINOR - 1))"
70+ fi
71+ PREVIOUS_WP_VERSION="$(jq --raw-output --arg series "${PREVIOUS_WP_SERIES}" 'with_entries(select(.key|startswith($series)))|keys[-1]' versions.json)"
72+ echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> "$GITHUB_OUTPUT"
73+ rm versions.json
74+
4875 tests :
49- name : Test Suite
76+ name : PHP ${{ matrix.php }}${{ matrix.wordpress != '' && format( ' (WP {0})', matrix.wordpress ) || '' }}
77+ needs : [compute-previous-wordpress-version]
5078 runs-on : ubuntu-latest
79+ strategy :
80+ fail-fast : false
81+ matrix :
82+ php : ['7.4', '8.0', '8.1', '8.2', '8.3']
83+ wordpress : ['', 'previous major version']
84+ env :
85+ WP_ENV_PHP_VERSION : ${{ matrix.php }}
86+ WP_ENV_CORE : ${{ matrix.wordpress == '' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', needs.compute-previous-wordpress-version.outputs.previous-wordpress-version ) }}
5187 steps :
5288 - name : Checkout
5389 uses : actions/checkout@v3
@@ -66,23 +102,24 @@ jobs:
66102 - name : Install Node Dependencies
67103 run : npm i
68104
69- - name : Compile JavaScript App
70- run : npm run build
71-
72- - name : Setup MySQL
73- if : success() || failure()
74- uses : shogo82148/actions-setup-mysql@v1
105+ - name : Set up PHP
106+ uses : shivammathur/setup-php@v2
75107 with :
76- mysql-version : ' 8.0'
108+ php-version : ' ${{ matrix.php }}'
109+ ini-file : development
110+ coverage : none
111+
112+ - name : Docker debug information
113+ run : docker -v
77114
78- - name : Run JavaScript unit tests
79- run : npm run test:unit
115+ - name : Start Docker environment
116+ run : npm run wp-env start
80117
81- - name : Install Subversion
82- run : sudo apt-get update -y && sudo apt-get install -y subversion
118+ - name : Docker container debug information
119+ run : npm run wp-env run tests-cli wp core version
120+
121+ - name : Log running Docker containers
122+ run : docker ps -a
83123
84124 - name : Run PHP tests
85- run : |
86- mysql -uroot -h127.0.0.1 -e 'SELECT version()' \
87- && ./bin/install-wp-tests.sh --wp-version=trunk --recreate-db wordpress_test root '' > /dev/null \
88- && composer run-script test
125+ run : npm run test:unit:php
0 commit comments