Skip to content

Conversation

@galesky-a
Copy link
Contributor

@galesky-a galesky-a commented Jan 9, 2026

Summary

Running formatting after generation makes calculating diff impossible. This is the current flow:

1. Generate
2. If diff, Create PR
3. Format

Because (3) happens after (2), the next time generation runs it will compare formatted with raw, meaning there will always be a delta

This PR fixes this by making sure formatting happens before the diff is calculated.

It's done by invoking a composable action on each lang's repos. I've already moved the format action in java to this setup and will proceed with the same for the other languages.

Tested scenarios

  • Tested by creating a checkpoint commit that only created one PR on the Java Repo. See the PR here and the checkpoint here.

@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

Adds a formatting step to the Java code generation workflow.

This runs 'mvn spotless:apply' after code generation to ensure that generated code is formatted correctly before a pull request is created. This prevents creating pull requests that only contain formatting changes, which can happen when the code generation output doesn't perfectly match the project's style guidelines.
Refactors the code generation workflow to use a composite action for formatting.

This new approach modularizes the formatting step by allowing each library to define its own formatting action. The main workflow calls this action, checks for diffs, and then creates a pull request.

This change is initially applied to the Java `generate-per-service` job. The workflow now dynamically checks for the existence of the format action, making the pattern extensible to other languages in the future.
Updates the `generate-per-service` job to facilitate testing the new composite formatting action for Java.

The changes include:
- Pointing to a specific feature branch in the Java library repository to get the new formatter.
- Reducing the service matrix to a single service (`checkout`) to speed up test runs.
- Prefixing the PR branch and title with a test identifier to avoid conflicts.
The GitHub Actions workflow was failing with an "Unrecognized named-value: 'matrix'" error. This was caused by `if` conditions and other expressions referencing values that were not part of the matrix definition for a specific job.

This commit corrects the conditions to be specific to each job's matrix, resolving the validation error.
Implements a "move and use" strategy to dynamically run language-specific formatting actions from within a matrix job.

This works around a GitHub Actions limitation that prevents using matrix variables in the path of a local 'uses:' clause. The new approach moves the composite action from the checked-out SDK repository to a temporary static path, allowing it to be called correctly.
@galesky-a galesky-a force-pushed the fix/java-format-in-ci branch from 448c970 to 9062493 Compare January 12, 2026 13:01
@galesky-a galesky-a marked this pull request as ready for review January 12, 2026 13:07
@galesky-a galesky-a requested review from a team as code owners January 12, 2026 13:08
Copy link
Contributor

@gcatanese gcatanese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I left one minor question

@galesky-a galesky-a merged commit f909e8c into main Jan 12, 2026
3 checks passed
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