Skip to content

Commit 0ed9167

Browse files
committed
testing: ensure run.sh is executing in docker container
On the host, some undesired things could end up happening if this is executed, so we now exit and log if that is attempted. In addition, we now backup the previous cargo config if present. This will never be the case in the current build setup, but that could change if we decide to do builds in a data volume in the future. Signed-off-by: Paul Osborne <[email protected]>
1 parent 72f6754 commit 0ed9167

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ci/run.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66
set -e
77

8+
# This should only be run in a docker container, so verify that
9+
if [ ! -f /.dockerinit ]; then
10+
echo "run.sh should only be executed in a docker container"
11+
echo " and that does not appear to be the case. Maybe you meant"
12+
echo " to execute the tests via run-all.sh or run-docker.sh."
13+
echo ""
14+
echo "For more instructions, please refer to ci/README.md"
15+
exit 1
16+
fi
17+
818
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
919
MANIFEST_PATH="${BASE_DIR}/Cargo.toml"
1020
BUILD_DIR="."
@@ -18,9 +28,8 @@ export RUST_TEST_THREADS=1
1828
# Tell cargo what linker to use and whatever else is required
1929
#
2030
configure_cargo() {
21-
rm -rf .cargo
22-
mkdir .cargo
23-
cp "${BASE_DIR}/ci/cargo-config" .cargo/config
31+
mkdir -p .cargo
32+
cp -b "${BASE_DIR}/ci/cargo-config" .cargo/config
2433
}
2534

2635
#

0 commit comments

Comments
 (0)