Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions dev-tools/tests/gradle-dependency-recovery-contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,78 @@ assert_call 2 "--refresh-dependencies --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2
assert_output_contains "Configuration cache state could not be cached: field \`classpath\` of \`org.gradle.process.internal.DefaultJavaExecSpec_Decorated\`"
assert_output_contains "refreshed-captured-jooq-resolution"

# Gradle 9.9 can fail before source compilation while resolving inputs for the
# protobuf plugin's registered extraction task or while serializing a forked
# compiler's annotation processor path. Both shapes refresh once only when
# task, module, and configuration agree.
new_case protobuf-include-proto-resolution
cat > "$CASE_DIR/cause.log" <<'LOG'
> Task :account-service:extractIncludeProto
> Task :account-service:extractIncludeProto FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':account-service:extractIncludeProto' (registered by plugin 'com.google.protobuf').
> Could not resolve all files for configuration ':account-service:compileProtoPath'.
> Could not find lombok-1.18.48.jar (org.projectlombok:lombok:1.18.48).
Searched in the following locations:
https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.48/lombok-1.18.48.jar
* Try:
> Run with --stacktrace option to get the stack trace.
LOG
# shellcheck disable=SC2016
write_wrapper 'if [[ "$call_count" -eq 1 ]]; then cat "$CASE_DIR/cause.log"; exit 1; fi; echo refreshed-protobuf-include-proto; exit 0'
run_case account-service 0
assert_call_count 2
assert_call 2 "--refresh-dependencies --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8 :account-service:check -PfullCheck --profile --info --console=plain"
assert_output_contains "registered by plugin 'com.google.protobuf'"
assert_output_contains "refreshed-protobuf-include-proto"

new_case annotation-processor-path-resolution
cat > "$CASE_DIR/cause.log" <<'LOG'
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache state could not be cached: field `annotationProcessorPath` of `org.gradle.api.tasks.compile.CompileOptions_Decorated` bean found in captured state from method `org.gradle.api.internal.tasks.compile.CompilerForkUtils.doNotCacheIfForkingViaExecutable$f0a6ff5d` of lambda of type `org.gradle.api.internal.lambdas.SerializableLambdas$SerializableSpec` returning `boolean` found in field `spec` of `org.gradle.api.internal.tasks.execution.SelfDescribingSpec` bean found in doNotCacheIf specs of task `:common-platform-core:compileJava` of type `org.gradle.api.tasks.compile.JavaCompile`: error writing value of type 'org.gradle.api.internal.artifacts.configurations.DefaultLegacyConfiguration'
> Could not resolve all files for configuration ':common-platform-core:annotationProcessor'.
> Could not find lombok-1.18.48.jar (org.projectlombok:lombok:1.18.48).
Searched in the following locations:
https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.48/lombok-1.18.48.jar
* Try:
> Run with --stacktrace option to get the stack trace.
LOG
# shellcheck disable=SC2016
write_wrapper 'if [[ "$call_count" -eq 1 ]]; then cat "$CASE_DIR/cause.log"; exit 1; fi; echo refreshed-annotation-processors; exit 0'
run_case common-platform-core 0
assert_call_count 2
assert_call 2 "--refresh-dependencies --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8 :common-platform-core:check -PfullCheck --profile --info --console=plain"
assert_output_contains "field \`annotationProcessorPath\`"
assert_output_contains "refreshed-annotation-processors"

# Mismatched ownership, configuration, or another fatal cause must not retry.
for mutation in wrong-module wrong-configuration extra-cause compile-started; do
new_case "protobuf-resolution-invalid-$mutation"
cat > "$CASE_DIR/cause.log" <<'LOG'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':account-service:extractIncludeProto' (registered by plugin 'com.google.protobuf').
> Could not resolve all files for configuration ':account-service:compileProtoPath'.
> Could not find lombok-1.18.48.jar (org.projectlombok:lombok:1.18.48).
Searched in the following locations:
https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.48/lombok-1.18.48.jar
* Try:
> Run with --stacktrace option to get the stack trace.
LOG
case "$mutation" in
wrong-module) sed -i 's/:account-service:extractIncludeProto/:world-management-service:extractIncludeProto/' "$CASE_DIR/cause.log" ;;
wrong-configuration) sed -i 's/:account-service:compileProtoPath/:account-service:runtimeClasspath/' "$CASE_DIR/cause.log" ;;
extra-cause) sed -i '/Could not resolve all files/a > Could not create task :unrelated:check due to invalid configuration.' "$CASE_DIR/cause.log" ;;
compile-started) sed -i '1i > Task :account-service:compileJava FAILED' "$CASE_DIR/cause.log" ;;
esac
# shellcheck disable=SC2016
write_wrapper 'cat "$CASE_DIR/cause.log"; exit 1'
run_case account-service 1
assert_no_retry
done

# PR 3252 retained a protoc connect timeout under a disabled MavenRepo and
# the existing pre-execution jOOQ configuration-cache wrapper.
write_jooq_protoc_timeout_cause() {
Expand Down Expand Up @@ -396,6 +468,45 @@ assert_call 2 "--refresh-dependencies --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2
assert_output_contains "Connect timed out"
assert_output_contains "refreshed-captured-jooq-resolution"

write_jooq_handshake_cause() {
cat > "$CASE_DIR/jooq-cause.log" <<'LOG'
FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache state could not be cached: field `classpath` of `org.gradle.process.internal.DefaultJavaExecSpec_Decorated` bean found in field `javaExecSpec` of task `:entity-management-service:generateJooq` of type `org.gradle.api.tasks.JavaExec`: error writing value of type 'org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection'
> Could not resolve all files for configuration ':entity-management-service:jooqCodegen'.
> Could not download jooq-codegen-3.21.9.jar (org.jooq:jooq-codegen:3.21.9)
> Could not get resource 'https://repo.maven.apache.org/maven2/org/jooq/jooq-codegen/3.21.9/jooq-codegen-3.21.9.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/jooq/jooq-codegen/3.21.9/jooq-codegen-3.21.9.jar'.
> The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. For more on this, please refer to https://docs.gradle.org/9.9.0/userguide/build_environment.html#sec:gradle_system_properties in the Gradle documentation.
> Remote host terminated the handshake
* Try:
> Run with --stacktrace option to get the stack trace.
LOG
}

new_case captured-jooq-maven-handshake
write_jooq_handshake_cause
write_jooq_wrapper ''
run_case game-session-service 0
assert_call_count 2
assert_call 2 "--refresh-dependencies --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8 :game-session-service:check -PfullCheck --profile --info --console=plain"
[[ "$(cat "$CASE_DIR/sleeps")" == 2 ]] || fail "Maven handshake closure did not use one short delay"

for mutation in wrong-host certificate-error generation-started; do
new_case "jooq-maven-handshake-invalid-$mutation"
write_jooq_handshake_cause
progress_line=""
case "$mutation" in
wrong-host) sed -i 's/repo.maven.apache.org/other.example.org/g' "$CASE_DIR/jooq-cause.log" ;;
certificate-error) sed -i 's/Remote host terminated the handshake/PKIX path building failed/' "$CASE_DIR/jooq-cause.log" ;;
generation-started) progress_line='> Task :entity-management-service:generateJooq' ;;
esac
write_jooq_wrapper "$progress_line"
run_case game-session-service 1
assert_no_retry
done

for mutation in repository configuration pin url host cache-family mixed unknown; do
new_case "protoc-timeout-invalid-$mutation"
write_jooq_protoc_timeout_cause
Expand Down
66 changes: 62 additions & 4 deletions dev-tools/validation/run-gradle-with-dependency-recovery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ classify_failure_body() {
transient++
next
}
if (line ~ /^> Could not download jooq-codegen-[0-9][[:alnum:]_.-]*\.jar \(org\.jooq:jooq-codegen:[0-9][[:alnum:]_.-]*\)$/) {
version = line
sub(/^.*\(org\.jooq:jooq-codegen:/, "", version)
sub(/\)$/, "", version)
if (line != "> Could not download jooq-codegen-" version ".jar (org.jooq:jooq-codegen:" version ")") invalid++
jooq_jar_url = "https://repo.maven.apache.org/maven2/org/jooq/jooq-codegen/" version "/jooq-codegen-" version ".jar"
jooq_jar_downloads++
coordinates++
next
}
if (line ~ /^> The server may not support the client\047s requested TLS protocol versions: \(TLSv1\.2, TLSv1\.3\)\. You may need to configure the client to allow other protocols to be used\. For more on this, please refer to https:\/\/docs\.gradle\.org\/9\.[0-9]+\.[0-9]+\/userguide\/build_environment\.html#sec:gradle_system_properties in the Gradle documentation\.$/) {
jooq_tls_context++
next
}
if (line == "> Remote host terminated the handshake") {
jooq_tls_terminated++
transient++
next
}

if (line == "1 problem was found storing the configuration cache.") {
cache_summary++
Expand Down Expand Up @@ -218,6 +237,27 @@ classify_failure_body() {
jooq_execution_causes++
next
}
# Gradle 9.9 can resolve annotation processors while serializing the
# compiler-fork predicate, before it starts the Java compile task.
if (line ~ /^Configuration cache state could not be cached: field `annotationProcessorPath` of `org\.gradle\.api\.tasks\.compile\.CompileOptions_Decorated` bean found in captured state from method `org\.gradle\.api\.internal\.tasks\.compile\.CompilerForkUtils\.doNotCacheIfForkingViaExecutable\$[[:xdigit:]]+` of lambda of type `org\.gradle\.api\.internal\.lambdas\.SerializableLambdas\$SerializableSpec` returning `boolean` found in field `spec` of `org\.gradle\.api\.internal\.tasks\.execution\.SelfDescribingSpec` bean found in doNotCacheIf specs of task `:[[:alnum:]-]+:compileJava` of type `org\.gradle\.api\.tasks\.compile\.JavaCompile`: error writing value of type \047org\.gradle\.api\.internal\.artifacts\.configurations\.DefaultLegacyConfiguration\047$/) {
module = line
sub(/^.* specs of task `/, "", module)
sub(/:compileJava`.*$/, "", module)
expected_wrapped_configuration = module ":annotationProcessor"
wrapped_resolution_causes++
wrapped_cache_cause = 1
cache_cause++
next
}
# Protobuf extracts dependency protos before generation or compilation.
if (line ~ /^Execution failed for task \047:[[:alnum:]-]+:extractIncludeProto\047 \(registered by plugin \047com\.google\.protobuf\047\)\.$/) {
module = line
sub(/^Execution failed for task \047/, "", module)
sub(/:extractIncludeProto\047.*$/, "", module)
expected_wrapped_configuration = module ":compileProtoPath"
wrapped_resolution_causes++
next
}
if (line ~ /^Configuration cache state could not be cached: field `classpath` of task `:[^`]+:compile[A-Za-z0-9]+` of type .*JavaCompile.*: error writing value of type .*DefaultResolvableConfiguration/ ||
line ~ /^- Task `:[^`]+:compile[A-Za-z0-9]+` of type .*JavaCompile.*: error writing value of type .*DefaultResolvableConfiguration/) {
if (match(line, /`:[^`]+:compile[A-Za-z0-9]+`/)) {
Expand All @@ -239,7 +279,7 @@ classify_failure_body() {
line == ("> If the artifact you are trying to retrieve can be found in the repository but without metadata in " quote "Maven POM" quote " format, you need to adjust the " quote "metadataSources { ... }" quote " of the repository declaration.") ||
line == "Deprecated Gradle features were used in this build, making it incompatible with Gradle 10." ||
line == "You can use \047--warning-mode all\047 to show the individual deprecation warnings and determine if they come from your own scripts or plugins." ||
line == "For more on this, please refer to https://docs.gradle.org/9.8.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation." ||
line ~ /^For more on this, please refer to https:\/\/docs\.gradle\.org\/[0-9]+\.[0-9]+\.[0-9]+\/userguide\/command_line_interface\.html#sec:command_line_warnings in the Gradle documentation\.$/ ||
line ~ /^[0-9]+ actionable tasks: [0-9]+ executed, [0-9]+ from cache$/) {
next
}
Expand All @@ -256,6 +296,7 @@ classify_failure_body() {
if (substr(configuration_name, 1, 1) == quote) {
configuration_name = substr(configuration_name, 2, length(configuration_name) - 2)
}
resolved_configuration = configuration_name
if (configuration_name == "classpath") buildsrc_classpath++
if (configuration_name ~ /^:[[:alnum:]-]+:jooqCodegen$/) {
jooq_codegen_roots++
Expand Down Expand Up @@ -289,6 +330,10 @@ classify_failure_body() {
if (line == "> Could not get resource " quote protoc_pom_url quote ".") protoc_pom_resource++
if (line == "> Could not GET " quote protoc_pom_url quote ".") protoc_pom_get++
}
if (jooq_jar_url != "") {
if (line == "> Could not get resource " quote jooq_jar_url quote ".") jooq_jar_resource++
if (line == "> Could not GET " quote jooq_jar_url quote ".") jooq_jar_get++
}
repository_requests++
next
}
Expand Down Expand Up @@ -330,12 +375,22 @@ classify_failure_body() {
protoc_coordinates != 1 || protoc_pom_resource != 1 || protoc_pom_get != 1 ||
coordinates != 2 || repository_requests != 2 || searched ||
jooq_wrapper_causes != 1)) ||
((jooq_jar_downloads || jooq_tls_context || jooq_tls_terminated) &&
(jooq_jar_downloads != 1 || jooq_tls_context != 1 || jooq_tls_terminated != 1 ||
jooq_jar_resource != 1 || jooq_jar_get != 1 ||
coordinates != 1 || repository_requests != 2 || searched ||
jooq_wrapper_causes != 1)) ||
((buildsrc_configuration || buildsrc_context || buildsrc_repository || buildsrc_pom || buildsrc_http_429) &&
(buildsrc_configuration != 1 || buildsrc_context == 0 ||
resolver_roots != 1 || buildsrc_classpath != 1 || buildsrc_http_429 == 0 ||
cache_cause || compile_task_failure || searched)) ||
(cache_summary && (cache_cause == 0 || cache_cause > 2)) ||
(compile_task_failure && compile_classpath_roots == 0) ||
(wrapped_resolution_causes &&
(wrapped_resolution_causes != 1 || resolver_roots != 1 ||
expected_wrapped_configuration != resolved_configuration ||
cache_cause != wrapped_cache_cause || compile_task_failure ||
jooq_wrapper_causes || jooq_execution_causes)) ||
(jooq_wrapper_causes &&
(jooq_wrapper_causes != 1 || jooq_codegen_roots != 1 || resolver_roots != 1 ||
cache_cause != 1 || jooq_execution_causes || jooq_module == "" || jooq_root_module != jooq_module)) ||
Expand All @@ -346,6 +401,7 @@ classify_failure_body() {
!((transient && repository_requests) || (searched && repository_urls))) {
exit 1
}
if (wrapped_resolution_causes) print "before-compile"
exit 0
}
' "$log_path"
Expand All @@ -354,14 +410,15 @@ classify_failure_body() {
is_dependency_resolution_failure() {
local log_path="$1"
local body_path
local resolution_boundary
local substantive_status=0

body_path="$(mktemp "${TEMP_DIR%/}/failure-body.XXXXXX")" || return 1
if ! failure_body "$log_path" > "$body_path"; then
rm -f -- "$body_path"
return 1
fi
if ! classify_failure_body "$body_path"; then
if ! resolution_boundary="$(classify_failure_body "$body_path")"; then
rm -f -- "$body_path"
return 1
fi
Expand Down Expand Up @@ -428,7 +485,8 @@ is_dependency_resolution_failure() {
rm -f -- "$body_path"
case "$substantive_status" in
0) return 1 ;;
1|2) return 0 ;;
1) return 0 ;;
2) [[ "$resolution_boundary" != before-compile ]] ;;
*) return 1 ;;
esac
}
Expand All @@ -440,7 +498,7 @@ retry_delay_seconds() {

retry_after="$(failure_body "$log_path" | sed -nE 's/^.*[Rr]etry-[Aa]fter:[[:space:]]*(.*)$/\1/p')" || return 1
if [[ -z "$retry_after" ]]; then
if failure_body "$log_path" | grep -Eq 'Connection reset|Connection timed out|Connect timed out|SocketTimeoutException|Received status code 429 from server|Received status code 5[0-9][0-9] from server'; then
if failure_body "$log_path" | grep -Eq 'Connection reset|Connection timed out|Connect timed out|SocketTimeoutException|Remote host terminated the handshake|Received status code 429 from server|Received status code 5[0-9][0-9] from server'; then
printf '2\n'
else
printf '0\n'
Expand Down
Loading