Skip to content

ci: split enforcer into fast PR metadata check and release banDuplicateClasses check - #14142

Merged
lqiu96 merged 5 commits into
googleapis:mainfrom
lqiu96:optimize_enforcer_job_runtime
Aug 27, 2026
Merged

ci: split enforcer into fast PR metadata check and release banDuplicateClasses check#14142
lqiu96 merged 5 commits into
googleapis:mainfrom
lqiu96:optimize_enforcer_job_runtime

Conversation

@lqiu96

@lqiu96 lqiu96 commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Separates the Maven Enforcer configuration into two distinct executions:

  1. enforce (Fast Metadata Checks): Checks requireUpperBoundDeps, requireMavenVersion, and requireJavaVersion. Runs on every PR directly in memory (~15s) without needing a full-repo build.
  2. enforce-banned-duplicate-classes (Bytecode Scanner): Checks banDuplicateClasses. Runs only on Release-Please (non-SNAPSHOT) PRs after compiling and installing all module JARs to disk.

Key Changes

  • java-shared-config/pom.xml:
    • Separated <id>enforce</id> into fast metadata rules (requireUpperBoundDeps, requireMavenVersion: [3.8.0,), requireJavaVersion: [1.8,)).
    • Added <id>enforce-banned-duplicate-classes</id> execution containing the <banDuplicateClasses> rule.
  • .github/workflows/ci.yaml:
    • enforcer job: Runs on every PR using mvn -B -ntp enforcer:enforce@enforce -T 1C (executes in ~15 seconds across all modules without pre-installing JARs).
    • ban-duplicate-classes job: Runs on Release-Please PRs (release-please--branches--main non-SNAPSHOT) with the full JOB_TYPE: install step followed by mvn -B -ntp enforcer:enforce@enforce-banned-duplicate-classes -T 1C.
  • grpc-gcp-java:
    • Updated parent POM to inherit the local google-cloud-shared-config:1.21.0-SNAPSHOT parent via relative path and Release-Please tracking comment (<!-- {x-version-update:google-cloud-shared-config:current} -->), directly inheriting the split enforcer configuration.
  • google-auth-library-java:
    • Added temporary enforcer configuration overrides with <rules combine.self="override"> to prevent running the old banDuplicateClasses rule inherited from the remote google-cloud-shared-config:1.17.0 release artifact.
    • Note: These overrides are temporary until the new version of google-cloud-shared-config is published to Maven Central, at which point the parent version will be bumped and the overrides removed.
  • java-samples:
    • Added <enforcer.skip>true</enforcer.skip> to sample parent POM.

Benefits

  • Fast PR Turnaround: Developers get immediate feedback on dependency convergence (requireUpperBoundDeps) and tool versions in ~15 seconds rather than waiting 20+ minutes.
  • Full Classpath Safety: Releases remain protected against duplicate class conflicts (JAR hell) via banDuplicateClasses before publishing.

@lqiu96
lqiu96 requested review from a team as code owners August 20, 2026 01:26

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request configures java-samples to skip the enforcer plugin, updates the minimum Maven and Java version requirements in the shared configuration, and removes the banDuplicateClasses rule. The reviewer noted that removing the banDuplicateClasses rule completely exposes downstream projects to classpath conflicts and suggested instead moving it to a separate profile or execution phase to maintain protection without slowing down PR checks.

I am having trouble creating individual review comments. Click here to see my feedback.

java-shared-config/java-shared-config/pom.xml (257-264)

medium

Removing the banDuplicateClasses rule entirely from the shared configuration eliminates protection against classpath conflicts (JAR hell) for all downstream projects inheriting this configuration. While this significantly speeds up the CI enforcer job by avoiding bytecode inspection of compiled dependencies, completely disabling this check increases the risk of duplicate classes causing runtime issues (such as LinkageError or NoSuchMethodError).

Consider keeping this rule but binding it to a separate execution or a profile (e.g., activated only during release or packaging phases) so that it doesn't block fast PR checks but still runs before releases.

@lqiu96
lqiu96 marked this pull request as draft August 20, 2026 01:31
- Update enforcer job in ci.yaml to run only when PR is raised from release-please--branches--main and title does not end with SNAPSHOT
- Skips enforcer check on standard feature/bugfix PRs to eliminate 20+ minute CI turnaround time
@lqiu96
lqiu96 force-pushed the optimize_enforcer_job_runtime branch from 9a15d11 to 82fc824 Compare August 27, 2026 15:09
@lqiu96 lqiu96 changed the title ci: streamline enforcer job and update version requirements ci: run enforcer check only on release-please PRs Aug 27, 2026
…teClasses check

- Split enforcer plugin executions into enforce (requireUpperBoundDeps, requireMavenVersion, requireJavaVersion) and enforce-banned-duplicate-classes (banDuplicateClasses)
- Run fast in-memory enforcer checks on every PR without full-repo build (~15s runtime)
- Scope bytecode-level banDuplicateClasses check to release-please PRs with pre-installed module JARs
- Configure enforcer overrides in google-auth-library-java and grpc-gcp-java
@lqiu96 lqiu96 changed the title ci: run enforcer check only on release-please PRs ci: split enforcer into fast PR metadata check and release banDuplicateClasses check Aug 27, 2026
Comment thread grpc-gcp-java/pom.xml Outdated
</extension>
</extensions>
<plugins>
<!-- Temporary enforcer configuration override until a new version of google-cloud-shared-config is released to Maven Central.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is probably a separate issue. java-shared-config is in the same repo now, other modules should be able to use the SNAPSHOT version of java-shared-config.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From an older change:

<!-- Do not depend on the version in this monorepo. It causes the publication order problem. -->
as part of monorepo migration.

I think this probably requires a bit larger of an effort the fix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see. Auth makes sense because it needs to be published first and its group id com.google.auth is different from shared-config's group id com.google.cloud. But we can probably change grpc-gcp to use snapshot version of shared-config because it has the same group id.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated

@lqiu96
lqiu96 marked this pull request as ready for review August 27, 2026 17:08
@lqiu96
lqiu96 requested review from a team as code owners August 27, 2026 17:08
@lqiu96
lqiu96 enabled auto-merge (squash) August 27, 2026 17:38
@lqiu96
lqiu96 merged commit 4d93800 into googleapis:main Aug 27, 2026
352 of 360 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