@@ -44,22 +44,27 @@ jobs:
4444 # -short skips 3 known-slow stress tests in pkg/daemon and
4545 # pkg/daemon/udpio; everything else runs.
4646 #
47- # Both hosted runners have started handing out a $RUNNER_TEMP
48- # (/Users/runner/work/_temp on macOS, /home/runner/work/_temp on
49- # ubuntu) whose ACLs make t.TempDir() fail with "mkdir ...:
50- # permission denied" — a recurring GitHub-runner issue (seen on
51- # #304/#306/#308 for macOS and now hitting ubuntu too). A writable
52- # subdir under it inherits the same restriction, so redirecting
53- # TMPDIR *into* $RUNNER_TEMP is not enough; it must point at a
54- # freshly-created dir outside that tree. Create one under /tmp
55- # (writable by the test process on both Linux and macOS), chmod it
56- # so t.TempDir()'s sub-dirs are creatable, and point $TMPDIR there
57- # for THIS run block so go test's os.TempDir() -> t.TempDir()
58- # lands somewhere writable. No job/step-level `env: TMPDIR:` is set
59- # anywhere in this workflow, so nothing overrides this export.
47+ # t.TempDir() flakes with "mkdir <dir>/<TestName>/001: permission
48+ # denied" on the hosted runners when $TMPDIR points into /tmp.
49+ # /tmp (and /private/tmp on macOS) is world-writable with the
50+ # sticky bit (mode 1777); the runner's extra sandbox layer
51+ # (sandbox-exec on macOS, AppArmor on ubuntu) intermittently
52+ # denies the nested mkdir Go does for each parallel sub-test there,
53+ # which is why #316's `mktemp -d /tmp/...` + chmod 777 still failed
54+ # on #302/#321/#325 (and started hitting ubuntu too). The fix is to
55+ # keep temp OUT of the sticky /tmp tree and use a plain, per-user,
56+ # runner-owned directory instead:
57+ # * macOS: the OS-native DARWIN_USER_TEMP_DIR (/var/folders/.../T)
58+ # — a per-user temp with no sticky bit and no sandbox quirk.
59+ # * Linux: a fresh dir under the runner-owned $RUNNER_TEMP.
60+ # No job/step-level `env: TMPDIR:` is set anywhere in this
61+ # workflow, so nothing overrides this export.
6062 run : |
61- TMPDIR="$(mktemp -d /tmp/gotmpXXXXXX 2>/dev/null || mktemp -d "${RUNNER_TEMP:-.}/gotmpXXXXXX")"
62- chmod 777 "$TMPDIR"
63+ if [ "${RUNNER_OS}" = "macOS" ]; then
64+ TMPDIR="$(getconf DARWIN_USER_TEMP_DIR)"
65+ else
66+ TMPDIR="$(mktemp -d "${RUNNER_TEMP:-/tmp}/gotmpXXXXXX")"
67+ fi
6368 export TMPDIR
6469 echo "using TMPDIR=$TMPDIR"
6570 go test -short -count=1 -timeout 600s ./pkg/... ./cmd/... ./internal/...
0 commit comments