Skip to content

Upgrade Java matrix axes that setup-java reads through ${{ matrix.* }} - #231

Merged
jkschneider merged 1 commit into
mainfrom
setup-java-matrix-version
Oct 3, 2026
Merged

jkschneider merged 1 commit into
mainfrom
setup-java-matrix-version

Conversation

@jkschneider

Copy link
Copy Markdown
Member

SetupJavaUpgradeJavaVersion only rewrote literal java-version values, so java-version: ${{ matrix.java }} with strategy.matrix.java: [ '17' ] stayed at 17 after a Java 25 migration. Now, per job, the axes a setup-java step references through ${{ matrix.<axis> }} get their values upgraded like a literal would be, duplicates collapse ([ '11', '17' ] becomes [ '25' ]), and a matrix with include or exclude is left alone since those encode relationships between axes.

Found by a team of coding agents reviewing a Moderne run of org.openrewrite.java.migrate.UpgradeToJava25 over eight open-source repositories (run 20261003103223-WtyA8). The issue is setup-java-matrix-version in the run's io.moderne.RecipeIssues data table, and the fix was discussed and reviewed on the run's message board. A row from the table, as a generalized example:

The migration leaves the setup-java matrix at Java 17 while the build and migrated sources require Java 25. (spring-projects/spring-petclinic, .github/workflows/maven-build.yml)

Before:

strategy:
  matrix:
    java: [ '17' ]
steps:
  - uses: actions/setup-java@v4
    with:
      java-version: ${{matrix.java}}

What the recipe produced:

strategy:
  matrix:
    java: [ '17' ]
steps:
  - uses: actions/setup-java@v4
    with:
      java-version: ${{matrix.java}}

Expected:

strategy:
  matrix:
    java: [ '25' ]
steps:
  - uses: actions/setup-java@v4
    with:
      java-version: ${{matrix.java}}

@jkschneider
jkschneider merged commit a2673f6 into main Oct 3, 2026
1 check passed
@jkschneider
jkschneider deleted the setup-java-matrix-version branch October 3, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant