Skip to content

test: verify Maven cache restoration and local .m2 overwrite in CI - #14059

Closed
lqiu96 wants to merge 7 commits into
mainfrom
test-ci-cache-overwrite
Closed

test: verify Maven cache restoration and local .m2 overwrite in CI#14059
lqiu96 wants to merge 7 commits into
mainfrom
test-ci-cache-overwrite

Conversation

@lqiu96

@lqiu96 lqiu96 commented Aug 12, 2026

Copy link
Copy Markdown
Member

Description

This is a test PR to verify that GitHub Actions:

  1. Restores the ~/.m2/repository cache.
  2. Freshly builds local modules when code changes.
  3. Physically overwrites the cached SNAPSHOT artifacts in ~/.m2/repository on the runner.

@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 optimizes the CI build and test process by defaulting unit tests to be skipped in the parent POM for GAPIC-generated clients, while explicitly enabling them in modules with handwritten tests. It also introduces a new compile job type and parallelizes Maven executions. The reviewer provided valuable feedback pointing out critical issues: changing the default Maven goal to compile in the test job completely skips test compilation and execution for the entire repository; changing mvn install to mvn test-compile in the dependency analysis script breaks local artifact resolution; defaulting skipUnitTests to true in the parent POM will silently disable tests for inheriting core modules like google-cloud-core; and using mvn compile instead of mvn test-compile in the compile job ignores test source compilation errors.

Comment thread .kokoro/build.sh Outdated
Comment thread .kokoro/dependencies.sh Outdated
Comment on lines +59 to +61
# this should run maven enforcer and compile test dependencies
mvn test-compile -B -V -ntp \
-Pquick-build -DskipTests=true -Dmaven.javadoc.skip=true -Denforcer.skip=false -T 1C

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.

high

Changing mvn install to mvn test-compile here prevents the built artifacts from being installed to the local Maven repository (~/.m2/repository). Because Maven runs are independent and do not share reactor state across separate invocations, the subsequent mvn dependency:analyze command (on line 63) will fail to resolve any inter-module dependencies within the monorepo, or it will use stale cached versions from previous runs. To ensure correct dependency resolution for independent Maven steps, the artifacts must be installed locally using mvn install (with -DskipTests=true to keep it fast).

Suggested change
# this should run maven enforcer and compile test dependencies
mvn test-compile -B -V -ntp \
-Pquick-build -DskipTests=true -Dmaven.javadoc.skip=true -Denforcer.skip=false -T 1C
# this should run maven enforcer and install dependencies to local .m2
mvn install -B -V -ntp \
-Pquick-build -DskipTests=true -Dmaven.javadoc.skip=true -Denforcer.skip=false -T 1C

Comment thread google-cloud-jar-parent/pom.xml Outdated
Comment thread .kokoro/build.sh Outdated
@lqiu96
lqiu96 force-pushed the test-ci-cache-overwrite branch from 490a637 to 0408151 Compare August 12, 2026 20:36
@lqiu96
lqiu96 marked this pull request as ready for review August 12, 2026 20:38
@lqiu96
lqiu96 requested review from a team as code owners August 12, 2026 20:38
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@lqiu96 lqiu96 closed this Aug 13, 2026
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.

1 participant