Skip to content

Commit 7e90ea8

Browse files
committed
Retry transient cold Forge downloads
1 parent 5553ee2 commit 7e90ea8

2 files changed

Lines changed: 38 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,31 @@ jobs:
5151
set -euo pipefail
5252
test ! -e .gradle
5353
test ! -e "$GRADLE_USER_HOME"
54-
mkdir -p "$GRADLE_USER_HOME"
5554
chmod +x ./gradlew
56-
./gradlew verifyMavenizerCompatibilityFixture help \
57-
--no-daemon --no-build-cache --stacktrace --max-workers=2 \
58-
-Dorg.gradle.java.installations.paths="$JAVA_HOME,$JAVA_HOME_8_X64,$JAVA_HOME_25_X64" \
59-
-Dorg.gradle.java.installations.auto-detect=false \
60-
-Dorg.gradle.java.installations.auto-download=false \
61-
| tee "$RUNNER_TEMP/cold-forge-bootstrap.log"
55+
gradle_args=(
56+
verifyMavenizerCompatibilityFixture help
57+
--no-daemon --no-build-cache --stacktrace --max-workers=2
58+
"-Dorg.gradle.java.installations.paths=$JAVA_HOME,$JAVA_HOME_8_X64,$JAVA_HOME_25_X64"
59+
-Dorg.gradle.java.installations.auto-detect=false
60+
-Dorg.gradle.java.installations.auto-download=false
61+
)
62+
for attempt in 1 2 3; do
63+
if (( attempt > 1 )); then
64+
echo "Retrying the cold Forge bootstrap after transient download failure ($attempt/3)"
65+
rm -rf -- "$GRADLE_USER_HOME/caches/minecraftforge" .gradle/mavenizer
66+
sleep "$((attempt * 5))"
67+
fi
68+
mkdir -p "$GRADLE_USER_HOME"
69+
attempt_log="$RUNNER_TEMP/cold-forge-bootstrap-attempt-$attempt.log"
70+
if ./gradlew "${gradle_args[@]}" 2>&1 | tee "$attempt_log"; then
71+
cp "$attempt_log" "$RUNNER_TEMP/cold-forge-bootstrap.log"
72+
break
73+
fi
74+
if (( attempt == 3 )); then
75+
echo "Cold Forge bootstrap failed after $attempt attempts" >&2
76+
exit 1
77+
fi
78+
done
6279
grep -F "OreSpawn Mavenizer compatibility runtime: Java 25.0.3" \
6380
"$RUNNER_TEMP/cold-forge-bootstrap.log"
6481
grep -F "OreSpawn Mavenizer compatibility: applied 0 rule(s) for net.minecraftforge:forge:1.21.1-52.1.0 (explicit no-op)" \

‎src/test/java/zone/moddev/mc/orespawn/ReleaseWorkflowContractTest.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ void codeQlUsesABoundedCachePreservingCompileRetry() throws Exception {
8585
"CodeQL must fail rather than hide a persistent bootstrap defect");
8686
}
8787

88+
@Test
89+
void coldForgeBootstrapRetriesTransientDownloadsWithoutAcceptingPersistentFailure() throws Exception {
90+
String text = new String(Files.readAllBytes(
91+
Paths.get(".github", "workflows", "ci.yml")), StandardCharsets.UTF_8);
92+
assertTrue(text.contains("for attempt in 1 2 3; do"),
93+
"Cold Forge bootstrap must bound transient download retries");
94+
assertTrue(text.contains("./gradlew \"${gradle_args[@]}\" 2>&1 | tee \"$attempt_log\""),
95+
"Every retry must preserve the exact Gradle bootstrap arguments and diagnostics");
96+
assertTrue(text.contains("rm -rf -- \"$GRADLE_USER_HOME/caches/minecraftforge\" .gradle/mavenizer"),
97+
"Retries must discard partial Forge and Mavenizer state");
98+
assertTrue(text.contains("Cold Forge bootstrap failed after $attempt attempts"),
99+
"A persistent bootstrap failure must still fail CI");
100+
}
101+
88102
private static int occurrences(String text, String needle) {
89103
int count = 0;
90104
int offset = 0;

0 commit comments

Comments
 (0)