|
13 | 13 | type: string |
14 | 14 | required: false |
15 | 15 | default: '4.9' |
| 16 | + with-coverage: |
| 17 | + description: 'Include coverages tests.' |
| 18 | + type: boolean |
| 19 | + required: false |
| 20 | + default: true |
16 | 21 |
|
17 | 22 | # Cancels all previous workflow runs for the same branch that have not yet completed. |
18 | 23 | concurrency: |
@@ -222,7 +227,31 @@ jobs: |
222 | 227 | id: set-matrix |
223 | 228 | run: | |
224 | 229 | if [[ $FILE_EXISTS == 'true' ]]; then |
225 | | - echo "matrix=$(jq -c '.include |= map(with_entries(select(.key == "php", .key == "coverage"))) | .include |= map(select(.php >= "${{ inputs.minimum-php }}")) | .include |= unique_by(.php)' <<< $BASE_MATRIX)" >> $GITHUB_OUTPUT |
| 230 | + echo "matrix=$(jq -c \ |
| 231 | + --argjson with_coverage_flag "${{ inputs.with-coverage }}" \ |
| 232 | + --arg minimum_php "${{ inputs.minimum-php }}" \ |
| 233 | + --arg minimum_wp "${{ inputs.minimum-wp }}" \ |
| 234 | + ' |
| 235 | + .include |= ( |
| 236 | + map( |
| 237 | + # First, select only the versions that meet all minimum requirements |
| 238 | + select( |
| 239 | + (.php >= $minimum_php) and |
| 240 | + (.wp == "latest" or .wp >= $minimum_wp) |
| 241 | + ) | |
| 242 | +
|
| 243 | + # Next, update the coverage flag on the remaining items |
| 244 | + if $with_coverage_flag == false and .coverage == true then |
| 245 | + .coverage = false |
| 246 | + else |
| 247 | + . |
| 248 | + end |
| 249 | + ) | |
| 250 | +
|
| 251 | + # Finally, get the unique entries |
| 252 | + unique_by(.php) |
| 253 | + ) |
| 254 | + ' <<< "$BASE_MATRIX")" >> $GITHUB_OUTPUT |
226 | 255 | else |
227 | 256 | echo "matrix=" >> $GITHUB_OUTPUT |
228 | 257 | fi |
@@ -313,7 +342,35 @@ jobs: |
313 | 342 | id: set-matrix |
314 | 343 | run: | |
315 | 344 | if [[ $FILE_EXISTS == 'true' ]]; then |
316 | | - echo "matrix=$(jq -c '.include |= map(select(.wp == "4.9").wp |= "${{ inputs.minimum-wp }}") | .include |= map(select(.php >= "${{ inputs.minimum-php }}"))' <<< $BASE_MATRIX)" >> $GITHUB_OUTPUT |
| 345 | + echo "matrix=$(jq -c \ |
| 346 | + --argjson with_coverage_flag "${{ inputs.with-coverage }}" \ |
| 347 | + --arg minimum_php "${{ inputs.minimum-php }}" \ |
| 348 | + --arg minimum_wp "${{ inputs.minimum-wp }}" \ |
| 349 | + ' |
| 350 | + # First, select only the versions that meet all minimum requirements |
| 351 | + .include |= ( |
| 352 | + map( |
| 353 | + select( |
| 354 | + .php >= $minimum_php |
| 355 | + ) | |
| 356 | + # Next, update the coverage flag on the remaining items |
| 357 | + if $with_coverage_flag == false and .coverage == true then |
| 358 | + .coverage = false |
| 359 | + else |
| 360 | + . |
| 361 | + end |
| 362 | + ) |
| 363 | + ) | |
| 364 | +
|
| 365 | + # Reassign WP4.9 to minimum_wp |
| 366 | + .include |= ( |
| 367 | + map( |
| 368 | + select( |
| 369 | + .wp == "4.9" |
| 370 | + ).wp |= $minimum_wp |
| 371 | + ) |
| 372 | + ) |
| 373 | + ' <<< "$BASE_MATRIX" )" >> $GITHUB_OUTPUT |
317 | 374 | else |
318 | 375 | echo "matrix=" >> $GITHUB_OUTPUT |
319 | 376 | fi |
|
0 commit comments