-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·61 lines (48 loc) · 1.56 KB
/
build.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Script to build valkeyJSON module, build it and generate .so files, run unit and integration tests.
# # Exit the script if any command fails
set -e
SCRIPT_DIR=$(pwd)
echo "Script Directory: $SCRIPT_DIR"
# If environment variable SERVER_VERSION is not set, default to "unstable"
if [ -z "$SERVER_VERSION" ]; then
echo "SERVER_VERSION environment variable is not set. Defaulting to \"unstable\"."
export SERVER_VERSION="unstable"
fi
# Variables
BUILD_DIR="$SCRIPT_DIR/build"
# Build the Valkey JSON module using CMake
echo "Building valkeyJSON..."
if [ ! -d "$BUILD_DIR" ]; then
mkdir $BUILD_DIR
fi
cd $BUILD_DIR
if [ -z "${CFLAGS}" ]; then
cmake .. -DVALKEY_VERSION=${SERVER_VERSION}
else
cmake .. -DVALKEY_VERSION=${SERVER_VERSION} -DCFLAGS=${CFLAGS}
fi
make
# Running the Valkey JSON unit tests.
echo "Running Unit Tests..."
make -j unit
cd $SCRIPT_DIR
REQUIREMENTS_FILE="requirements.txt"
# Check if pip is available
if command -v pip > /dev/null 2>&1; then
echo "Using pip to install packages..."
pip install -r "$SCRIPT_DIR/$REQUIREMENTS_FILE"
# Check if pip3 is available
elif command -v pip3 > /dev/null 2>&1; then
echo "Using pip3 to install packages..."
pip3 install -r "$SCRIPT_DIR/$REQUIREMENTS_FILE"
else
echo "Error: Neither pip nor pip3 is available. Please install Python package installer."
exit 1
fi
export MODULE_PATH="$SCRIPT_DIR/build/src/libjson.so"
# Running the Valkey JSON integration tests.
echo "Running the integration tests..."
cd $BUILD_DIR
make -j test
echo "Build and Integration Tests succeeded"