Skip to content

Commit 0d97dad

Browse files
committed
Retry transient cold Forge bootstrap downloads
1 parent 6512994 commit 0d97dad

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,31 @@ jobs:
3939
set -euo pipefail
4040
test ! -e .gradle
4141
test ! -e "$GRADLE_USER_HOME"
42-
mkdir -p "$GRADLE_USER_HOME"
4342
chmod +x ./gradlew
44-
./gradlew verifyMavenizerCompatibilityFixture help \
45-
--no-daemon --no-build-cache --stacktrace --max-workers=2 \
46-
-Dorg.gradle.java.installations.paths="$JAVA_HOME" \
47-
-Dorg.gradle.java.installations.auto-detect=false \
48-
-Dorg.gradle.java.installations.auto-download=false \
49-
| tee "$RUNNER_TEMP/cold-forge-bootstrap.log"
43+
gradle_args=(
44+
verifyMavenizerCompatibilityFixture help
45+
--no-daemon --no-build-cache --stacktrace --max-workers=2
46+
"-Dorg.gradle.java.installations.paths=$JAVA_HOME"
47+
-Dorg.gradle.java.installations.auto-detect=false
48+
-Dorg.gradle.java.installations.auto-download=false
49+
)
50+
for attempt in 1 2 3; do
51+
if (( attempt > 1 )); then
52+
echo "Retrying the cold Forge bootstrap after transient download failure ($attempt/3)"
53+
rm -rf -- "$GRADLE_USER_HOME/caches/minecraftforge" .gradle/mavenizer
54+
sleep "$((attempt * 5))"
55+
fi
56+
mkdir -p "$GRADLE_USER_HOME"
57+
attempt_log="$RUNNER_TEMP/cold-forge-bootstrap-attempt-$attempt.log"
58+
if ./gradlew "${gradle_args[@]}" 2>&1 | tee "$attempt_log"; then
59+
cp "$attempt_log" "$RUNNER_TEMP/cold-forge-bootstrap.log"
60+
break
61+
fi
62+
if (( attempt == 3 )); then
63+
echo "Cold Forge bootstrap failed after $attempt attempts" >&2
64+
exit 1
65+
fi
66+
done
5067
grep -F "OreSpawn Mavenizer compatibility runtime: Java 25.0.3" \
5168
"$RUNNER_TEMP/cold-forge-bootstrap.log"
5269
grep -F "OreSpawn Mavenizer compatibility: applied 0 rule(s) for net.minecraftforge:forge:26.1.2-64.0.9 (explicit no-op)" \

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ void codeQlUsesABoundedCachePreservingCompileRetry() throws Exception {
9090
"CodeQL retries must preserve exact Gradle arguments");
9191
assertTrue(text.contains("failed after $attempt attempts"),
9292
"CodeQL must fail rather than hide a persistent bootstrap defect");
93+
94+
String ci = new String(Files.readAllBytes(
95+
Paths.get(".github", "workflows", "ci.yml")), StandardCharsets.UTF_8);
96+
assertTrue(ci.contains("gradle_args=("),
97+
"the cold Forge bootstrap must pass Gradle options as an argument vector");
98+
assertTrue(ci.contains("for attempt in 1 2 3; do"),
99+
"the cold Forge bootstrap must bound transient Mavenizer download retries");
100+
assertTrue(ci.contains("./gradlew \"${gradle_args[@]}\""),
101+
"cold-bootstrap retries must preserve exact Gradle arguments");
102+
assertTrue(ci.contains("Cold Forge bootstrap failed after $attempt attempts"),
103+
"the cold bootstrap must fail rather than hide a persistent download defect");
93104
}
94105

95106
private static int occurrences(String text, String needle) {

0 commit comments

Comments
 (0)