Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use --experiment-run-id argument when calling summary tool #817

Merged
merged 3 commits into from
Apr 11, 2025
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
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ repositories {
}
}
mavenCentral()

}

val isDevelopmentRelease = !hasProperty("finalRelease")
val releaseVersion = releaseVersion()
val releaseNotes = releaseNotes()
val distributionVersion = distributionVersion()
val buildScanSummaryVersion = "1.0.4-2024.1"
val buildScanSummaryVersion = "1.0.5-2024.1"

allprojects {
version = releaseVersion.get()
Expand Down
567 changes: 3 additions & 564 deletions components/licenses/NOTICE

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions components/scripts/gradle/01-validate-incremental-building.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ execute() {
rename_project_dir "build_${project_name}" "second-build_${project_name}"

print_bl
fetch_build_cache_metrics
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -109,7 +109,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
fetch_build_cache_metrics
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -139,8 +139,8 @@ print_gradle_command() {
info "./gradlew --no-build-cache -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} -Dpts.enabled=false $*$(print_extra_args)"
}

fetch_build_cache_metrics() {
process_build_scan_data_online
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID"
}

# Overrides summary.sh#print_performance_characteristics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ execute() {
rename_project_dir "build_${project_name}" "second-build_${project_name}"

print_bl
fetch_build_cache_metrics
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -111,7 +111,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
fetch_build_cache_metrics
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -144,8 +144,8 @@ print_gradle_command() {
info "./gradlew --build-cache -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} -Dpts.enabled=false clean ${tasks}$(print_extra_args)"
}

fetch_build_cache_metrics() {
process_build_scan_data_online
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID"
}

print_introduction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ execute() {
execute_second_build

print_bl
fetch_build_cache_metrics
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -115,7 +115,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
fetch_build_cache_metrics
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -149,8 +149,8 @@ print_gradle_command() {
info "./gradlew --build-cache -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} -Dpts.enabled=false clean ${tasks}$(print_extra_args)"
}

fetch_build_cache_metrics() {
process_build_scan_data_online
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID"
}

print_introduction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ main() {
}

execute() {
fetch_build_scans
process_build_scan_data
make_experiment_dir

print_bl
Expand Down Expand Up @@ -91,7 +91,7 @@ wizard_execute() {
explain_command_to_repeat_experiment_after_collecting_parameters

print_bl
fetch_build_scans
process_build_scan_data
make_experiment_dir

print_bl
Expand All @@ -116,8 +116,8 @@ validate_required_args() {
fi
}

fetch_build_scans() {
fetch_build_scans_and_build_time_metrics 'verbose_logging' "${build_scan_urls[@]}"
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_VERBOSE" "$RUN_ID_NONE"
}

# Overrides summary.sh#print_experiment_specific_summary_info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ execute() {
execute_build

print_bl
process_build_scan_data_online
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -130,7 +130,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
process_build_scan_data_online
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -224,6 +224,10 @@ execute_build() {
invoke_gradle 1 "${args[@]}"
}

process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID_NONE"
}

# Overrides summary.sh#print_experiment_specific_summary_info
print_experiment_specific_summary_info() {
summary_row "Custom value mapping file:" "${mapping_file:-<none>}"
Expand Down
65 changes: 38 additions & 27 deletions components/scripts/lib/build-scan-online.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
#!/usr/bin/env bash

# This is a helper function for the common pattern of reading Build Scan metadata
# from the build-scans.csv file, then retrieving build metrics using the
# Develocity API.
readonly LOGGING_BRIEF='brief_logging'
readonly LOGGING_VERBOSE='verbose_logging'
readonly RUN_ID_NONE=''

# Main entrypoint for processing data online using the Build Scan summary tool.
# All scripts should call this function to fetch Build Scan data used in the
# experiment summary.
#
# USAGE: fetch_build_scans_and_build_time_metrics <logging_level> <run_id>
# EXAMPLE: fetch_build_scans_and_build_time_metrics "$LOGGING_BRIEF" "$RUN_ID"
#
# <logging_level> should be set to the constant LOGGING_BRIEF or LOGGING_VERBOSE
# <run_id> should be set to the constant RUN_ID or RUN_ID_NONE depending
# on whether the builds being queried for have a common run id,
# which will only be the case when both builds were produced
# during script execution
process_build_scan_data_online() {
local logging_level="$1"
local run_id="$2"

# Always call since it will only read if the metadata file exists
read_build_scan_metadata
fetch_build_scans_and_build_time_metrics 'brief_logging' "${build_scan_urls[@]}"

local build_scan_data
build_scan_data="$(fetch_build_scan_data "$logging_level" "$run_id")"
parse_build_scans_and_build_time_metrics "${build_scan_data}"
}

read_build_scan_metadata() {
Expand Down Expand Up @@ -46,38 +66,25 @@ is_build_scan_metadata_missing() {
return 0
}

# Used by CI / Local experiments to fetch data for the first CI build.
fetch_single_build_scan() {
local build_scan_url="$1"

local build_scan_data
build_scan_data="$(fetch_build_scan_data 'verbose_logging' "${build_scan_url}")"
build_scan_data="$(fetch_build_scan_data "$LOGGING_VERBOSE" "$RUN_ID_NONE")"

parse_single_build_scan "${build_scan_data}"
}

# The value of logging_level should be either 'brief_logging' or
# 'verbose_logging'
fetch_build_scans_and_build_time_metrics() {
local logging_level="$1"
shift
local build_scan_urls=("$@")

if [[ "${logging_level}" == 'verbose_logging' ]]; then
info "Fetching build scan data"
fi

local build_scan_data
build_scan_data="$(fetch_build_scan_data "${logging_level}" "${build_scan_urls[@]}")"

parse_build_scans_and_build_time_metrics "${build_scan_data}"
}

# Note: Callers of this function require stdout to be clean. No logging can be
# done inside this function.
# WARNING: Experiment scripts should not call this function directly and instead
# use the process_build_scan_data_online or fetch_single_build_scan
# function.
#
# WARNING: Callers of this function require stdout to be clean. No logging can
# be done inside this function.
fetch_build_scan_data() {
local logging_level="$1"
shift
local build_scan_urls=("$@")
local run_id="$2"

if [[ "${debug_mode}" == "on" ]]; then
args+=("--debug")
Expand All @@ -91,14 +98,18 @@ fetch_build_scan_data() {
args+=("--network-settings-file" "${SCRIPT_DIR}/network.settings")
fi

if [[ "${logging_level}" == "brief_logging" ]]; then
if [[ "${logging_level}" == "${LOGGING_BRIEF}" ]]; then
args+=("--brief-logging")
fi

if [[ "${fail_if_not_fully_cacheable}" == "on" ]]; then
args+=("--build-scan-availability-wait-timeout" "60")
fi

if [[ -n "${run_id}" ]]; then
args+=("--experiment-run-id" "$run_id")
fi

for run_num in "${!build_scan_urls[@]}"; do
args+=( "${run_num},${build_scan_urls[run_num]}" )
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ execute() {
rename_project_dir "build_${project_name}" "second-build_${project_name}"

print_bl
fetch_build_cache_metrics
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -110,7 +110,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
fetch_build_cache_metrics
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -149,8 +149,8 @@ print_maven_command() {
info "./mvnw -Dscan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} -Dpts.enabled=false clean ${tasks}$(print_extra_args)"
}

fetch_build_cache_metrics() {
process_build_scan_data_online
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID"
}

print_introduction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ execute() {
execute_second_build

print_bl
fetch_build_cache_metrics
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -113,7 +113,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
fetch_build_cache_metrics
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -153,8 +153,8 @@ print_maven_command() {
info "./mvnw -Dscan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} -Dpts.enabled=false clean ${tasks}$(print_extra_args)"
}

fetch_build_cache_metrics() {
process_build_scan_data_online
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID"
}

print_introduction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ main() {
}

execute() {
fetch_build_scans
process_build_scan_data
make_experiment_dir

print_bl
Expand Down Expand Up @@ -89,7 +89,7 @@ wizard_execute() {
explain_command_to_repeat_experiment_after_collecting_parameters

print_bl
fetch_build_scans
process_build_scan_data
make_experiment_dir

print_bl
Expand All @@ -114,8 +114,8 @@ validate_required_args() {
fi
}

fetch_build_scans() {
fetch_build_scans_and_build_time_metrics 'verbose_logging' "${build_scan_urls[@]}"
process_build_scan_data() {
process_build_scan_data_online "$LOGGING_VERBOSE" "$RUN_ID_NONE"
}

# Overrides summary.sh#print_experiment_specific_summary_info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ execute() {
execute_build

print_bl
process_build_scan_data_online
process_build_scan_data

print_bl
print_summary
Expand Down Expand Up @@ -127,7 +127,7 @@ wizard_execute() {
print_bl
explain_measure_build_results
print_bl
process_build_scan_data_online
process_build_scan_data
print_bl
explain_and_print_summary
}
Expand Down Expand Up @@ -219,6 +219,10 @@ execute_build() {
invoke_maven 1 "${args[@]}"
}

process_build_scan_data() {
process_build_scan_data_online "$LOGGING_BRIEF" "$RUN_ID_NONE"
}

# Overrides summary.sh#print_experiment_specific_summary_info
print_experiment_specific_summary_info() {
summary_row "Custom value mapping file:" "${mapping_file:-<none>}"
Expand Down
1 change: 1 addition & 0 deletions release/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

- [NEW] Support Develocity and Gradle Enterprise remote build cache connectors in the Gradle CI/Local experiment
- [NEW] Better handling of remote build cache misconfigurations
- [NEW] Fewer calls are made to the Develocity API when possible, resulting in faster and more stable execution
- [FIX] Scripts do not wait long enough for build scans to become available when `--fail-if-not-fully-cacheable` is used
- [FIX] Successful exit code returned when performance characteristics are unknown and `--fail-if-not-fully-cacheable` is used
- [FIX] Gradle experiments do not disable background Build Scan publication
Expand Down