|
3 | 3 | set -u |
4 | 4 | ref=$1; shift |
5 | 5 | cmd=$1; shift |
6 | | -OFF=$HOME/ecce-offload |
| 6 | +# Set by run-offload.sh: OFF (work root), MODE (container|native), SLOTS, JOBS. |
| 7 | +OFF=${OFF:-$HOME/ecce-offload} |
| 8 | +MODE=${MODE:-container} |
7 | 9 | REPO_URL=https://github.com/FriendsofECCE/ECCE.git |
8 | 10 | IMAGE=ecce-trixie-build |
9 | | -SLOTS=2 |
10 | | -JOBS=6 |
11 | | -mkdir -p "$OFF"/{src,wt,build,logs,locks,home} |
| 11 | +SLOTS=${SLOTS:-2} |
| 12 | +JOBS=${JOBS:-6} |
| 13 | +mkdir -p "$OFF"/{src,wt,build,logs,locks,home,cache,tmp} |
12 | 14 |
|
13 | | -safe=$(printf %s "$ref" | tr -c 'A-Za-z0-9._-\n' '_') |
| 15 | +safe=$(printf %s "$ref" | tr -c 'A-Za-z0-9._-' '_') |
14 | 16 | stamp=$(date +%Y%m%d-%H%M%S) |
15 | | -log=$OFF/logs/$stamp-$safe.log |
| 17 | +log=$OFF/logs/$stamp-$safe-$$.log |
16 | 18 | exec 3>&1 |
17 | 19 | # Everything below goes to the log; the summary is printed on fd 3. |
18 | 20 | exec >"$log" 2>&1 |
19 | 21 | say() { echo "$@" >&3; } |
20 | | -fail() { say "FAIL: $* (log: radium:$log)"; exit 1; } |
| 22 | +fail() { say "FAIL: $* (log: $(hostname):$log)"; exit 1; } |
21 | 23 |
|
22 | 24 | # Per-ref lock: two jobs on one ref would share one build directory. |
23 | 25 | exec 8>"$OFF/locks/ref-$safe" |
@@ -59,41 +61,50 @@ wt=$OFF/wt/$safe |
59 | 61 | bdir=$OFF/build/$safe |
60 | 62 | mkdir -p "$bdir" "$OFF/home/$safe" |
61 | 63 | echo "ref $ref = $sha, command: $cmd $*" |
62 | | -say "radium: $ref = ${sha:0:10}, $cmd $* (slot $got)" |
| 64 | +say "$(hostname): $ref = ${sha:0:10}, $cmd $* (slot $got)" |
63 | 65 |
|
64 | | -# Commands run inside the container; /work/src is the checkout, /work/build |
65 | | -# the persistent per-ref build directory. |
| 66 | +# $SRC is the checkout, $BLD the persistent per-ref build directory. |
66 | 67 | case $cmd in |
67 | | - build) inner='configure; ninja -C /work/build/b -j'$JOBS' -k 0' ;; |
68 | | - ctest) inner='configure; ninja -C /work/build/b -j'$JOBS' -k 0 && cd /work/build/b && ctest -j2 --output-on-failure "$@"' ;; |
69 | | - teaching) inner='configure; ninja -C /work/build/b -j'$JOBS' -k 0 && cd /work/src && tests/teaching/run_tests.py --build /work/build/b --jobs 4 "$@"' ;; |
70 | | - apps) inner='install_tree; cd /work/src && ECCE_TEST_HOME=/work/build/install ECCE_TEST_WRAPPERS=/work/build/install-bin tests/apps/run_tests.py "$@"' ;; |
71 | | - run) inner='configure; cd /work/src && "$@"' ;; |
| 68 | + build) inner='configure; ninja -C $BLD/b -j'$JOBS' -k 0' ;; |
| 69 | + ctest) inner='configure; ninja -C $BLD/b -j'$JOBS' -k 0 && cd $BLD/b && ctest -j${CTEST_JOBS:-2} --output-on-failure "$@"' ;; |
| 70 | + teaching) inner='configure; ninja -C $BLD/b -j'$JOBS' -k 0 && cd $SRC && tests/teaching/run_tests.py --build $BLD/b --jobs 4 "$@"' ;; |
| 71 | + apps) inner='install_tree; cd $SRC && ECCE_TEST_HOME=$BLD/install ECCE_TEST_WRAPPERS=$BLD/install-bin tests/apps/run_tests.py "$@"' ;; |
| 72 | + run) inner='configure; cd $SRC && "$@"' ;; |
72 | 73 | *) fail "unknown command '$cmd' (build|ctest|teaching|apps|run)" ;; |
73 | 74 | esac |
74 | 75 | prelude=' |
75 | 76 | configure() { |
76 | | - [ -f /work/build/b/build.ninja ] || cmake -G Ninja -S /work/src -B /work/build/b -DECCE_REQUIRE_LIBSSH=ON || return 1 |
| 77 | + [ -f $BLD/b/build.ninja ] || cmake -G Ninja -S $SRC -B $BLD/b -DECCE_REQUIRE_LIBSSH=ON || return 1 |
77 | 78 | } |
78 | 79 | install_tree() { |
79 | | - [ -f /work/build/bi/build.ninja ] || cmake -G Ninja -S /work/src -B /work/build/bi \ |
80 | | - -DCMAKE_INSTALL_PREFIX=/work/build/install -DECCE_HOME_DIR=/work/build/install \ |
81 | | - -DECCE_WRAPPER_DESTINATION=/work/build/install-bin || return 1 |
82 | | - ninja -C /work/build/bi -j'$JOBS' -k 0 && ninja -C /work/build/bi install |
| 80 | + [ -f $BLD/bi/build.ninja ] || cmake -G Ninja -S $SRC -B $BLD/bi \ |
| 81 | + -DCMAKE_INSTALL_PREFIX=$BLD/install -DECCE_HOME_DIR=$BLD/install \ |
| 82 | + -DECCE_WRAPPER_DESTINATION=$BLD/install-bin || return 1 |
| 83 | + ninja -C $BLD/bi -j'$JOBS' -k 0 && ninja -C $BLD/bi install |
83 | 84 | } |
84 | 85 | set -e' |
85 | 86 |
|
86 | 87 | start=$(date +%s) |
87 | | -podman run --rm --memory 12g --memory-swap 12g --userns=keep-id --shm-size 1g \ |
88 | | - -e HOME=/work/home -e TERM=dumb -e CTEST_OUTPUT_ON_FAILURE=1 \ |
89 | | - -v "$wt":/work/src -v "$bdir":/work/build -v "$OFF/home/$safe":/work/home \ |
90 | | - -w /work/src "$IMAGE" bash -c "$prelude |
| 88 | +# Inside the container the checkout, build dir and home are /work/*; native |
| 89 | +# hosts use the real paths. Only the work root is ever written to. |
| 90 | +if [ "$MODE" = container ]; then |
| 91 | + podman run --rm --memory 12g --memory-swap 12g --userns=keep-id --shm-size 1g \ |
| 92 | + -e HOME=/work/home -e USER="$(id -un)" -e LOGNAME="$(id -un)" -e SRC=/work/src -e BLD=/work/build -e TERM=dumb \ |
| 93 | + -e CTEST_OUTPUT_ON_FAILURE=1 \ |
| 94 | + -v "$wt":/work/src -v "$bdir":/work/build -v "$OFF/home/$safe":/work/home \ |
| 95 | + -w /work/src "$IMAGE" bash -c "$prelude |
91 | 96 | $inner" bash "$@" </dev/null |
| 97 | +else |
| 98 | + PATH=$PATH:/usr/sbin:/sbin HOME=$OFF/home/$safe SRC=$wt BLD=$bdir XDG_CACHE_HOME=$OFF/cache TMPDIR=$OFF/tmp \ |
| 99 | + TERM=dumb CTEST_OUTPUT_ON_FAILURE=1 \ |
| 100 | + bash -c "$prelude |
| 101 | +$inner" bash "$@" </dev/null |
| 102 | +fi |
92 | 103 | rc=$? |
93 | 104 | secs=$(( $(date +%s) - start )) |
94 | 105 |
|
95 | 106 | say "---- last lines of the log ----" |
96 | 107 | tail -n 25 "$log" >&3 |
97 | 108 | if [ $rc -eq 0 ]; then verdict=PASS; elif [ $rc -eq 77 ]; then verdict=SKIP; else verdict=FAIL; fi |
98 | | -say "$verdict: $cmd $* on $ref (${sha:0:10}) exit $rc, ${secs}s (log: radium:$log)" |
| 109 | +say "$verdict: $cmd $* on $ref (${sha:0:10}) exit $rc, ${secs}s (log: $(hostname):$log)" |
99 | 110 | exit $rc |
0 commit comments