ci: keep unit-test scratch out of the runner's shared /tmp (#3083)

* ci: keep unit-test scratch out of the runner's shared /tmp

Test JVMs now write temp files under the test task's build folder,
which checkout wipes on every job, so a killed run no longer leaves
Robolectric and JUnit folders behind in /tmp.

Self-hosted runners also clear stale test folders they own in /tmp,
drop the regenerable Gradle build cache when the workspace has under
20 GB free, and log disk use so a full disk is visible in the job.

* test(agent): size check no longer depends on the temp path's length

A symlink's own size is the length of its target path, so the old
100-byte bound failed once the temp dir moved under the build folder.

* ci: never remove a mount point while clearing runner scratch

* ci: keep a scratch folder that anything inside it touched recently

* ci: keep a scratch folder the freshness scan could not read
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-23 15:24:05 -05:00
1 parent e3b1b60914
commit b0a8c0898e
4 files changed
+26 -2

No files matched your search

+7
View File
@@ -164,6 +164,9 @@ jobs:
!/docs/releases/media/
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Clear scratch earlier runs left behind
if: runner.environment == 'self-hosted'
run: bash tools/ci/clear-runner-scratch.sh "$GITHUB_WORKSPACE"
- name: Merge the pinned APK base
if: github.event_name == 'pull_request'
env:
@@ -367,6 +370,10 @@ jobs:
persist-credentials: false
submodules: recursive
- name: Clear scratch earlier runs left behind
if: runner.environment == 'self-hosted'
run: bash tools/ci/clear-runner-scratch.sh "$GITHUB_WORKSPACE"
- name: Check human authorship
env:
EVENT_NAME: ${{ github.event_name }}
+3
View File
@@ -232,6 +232,9 @@ android {
}
maxHeapSize = '2g'
maxParallelForks = 2
def jvmTemp = new File(temporaryDir, 'jvm')
systemProperty 'java.io.tmpdir', jvmTemp.absolutePath
doFirst { jvmTemp.mkdirs() }
def logTarget = providers.systemProperty('robolectric.logging').orNull
if (logTarget != null) systemProperty 'robolectric.logging', logTarget
}
@@ -11,13 +11,13 @@ class AgentStorageTest {
@Test fun removingAFolderKeepsWhatItsLinksPointAt() {
val base = Files.createTempDirectory("agent-storage")
val outside = Files.createDirectories(base.resolve("sdcard"))
Files.write(outside.resolve("save.dat"), ByteArray(100))
Files.write(outside.resolve("save.dat"), ByteArray(1 shl 20))
val item = Files.createDirectories(base.resolve("rootfs/android-sdk"))
Files.write(item.resolve("a.jar"), ByteArray(10))
val linked = runCatching { Files.createSymbolicLink(item.resolve("saves"), outside) }.isSuccess
assumeTrue("symbolic links need privileges on this OS", linked)
assertTrue(AgentStorage.size(item) < 100)
assertTrue(AgentStorage.size(item) < 1 shl 20)
AgentStorage.delete(item)
assertFalse(Files.exists(item))
assertTrue(Files.exists(outside.resolve("save.dat")))
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -uo pipefail
workspace="${1:?}"
find /tmp -maxdepth 1 -user "$(id -u)" \( -name 'robolectric-*' -o -name 'junit*' -o -name 'gradle-*' -o -name 'kotlin-*' \) -mmin +180 -print0 |
while IFS= read -r -d '' entry; do
recent=$(find "$entry" -xdev -mmin -180 -print -quit 2>/dev/null) && [ -z "$recent" ] && rm -rf --one-file-system --preserve-root=all -- "$entry"
done
free=$(df --output=avail -k "$workspace" | tail -1)
if [ "$free" -lt 20971520 ]; then
rm -rf --one-file-system --preserve-root=all -- "${HOME:?}/.gradle/caches/build-cache-1" "${HOME:?}/.gradle/.tmp"
fi
df -h /tmp "$workspace"
du -xsh /tmp "${HOME:?}/.gradle" "${HOME:?}/.cargo" "${HOME:?}/.m2" "$(dirname "$workspace")" 2>/dev/null | sort -h
exit 0