|
| 1 | +## |
| 2 | +# A reusable workflow that reads the .version-support-*.json files and returns values for use in a |
| 3 | +# test matrix based on a given WordPress version. |
| 4 | +## |
| 5 | +name: Determine test matrix values |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + wp-version: |
| 11 | + description: 'The WordPress version to test . Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".' |
| 12 | + type: string |
| 13 | + default: 'nightly' |
| 14 | + outputs: |
| 15 | + major-wp-version: |
| 16 | + description: "The major WordPress version based on the version provided in wp-version" |
| 17 | + value: ${{ jobs.major-wp-version.outputs.version }} |
| 18 | + php-versions: |
| 19 | + description: "The PHP versions to test for the given wp-version" |
| 20 | + value: ${{ jobs.php-versions.outputs.versions }} |
| 21 | + mysql-versions: |
| 22 | + description: "The MySQL versions to test for the given wp-version" |
| 23 | + value: ${{ jobs.mysql-versions.outputs.versions }} |
| 24 | + |
| 25 | +jobs: |
| 26 | + # Determines the major version of WordPress being tested. |
| 27 | + # |
| 28 | + # The data in the JSON files are indexed by major version, so this is used to look up the appropriate support policy. |
| 29 | + # |
| 30 | + # Performs the following steps: |
| 31 | + # - Checks out the repository |
| 32 | + # - Returns the major WordPress version as an output based on the value passed to the wp-version input. |
| 33 | + major-wp-version: |
| 34 | + name: Determine major WordPress version |
| 35 | + runs-on: ubuntu-latest |
| 36 | + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} |
| 37 | + timeout-minutes: 5 |
| 38 | + outputs: |
| 39 | + version: ${{ steps.major-wp-version.outputs.version }} |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 44 | + with: |
| 45 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 46 | + |
| 47 | + - name: Determine the major WordPress version |
| 48 | + id: major-wp-version |
| 49 | + run: | |
| 50 | + if [ "${{ inputs.wp-version }}" ] && [ "${{ inputs.wp-version }}" != "nightly" ] && [ "${{ inputs.wp-version }}" != "latest" ]; then |
| 51 | + echo "version=$(echo "${{ inputs.wp-version }}" | tr '.' '-' | cut -d '-' -f1-2)" >> $GITHUB_OUTPUT |
| 52 | + elif [ "${{ inputs.wp-version }}" ]; then |
| 53 | + echo "version=$(echo "${{ inputs.wp-version }}")" >> $GITHUB_OUTPUT |
| 54 | + else |
| 55 | + echo "version=nightly" >> $GITHUB_OUTPUT |
| 56 | + fi |
| 57 | +
|
| 58 | + # Determines the versions of PHP supported for a version of WordPress. |
| 59 | + # |
| 60 | + # Performs the following steps: |
| 61 | + # - Checks out the repository |
| 62 | + # - Returns the versions of PHP supported for the major version of WordPress by parsing the |
| 63 | + # .version-support-php.json file and returning the values in that version's index. |
| 64 | + php-versions: |
| 65 | + name: Determine PHP versions |
| 66 | + runs-on: ubuntu-latest |
| 67 | + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} |
| 68 | + needs: [ major-wp-version ] |
| 69 | + timeout-minutes: 5 |
| 70 | + outputs: |
| 71 | + versions: ${{ steps.php-versions.outputs.versions }} |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Checkout repository |
| 75 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 76 | + with: |
| 77 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 78 | + |
| 79 | + # Look up the major version's specific PHP support policy when a version is provided. |
| 80 | + # Otherwise, use the current PHP support policy. |
| 81 | + - name: Get supported PHP versions |
| 82 | + id: php-versions |
| 83 | + run: | |
| 84 | + if [ "${{ needs.major-wp-version.outputs.version }}" != "latest" ] && [ "${{ needs.major-wp-version.outputs.version }}" != "nightly" ]; then |
| 85 | + echo "versions=$(jq -r '.["${{ needs.major-wp-version.outputs.version }}"] | @json' .version-support-php.json)" >> $GITHUB_OUTPUT |
| 86 | + else |
| 87 | + echo "versions=$(jq -r '.[ (keys[-1]) ] | @json' .version-support-php.json)" >> $GITHUB_OUTPUT |
| 88 | + fi |
| 89 | +
|
| 90 | + # Determines the versions of MySQL supported for a version of WordPress. |
| 91 | + # |
| 92 | + # Performs the following steps: |
| 93 | + # - Checks out the repository |
| 94 | + # - Returns the versions of MySQL supported for the major version of WordPress by parsing the |
| 95 | + # .version-support-mysql.json file and returning the values in that version's index. |
| 96 | + mysql-versions: |
| 97 | + name: Determine MySQL versions |
| 98 | + runs-on: ubuntu-latest |
| 99 | + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} |
| 100 | + needs: [ major-wp-version ] |
| 101 | + timeout-minutes: 5 |
| 102 | + outputs: |
| 103 | + versions: ${{ steps.mysql-versions.outputs.versions }} |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout repository |
| 107 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 108 | + with: |
| 109 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 110 | + |
| 111 | + # Look up the major version's specific MySQL support policy when a version is provided. |
| 112 | + # Otherwise, use the current MySQL support policy. |
| 113 | + - name: Get supported MySQL versions |
| 114 | + id: mysql-versions |
| 115 | + run: | |
| 116 | + if [ "${{ needs.major-wp-version.outputs.version }}" != "latest" ] && [ "${{ needs.major-wp-version.outputs.version }}" != "nightly" ]; then |
| 117 | + echo "versions=$(jq -r '.["${{ needs.major-wp-version.outputs.version }}"] | @json' .version-support-mysql.json)" >> $GITHUB_OUTPUT |
| 118 | + else |
| 119 | + echo "versions=$(jq -r '.[ (keys[-1]) ] | @json' .version-support-mysql.json)" >> $GITHUB_OUTPUT |
| 120 | + fi |
0 commit comments