Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically create test matrix, take 2 #87

Merged
merged 2 commits into from
Nov 2, 2023
Merged

Conversation

swissspidy
Copy link
Member

@swissspidy swissspidy commented Nov 2, 2023

Brings the matrix inline into the workflow instead of fetching it remotely from the repository.

Downside: No syntax highlighting
Upside: No need for a curl call; matrix is closer to the workflow, making it easier to grasp

Successfully tested by running this both correctly against this branch as well over at this repo


This is the second attempt at #78

The original description is below:

How it works:

Two new jobs are added to prepare the test matrix for the actual test jobs.

The full matrix is now in a JSON string. Is then processed by jq to filter out entries where the PHP version is below minimum-php. The test jobs then use this filtered matrix with fromJson

This way we avoid unused containers from being created.

Also excludes testing.yml from syncing.

Example:

The final matrix for the unit tests will look something like this for minimum-php = 7.0:

{"include":[{"php":"7.0"},{"php":"7.0"},{"php":"7.1"},{"php":"7.1"},{"php":"7.2"},{"php":"7.2"},{"php":"7.3"},{"php":"7.3"},{"php":"7.4"},{"php":"7.4"},{"php":"8.0"},{"php":"8.0"},{"php":"8.1"},{"php":"8.1"},{"php":"8.2"},{"php":"8.2"},{"php":"7.0"},{"php":"7.0"},{"php":"7.0"},{"php":"7.4"},{"php":"8.0"},{"php":"8.0"},{"php":"8.0"},{"php":"8.1"},{"php":"8.2"},{"php":"8.3"},{"php":"8.2"}]}

For the functional tests there are of course a few more keys:

{"include":[{"php":"7.0","wp":"latest","mysql":"8.0"},{"php":"7.0","wp":"latest","dbtype":"sqlite"},{"php":"7.1","wp":"latest","mysql":"8.0"},{"php":"7.1","wp":"latest","dbtype":"sqlite"},{"php":"7.2","wp":"latest","mysql":"8.0"},{"php":"7.2","wp":"latest","dbtype":"sqlite"},{"php":"7.3","wp":"latest","mysql":"8.0"},{"php":"7.3","wp":"latest","dbtype":"sqlite"},{"php":"7.4","wp":"latest","mysql":"8.0"},{"php":"7.4","wp":"latest","dbtype":"sqlite"},{"php":"8.0","wp":"latest","mysql":"8.0"},{"php":"8.0","wp":"latest","dbtype":"sqlite"},{"php":"8.1","wp":"latest","mysql":"8.0"},{"php":"8.1","wp":"latest","dbtype":"sqlite"},{"php":"8.2","wp":"latest","mysql":"8.0"},{"php":"8.2","wp":"latest","dbtype":"sqlite"},{"php":"7.0","wp":"trunk","mysql":"8.0"},{"php":"7.0","wp":"trunk","mysql":"5.7"},{"php":"7.0","wp":"trunk","mysql":"5.6"},{"php":"7.4","wp":"trunk","mysql":"8.0"},{"php":"8.0","wp":"trunk","mysql":"8.0"},{"php":"8.0","wp":"trunk","mysql":"5.7"},{"php":"8.0","wp":"trunk","mysql":"5.6"},{"php":"8.1","wp":"trunk","mysql":"8.0"},{"php":"8.2","wp":"trunk","mysql":"8.0"},{"php":"8.3","wp":"trunk","mysql":"8.0"},{"php":"8.2","wp":"trunk","dbtype":"sqlite"},{"php":"8.3","wp":"trunk","dbtype":"sqlite"}]}

Note I'm not super familiar with jq, so these commands can probably be improved.

Aside: I also snuck a PHP 8.3 + WP trunk + SQLite test in there, which we previously didn't have.

Brings the matrix inline into the workflow instead of fetching it remotely from the repository.
@swissspidy swissspidy marked this pull request as ready for review November 2, 2023 08:33
@swissspidy swissspidy requested a review from a team as a code owner November 2, 2023 08:33
@swissspidy
Copy link
Member Author

cc @BrianHenryIE

@BrianHenryIE
Copy link
Member

Looks to be working as expected in my dist-archive command fork:
https://github.com/BrianHenryIE/dist-archive-command/actions/runs/6738020356/workflow

With PHP 7.1:

jobs:
  test:
    uses: wp-cli/.github/.github/workflows/reusable-testing.yml@separate-matrix-v2
    with:
      minimum-php: 7.1
Screenshot 2023-11-02 at 1 43 21 PM Screenshot 2023-11-02 at 1 44 06 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants