Skip to content

Commit 60d4e07

Browse files
authored
Merge pull request #790 from gradle/erichaagdev/fail-unknown-perf-char-f
Unsuccessful exit code returned when performance characteristics are unknown and `--fail-if-not-fully-cacheable` is used
2 parents c64b21b + 333d22f commit 60d4e07

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

Gradle.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ is invoked, as shown in the example below.
8686

8787
The scripts return with an exit code that depends on the outcome of running a given experiment.
8888

89-
| Exit Code | Reason |
90-
|-----------|--------------------------------------------------------------------------------------------------------|
91-
| 0 | The experiment completed successfully |
92-
| 1 | An invalid input was provided while attempting to run the experiment |
93-
| 2 | One of the builds that is part of the experiment failed |
94-
| 3 | The build was not fully cacheable for the given task graph and `--fail-if-not-fully-cacheable` was set |
95-
| 100 | An unclassified, fatal error happened while running the experiment |
89+
| Exit Code | Reason |
90+
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
91+
| 0 | The experiment completed successfully |
92+
| 1 | An invalid input was provided while attempting to run the experiment |
93+
| 2 | One of the builds that is part of the experiment failed |
94+
| 3 | Option `--fail-if-not-fully-cacheable` was set and the build was not fully cacheable for the given task graph |
95+
| 4 | Option `--fail-if-not-fully-cacheable` was set and performance characteristics are unknown, e.g., due to a failed API response |
96+
| 100 | An unclassified, fatal error happened while running the experiment |
9697

9798
## Verifying the setup
9899

Maven.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ is invoked, as shown in the example below.
8484

8585
The scripts return with an exit code that depends on the outcome of running a given experiment.
8686

87-
| Exit Code | Reason |
88-
|-----------|------------------------------------------------------------------------------------------------------------|
89-
| 0 | The experiment completed successfully |
90-
| 1 | An invalid input was provided while attempting to run the experiment |
91-
| 2 | One of the builds that is part of the experiment failed |
92-
| 3 | The build was not fully cacheable for the given execution plan and `--fail-if-not-fully-cacheable` was set |
93-
| 100 | An unclassified, fatal error happened while running the experiment |
87+
| Exit Code | Reason |
88+
|-----------|--------------------------------------------------------------------------------------------------------------------------------|
89+
| 0 | The experiment completed successfully |
90+
| 1 | An invalid input was provided while attempting to run the experiment |
91+
| 2 | One of the builds that is part of the experiment failed |
92+
| 3 | Option `--fail-if-not-fully-cacheable` was set and the build was not fully cacheable for the given execution plan |
93+
| 4 | Option `--fail-if-not-fully-cacheable` was set and performance characteristics are unknown, e.g., due to a failed API response |
94+
| 100 | An unclassified, fatal error happened while running the experiment |
9495

9596
## Verifying the setup
9697

components/scripts/lib/exit-code.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ SUCCESS=0
44
INVALID_INPUT=1
55
BUILD_FAILED=2
66
BUILD_NOT_FULLY_CACHEABLE=3
7+
PERFORMANCE_CHARACTERISTICS_UNKNOWN=4
78
UNEXPECTED_ERROR=100
89

9-
readonly SUCCESS INVALID_INPUT UNEXPECTED_ERROR BUILD_FAILED BUILD_NOT_FULLY_CACHEABLE
10+
readonly SUCCESS INVALID_INPUT UNEXPECTED_ERROR BUILD_FAILED BUILD_NOT_FULLY_CACHEABLE PERFORMANCE_CHARACTERISTICS_UNKNOWN
1011

1112
# Overrides the die() function loaded from the argbash-generated parsing libs
1213
die() {
@@ -25,11 +26,20 @@ exit_with_return_code() {
2526
fi
2627

2728
if [[ "${fail_if_not_fully_cacheable}" == "on" ]]; then
29+
if [[ -z "${executed_cacheable_num_tasks[1]}" ]]; then
30+
print_bl
31+
die "FAILURE: Unable to determine if build is fully cacheable: Performance characteristics are unknown and --fail-if-not-fully-cacheable was used." "${PERFORMANCE_CHARACTERISTICS_UNKNOWN}"
32+
fi
33+
2834
local executed_avoidable_tasks
2935
executed_avoidable_tasks=$(( executed_cacheable_num_tasks[1] ))
3036
if (( executed_avoidable_tasks > 0 )); then
3137
print_bl
32-
die "FAILURE: Build is not fully cacheable for the given task graph." "${BUILD_NOT_FULLY_CACHEABLE}"
38+
if [[ "${BUILD_TOOL}" == "Maven" ]]; then
39+
die "FAILURE: Build is not fully cacheable for the given execution plan." "${BUILD_NOT_FULLY_CACHEABLE}"
40+
else
41+
die "FAILURE: Build is not fully cacheable for the given task graph." "${BUILD_NOT_FULLY_CACHEABLE}"
42+
fi
3343
fi
3444
fi
3545
exit "${SUCCESS}"

release/changes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
> [!IMPORTANT]
22
> The distributions of the Develocity Build Validation Scripts prefixed with `gradle-enterprise` are deprecated and will be removed in a future release. Migrate to the distributions prefixed with `develocity` instead.
33
4-
- [NEW] TBD
4+
- [FIX] Successful exit code returned when performance characteristics are unknown and `--fail-if-not-fully-cacheable` is used

0 commit comments

Comments
 (0)