-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·28 lines (22 loc) · 994 Bytes
/
test.sh
File metadata and controls
executable file
·28 lines (22 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
# Build and run unit tests inside the CI Docker image. Like `cargo test`.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMAGE="firebolt-cpp-transport-ci:local"
# Build the CI image if not present
if ! docker image inspect "$IMAGE" &>/dev/null; then
echo "Building CI Docker image (one-time)..."
docker build -t "$IMAGE" -f "$SCRIPT_DIR/.github/Dockerfile" "$SCRIPT_DIR"
fi
RUN="docker run --rm -v $SCRIPT_DIR:/workspace $IMAGE"
# Configure if no cache or if the cache was made from a different source path
mkdir -p "$SCRIPT_DIR/build-dev"
cached_src=$($RUN bash -c "grep '^CMAKE_HOME_DIRECTORY' build-dev/CMakeCache.txt 2>/dev/null | cut -d= -f2" || true)
if [[ "$cached_src" != "/workspace" ]]; then
echo "Configuring..."
$RUN cmake -B build-dev -S . -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON
fi
echo "Building..."
$RUN cmake --build build-dev --parallel
echo "Testing..."
$RUN ctest --test-dir build-dev/test --output-on-failure