From aeabd5c31022e21f5c62c451a026671e8e31902a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Sun, 22 Nov 2026 18:16:55 +0100 Subject: [PATCH 1/5] invoker: detect nono sandbox Give the user some hint why the sandbox does not work. --- pym/bob/invoker.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pym/bob/invoker.py b/pym/bob/invoker.py index 1884ec4d..a8a397d8 100644 --- a/pym/bob/invoker.py +++ b/pym/bob/invoker.py @@ -460,6 +460,7 @@ def ensureSandboxUsable(): ret = subprocess.run([getSandboxHelperPath(), "-C"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode if ret != 0: + msg = None knobs = [("/proc/sys/kernel/unprivileged_userns_clone", "1"), ("/proc/sys/kernel/apparmor_restrict_unprivileged_userns", "0")] for knob, expected_val in knobs: @@ -473,8 +474,13 @@ def ensureSandboxUsable(): except OSError: msg = f"Make sure {knob} is {expected_val}." break - else: + + if not msg and any(k.startswith("NONO_") for k, v in os.environ.items()): + msg = f"The nono sandbox does not support nested unprivileged containers. See https://github.com/nolabs-ai/nono/issues/1980." + + if not msg: msg = f"Not sure why that is exactly. Please consider opening a bug report at https://github.com/BobBuildTool/bob." + raise BuildError("Your system does not support unprivileged containers! You need to build without sandbox (--no-sandbox).", help=f"{msg} In case you use Docker, consider using the 'unconfined' seccomp profile." " See https://bob-build-tool.readthedocs.io/en/latest/installation.html#sandbox-capabilities for more details.", From f14c8a2f7e72393d015ad9f162ff142f82ed1fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Sun, 22 Nov 2026 18:32:49 +0100 Subject: [PATCH 2/5] test: make tests runnable inside nono sandbox Bob's sandbox does not work inside the nono sandbox because nested unprivileged containers are not supported. Disable the sandbox for 'build'-like commands if no explicit mode is requested and skip the tests that need a working sandbox. --- test/black-box/commands/run.sh | 4 ++++ test/black-box/fingerprints/run.sh | 3 +++ test/integration/gitea/run.py | 13 ++++++------- test/test-lib.sh | 30 +++++++++++++++++++++++++++--- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/test/black-box/commands/run.sh b/test/black-box/commands/run.sh index 43b4874d..9888a8d4 100755 --- a/test/black-box/commands/run.sh +++ b/test/black-box/commands/run.sh @@ -34,6 +34,10 @@ test_command() for CMD in "${COMMANDS[@]}"; do for SBX in "${SANDBOX_MODES[@]}" ; do + # Nested containers are not available in the nono sandbox + if is_nono && [[ ( $CMD == build || $CMD == dev || $CMD == project ) && -n "$SBX" && $SBX != --no-sandbox ]] ; then + continue + fi test_command "$CMD" $SBX done done diff --git a/test/black-box/fingerprints/run.sh b/test/black-box/fingerprints/run.sh index e9fb1bf7..80f605fb 100755 --- a/test/black-box/fingerprints/run.sh +++ b/test/black-box/fingerprints/run.sh @@ -6,6 +6,9 @@ if [[ $(uname -o) == Msys ]] ; then skip fi +# Needs working sandbox +"${BOB_ROOT}/bin/bob-namespace-sandbox" -C || skip + # Test the various direct properties of fingerprint scripts # ========================================================= # diff --git a/test/integration/gitea/run.py b/test/integration/gitea/run.py index 0d76c1ef..f96bfb9b 100644 --- a/test/integration/gitea/run.py +++ b/test/integration/gitea/run.py @@ -104,13 +104,13 @@ def testUploadDownload(archiveUrl, env): d = "testUploadDownload" prepare(d, archiveUrl) - res = runBob(["build", "--download=no", "--upload", "root"], d, env) + res = runBob(["build", "--no-sandbox", "--download=no", "--upload", "root"], d, env) assertEqual(res.returncode, 0) assertEqual(readResult(d, "root"), "ok") shutil.rmtree(os.path.join(d, "work")) - res = runBob(["build", "--download=forced", "root"], d, env) + res = runBob(["build", "--no-sandbox", "--download=forced", "root"], d, env) assertEqual(res.returncode, 0) assertEqual(readResult(d, "root"), "ok") @@ -125,7 +125,7 @@ def testManage(archiveUrl, env): d = "testManage" prepare(d, archiveUrl) - res = runBob(["build", "--download=no", "--upload", "root-alpha", "root-bravo"], d, env) + res = runBob(["build", "--no-sandbox", "--download=no", "--upload", "root-alpha", "root-bravo"], d, env) assertEqual(res.returncode, 0) shutil.rmtree(os.path.join(d, "work")) @@ -143,12 +143,12 @@ def testManage(archiveUrl, env): assertEqual(res.returncode, 0) # The retained artifact must still be downloadable... - res = runBob(["build", "--download=forced", "root-alpha"], d, env) + res = runBob(["build", "--no-sandbox", "--download=forced", "root-alpha"], d, env) assertEqual(res.returncode, 0) assertEqual(readResult(d, "root-alpha"), "alpha") # ...but the pruned one must be gone from the archive. - res = runBob(["build", "--download=forced", "root-bravo"], d, env) + res = runBob(["build", "--no-sandbox", "--download=forced", "root-bravo"], d, env) if res.returncode == 0: print("[TEST]:", "Error: pruned artifact could still be downloaded!") sys.exit(3) @@ -276,8 +276,7 @@ def giteaCmd(args): try: giteaLog = open(os.path.join(workDir, "gitea.log"), "wb") - giteaProc = subprocess.Popen([gitea, "--config", appIni, "--work-path", workDir, "web"], - stdout=giteaLog, stderr=subprocess.STDOUT) + giteaProc = subprocess.Popen([gitea, "--config", appIni, "--work-path", workDir, "web"]) print("[TEST]:", "Gitea running as pid", giteaProc.pid, "in", workDir) print("[TEST]:", "Waiting for Gitea to get ready...") diff --git a/test/test-lib.sh b/test/test-lib.sh index 8deca6bf..e5401e35 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -95,6 +95,12 @@ file_url() fi } +# Running inside the nono sandbox? +is_nono() +{ + [[ -n "${NONO_CAP_FILE:-}" ]] +} + cleanup() { rm -rf work dev .bob-* "$@" @@ -104,16 +110,34 @@ cleanup() # and "no global defaults" debug switches. run_bob() { + local args=("$@") + + # The nono sandbox does not support nested unprivileged containers. The + # "build" command uses the sandbox by default. Disable it unless the test + # explicitly asks for a sandbox mode. + if is_nono ; then + local a has_mode=0 is_build=0 + for a in "$@" ; do + [[ "$a" == *-sandbox ]] && has_mode=1 + done + # Find the command. Skip global "-C DIR" option. + local pos=0 + [[ "$1" == -C ]] && pos=2 + [[ "${args[$pos]:-}" == build || "${args[$pos]:-}" == project ]] && is_build=1 + # Options must precede generator arguments of "project" + [[ $is_build -eq 1 && $has_mode -eq 0 ]] && args=("${args[@]:0:pos+1}" --no-sandbox "${args[@]:pos+1}") + fi + if is_win32 ; then - python "$BOB_ROOT/bob" --debug=pkgck,ngd,audit "$@" + python "$BOB_ROOT/bob" --debug=pkgck,ngd,audit "${args[@]}" else - "$BOB_ROOT/bob" --debug=pkgck,ngd,audit "$@" + "$BOB_ROOT/bob" --debug=pkgck,ngd,audit "${args[@]}" fi } export_run_bob() { - export -f run_bob is_win32 + export -f run_bob is_win32 is_nono export BOB_ROOT TEST_ENVIRONMENT PYTHONPATH } From 225784df13ed8ce3b4c92854708b38802ee997d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Sun, 22 Nov 2026 20:06:45 +0100 Subject: [PATCH 3/5] test: disable obscure gitea feature Not sure why it wants to mess with ~/.ssh/authorized_keys but the nono sandbox refuses this rightfully so. Disable that. --- test/integration/gitea/run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/gitea/run.py b/test/integration/gitea/run.py index f96bfb9b..424da1b3 100644 --- a/test/integration/gitea/run.py +++ b/test/integration/gitea/run.py @@ -224,6 +224,7 @@ def giteaCmd(args): ROOT_URL = http://{GITEA_HOST}:{GITEA_PORT}/ DISABLE_SSH = true OFFLINE_MODE = true + SSH_CREATE_AUTHORIZED_KEYS_FILE = false [database] DB_TYPE = sqlite3 From 79f71b320d7c4d7a9b4036de10e939b5f4e060e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Sun, 22 Nov 2026 20:59:59 +0100 Subject: [PATCH 4/5] test: skip sandbox jenkins builds without container support The sandbox build variants need unprivileged containers. Skip them if the sandbox helper reports that they are not available, e.g. inside the nono sandbox. --- test/unit/test_jenkins_build.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/unit/test_jenkins_build.py b/test/unit/test_jenkins_build.py index abb26e25..44941b11 100644 --- a/test/unit/test_jenkins_build.py +++ b/test/unit/test_jenkins_build.py @@ -6,8 +6,16 @@ import subprocess import sys +from bob.invoker import getSandboxHelperPath from bob.utils import removePath +def _sandboxWorks(): + # Nested containers are not available e.g. inside the nono sandbox. + if sys.platform != "linux": + return False + return subprocess.run([getSandboxHelperPath(), "-C"], stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL).returncode == 0 + class JenkinsBuilds(JenkinsTests): OPTIONS = "" @@ -556,7 +564,7 @@ def testBuild(self): class JenkinsSandboxBuildDisabled(JenkinsSandboxBuilds, TestCase): pass -@skipUnless(sys.platform == "linux", "Sandbox requires Linux") +@skipUnless(_sandboxWorks(), "Sandbox requires working containers") class JenkinsSandboxBuildPartial(JenkinsSandboxBuilds, TestCase): OPTIONS = "--sandbox" OUTSIDE_ISOLATED=0 @@ -565,7 +573,7 @@ class JenkinsSandboxBuildPartial(JenkinsSandboxBuilds, TestCase): INSIDE_STABLE_PATH=1 INSIDE_IMAGE_USED=1 -@skipUnless(sys.platform == "linux", "Sandbox requires Linux") +@skipUnless(_sandboxWorks(), "Sandbox requires working containers") class JenkinsSandboxBuildSlim(JenkinsSandboxBuilds, TestCase): OPTIONS = "--slim-sandbox" OUTSIDE_ISOLATED=1 @@ -574,7 +582,7 @@ class JenkinsSandboxBuildSlim(JenkinsSandboxBuilds, TestCase): INSIDE_STABLE_PATH=0 INSIDE_IMAGE_USED=0 -@skipUnless(sys.platform == "linux", "Sandbox requires Linux") +@skipUnless(_sandboxWorks(), "Sandbox requires working containers") class JenkinsSandboxBuildDev(JenkinsSandboxBuilds, TestCase): OPTIONS = "--dev-sandbox" OUTSIDE_ISOLATED=1 @@ -583,7 +591,7 @@ class JenkinsSandboxBuildDev(JenkinsSandboxBuilds, TestCase): INSIDE_STABLE_PATH=0 INSIDE_IMAGE_USED=1 -@skipUnless(sys.platform == "linux", "Sandbox requires Linux") +@skipUnless(_sandboxWorks(), "Sandbox requires working containers") class JenkinsSandboxBuildStrict(JenkinsSandboxBuilds, TestCase): OPTIONS = "--strict-sandbox" OUTSIDE_ISOLATED=1 From c8f2f1068bbae4e3a6ff8e688a78ee793ed7f4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Sun, 22 Nov 2026 21:50:56 +0100 Subject: [PATCH 5/5] test: group verbose test output on GitHub Actions Wrap the output of each test in a collapsible group. The header shows the status (pass, fail, skip) and the duration. Groups are emitted atomically so parallel runs do not interleave. --- test/run-tests.sh | 54 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/test/run-tests.sh b/test/run-tests.sh index 53f561cf..7e4f0679 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -73,7 +73,6 @@ run_test() [[ ${VERBOSE+true} ]] && echo "$test_name: finished: ok ($((SECONDS-start))s)" || echo "ok ($((SECONDS-start))s)" elif [[ $ret -eq 240 ]] ; then [[ "${VERBOSE+true}" ]] && echo "$test_name: finished: skipped ($((SECONDS-start))s)" || echo "skipped ($((SECONDS-start))s)" - ret=0 elif [[ ${VERBOSE+true} ]] ; then echo "$test_name: finished: FAIL (exit $ret, $((SECONDS-start))s)" ret=1 @@ -94,7 +93,6 @@ run_test() [[ ${VERBOSE+true} ]] && echo "$test_name: finished: ok ($((SECONDS-start))s)" || echo "ok ($((SECONDS-start))s)" elif [[ $ret -eq 240 ]] ; then [[ ${VERBOSE+true} ]] && echo "$test_name: finished: skipped ($((SECONDS-start))s)" || echo "skipped ($((SECONDS-start))s)" - ret=0 elif [[ ${VERBOSE+true} ]] ; then echo "$test_name: finished: FAIL ($((SECONDS-start))s)" ret=1 @@ -112,6 +110,43 @@ run_test() cat "$LOGFILE" >> log.txt rm "$LOGFILE" + return $ret # 240 if the test was skipped +} + +# Run test and treat "skipped" as success +run_test_plain() +{ + local ret + run_test "$1" + ret=$? + [[ $ret -ne 240 ]] || ret=0 + return $ret +} + +# On GitHub Actions, collect the output of each test and emit it atomically as +# a collapsible group. The lock keeps parallel tests from interleaving. +run_test_grouped() +{ + local ret out=$(mktemp) start=$SECONDS + run_test "$1" > "$out" 2>&1 + ret=$? + local duration=$((SECONDS-start)) + # Portable lock (flock is unreliable on MSYS): mkdir is atomic. + until mkdir "$GROUP_LOCK/lock" 2>/dev/null ; do sleep 0.1 ; done + { + if [[ $ret -eq 240 ]] ; then + echo "::group::⏭️ $1 (${duration}s)" + elif [[ $ret -ne 0 ]] ; then + echo "::group::❌ $1 (${duration}s)" + else + echo "::group::✅ $1 (${duration}s)" + fi + cat "$out" + echo "::endgroup::" + } + rmdir "$GROUP_LOCK/lock" + rm -f "$out" + [[ $ret -ne 240 ]] || ret=0 return $ret } @@ -278,11 +313,20 @@ if [[ -n "$RUN_BLACKBOX_PAT" ]] ; then popd > /dev/null fi +# Group output per test on GitHub Actions (only useful in verbose mode) +RUN_TEST=run_test_plain +if [[ ${GITHUB_ACTIONS:-} == true && ${VERBOSE+true} ]] ; then + RUN_TEST=run_test_grouped + export GROUP_LOCK="$(mktemp -d)" + trap 'rm -rf "$GROUP_LOCK" 2>/dev/null' EXIT +fi + # execute all tests, possibly in parallel if [[ ${#RUN_TEST_NAMES[@]} -eq 0 ]] ; then : # No tests matched elif [[ ${RUN_JOBS:-} != 1 ]] ; then - export -f run_test print_verbose + export -f run_test run_test_plain run_test_grouped print_verbose + export RUN_TEST export RUN_PYTHON3 export RUN_PYTHON3_COV export TEST_ENVIRONMENT @@ -291,11 +335,11 @@ elif [[ ${RUN_JOBS:-} != 1 ]] ; then # buffering. This prevents the output from being interleaced. echo "${RUN_TEST_NAMES[@]}" \ | xargs -P ${RUN_JOBS:-$(nproc)} -n 1 \ - bash -o pipefail -c 'run_test "$@" | stdbuf -oL sed -e ""' bash \ + bash -o pipefail -c '$RUN_TEST "$@" | stdbuf -oL sed -e ""' bash \ || : $((FAILED+=$?)) else for i in "${RUN_TEST_NAMES[@]}" ; do - if ! run_test "$i" ; then + if ! $RUN_TEST "$i" ; then : $((FAILED++)) fi done