Skip to content

Add coverage input to reusable-testing#135

Merged
swissspidy merged 3 commits into
wp-cli:mainfrom
trepmal:add/coverage-input
Jun 10, 2025
Merged

Add coverage input to reusable-testing#135
swissspidy merged 3 commits into
wp-cli:mainfrom
trepmal:add/coverage-input

Conversation

@trepmal
Copy link
Copy Markdown
Contributor

@trepmal trepmal commented Jun 10, 2025

No description provided.

@trepmal trepmal requested a review from a team as a code owner June 10, 2025 15:55
@swissspidy
Copy link
Copy Markdown
Member

Thanks for the PR!

I think that instead of updating the conditions everywhere (which makes things complicated and easy to forget), we should just update the prepare-functional and prepare-unit steps to update the matrix accordingly. This is how we do it with minimum-wp and minimum-php already. See:

- name: Set matrix
id: set-matrix
run: |
if [[ $FILE_EXISTS == 'true' ]]; then
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
else
echo "matrix=" >> $GITHUB_OUTPUT
fi
env:
BASE_MATRIX: ${{ needs.get-matrix.outputs.matrix }}
FILE_EXISTS: ${{ steps.check_files.outputs.files_exists == 'true' }}

AI suggests something like this (untested):


jq -c \
  --argjson with_coverage_flag "${{ inputs.with-coverage }}" \
  --arg minimum_php "${{ inputs.minimum-php }}" \
  --arg minimum_wp "${{ inputs.minimum-wp }}" \
  '
  .include |= (
    map(
      # First, select only the versions that meet all minimum requirements
      select(
        (.php >= $minimum_php) and
        (.wp == "latest" or .wp >= $minimum_wp)
      ) |

      # Next, update the coverage flag on the remaining items
      if $with_coverage_flag == false and .coverage == true then
        .coverage = false
      else
        .
      end
    ) |

    # Finally, get the unique entries
    unique_by(.php)
  )
  ' <<< "$BASE_MATRIX"

@trepmal trepmal force-pushed the add/coverage-input branch from 6486a29 to 6ade809 Compare June 10, 2025 18:37
@trepmal trepmal marked this pull request as draft June 10, 2025 19:14
@trepmal trepmal marked this pull request as ready for review June 10, 2025 20:29
@trepmal
Copy link
Copy Markdown
Contributor Author

trepmal commented Jun 10, 2025

I somehow didn't realize I'd even opened this PR, but I've applied your suggestions :) Worked well for my repo https://github.com/trepmal/wp-revisions-cli/actions/runs/15569514699/workflow

@swissspidy swissspidy merged commit 0d5aa01 into wp-cli:main Jun 10, 2025
10 checks passed
@trepmal trepmal deleted the add/coverage-input branch June 10, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants