Skip to content

Commit 2ea209f

Browse files
ci: update build-ci.sh
1 parent a196132 commit 2ea209f

6 files changed

Lines changed: 71 additions & 95 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
run: ./scripts/build-ci.sh
3737
env:
3838
PARALLEL_JOBS: 16
39+
BUILD_TYPE: debug
40+
CMAKE_EXTRA_FLAGS: -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
3941

4042
- name: Evict stale ccache entries
4143
run: ccache --evict-older-than 3600s

.github/workflows/full-test-suite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
env:
5757
PARALLEL_JOBS: 16
5858
BUILD_TYPE: ${{ inputs.build-type }}
59+
CMAKE_EXTRA_FLAGS: -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost
5960

6061
- name: Run tests
6162
uses: ./source/.github/actions/run-tests

.github/workflows/nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
run: ./scripts/build-ci.sh
3636
env:
3737
PARALLEL_JOBS: 16
38+
CMAKE_EXTRA_FLAGS: -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
3839

3940
- name: Show ccache statistics
4041
run: ccache -s

.github/workflows/valgrind.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
env:
5252
PARALLEL_JOBS: 16
5353
BUILD_TYPE: debug
54-
CMAKE_EXTRA_FLAGS: -DWITH_VALGRIND=1
54+
CMAKE_EXTRA_FLAGS: -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost -DWITH_VALGRIND=1
5555

5656
- name: Run Valgrind tests
5757
uses: ./source/.github/actions/run-tests

scripts/build-ci.sh

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,74 @@
11
#!/bin/bash
2+
# Copyright (c) 2026 VillageSQL Contributors
3+
# Configure and build the VillageSQL server for CI.
4+
#
5+
# Env vars:
6+
# BUILD_DIR - build output directory (default: <source>/../build)
7+
# SOURCE_DIR - source root (default: parent of script dir)
8+
# BUILD_TYPE - debug or release (default: release, uses RelWithDebInfo)
9+
# PARALLEL_JOBS - parallel make jobs (default: auto-detected)
10+
# CMAKE_EXTRA_FLAGS - additional cmake flags appended verbatim
211

3-
# VillageSQL CI Build Script
4-
# Performs a clean build and basic validation for CI environments
12+
set -euo pipefail
513

6-
set -e
14+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15+
SOURCE_DIR="${SOURCE_DIR:-$(cd "$SCRIPT_DIR/.." && pwd)}"
16+
source "$SCRIPT_DIR/vsql_script_utils.sh"
717

8-
# Determine build type (default to debug)
9-
BUILD_TYPE="${BUILD_TYPE:-debug}"
18+
BUILD_DIR="${BUILD_DIR:-$(cd "$SOURCE_DIR/.." && pwd)/build}"
19+
BUILD_TYPE="${BUILD_TYPE:-release}"
20+
PARALLEL_JOBS="${PARALLEL_JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo "4")}"
1021

11-
echo "=== VillageSQL CI Build ==="
12-
echo "Build type: ${BUILD_TYPE}"
13-
echo "Available CPUs: $(nproc)"
14-
echo "Parallel jobs: ${PARALLEL_JOBS}"
15-
echo "Working directory: $(pwd)"
22+
log_step "VillageSQL CI Build"
23+
echo ""
1624

17-
# Use SOURCE_DIR from environment, fallback to current directory
18-
SOURCE_DIR="${SOURCE_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
19-
20-
# Use BUILD_DIR from environment, fallback to ../build relative to source
21-
BUILD_DIR="${BUILD_DIR:-${SOURCE_DIR}/../build}"
25+
if [[ ! -d "$SOURCE_DIR" ]]; then
26+
die "Source directory not found: $SOURCE_DIR"
27+
fi
28+
if [[ ! -f "$SOURCE_DIR/CMakeLists.txt" ]]; then
29+
die "Source directory doesn't appear to be valid (no CMakeLists.txt): $SOURCE_DIR"
30+
fi
2231

23-
# Create build directory
24-
echo "Creating build directory: ${BUILD_DIR}"
2532
mkdir -p "$BUILD_DIR"
33+
34+
log_info "Source Directory: $SOURCE_DIR"
35+
log_info "Build Directory: $BUILD_DIR"
36+
log_info "Build Type: $BUILD_TYPE"
37+
log_info "Parallel Jobs: $PARALLEL_JOBS"
38+
echo ""
39+
40+
log_step "Step 1: Configuring build with CMake..."
2641
cd "$BUILD_DIR"
2742

28-
# Configure CMake
29-
echo "=== CMake Configuration ==="
43+
CMAKE_FLAGS=(
44+
"-DWITH_SSL=system"
45+
)
3046

31-
# Set debug flag based on build type
32-
if [ "$BUILD_TYPE" = "debug" ]; then
33-
WITH_DEBUG_FLAG="-DWITH_DEBUG=1"
47+
if [[ "$BUILD_TYPE" == "debug" ]]; then
48+
CMAKE_FLAGS+=("-DCMAKE_BUILD_TYPE=Debug" "-DWITH_DEBUG=1")
3449
else
35-
WITH_DEBUG_FLAG=""
50+
CMAKE_FLAGS+=("-DCMAKE_BUILD_TYPE=RelWithDebInfo")
51+
fi
52+
53+
if [[ -n "${CMAKE_EXTRA_FLAGS:-}" ]]; then
54+
CMAKE_FLAGS+=($CMAKE_EXTRA_FLAGS)
55+
fi
56+
57+
log_info "CMake flags: ${CMAKE_FLAGS[*]}"
58+
cmake "$SOURCE_DIR" "${CMAKE_FLAGS[@]}" || die "CMake configuration failed"
59+
log_info "CMake configuration complete"
60+
61+
log_step "Step 2: Building binaries..."
62+
log_info "Building with $PARALLEL_JOBS parallel jobs..."
63+
make -j"${PARALLEL_JOBS}" || die "Build failed"
64+
65+
if [[ ! -x "$BUILD_DIR/runtime_output_directory/mysqld" ]]; then
66+
die "mysqld not found in $BUILD_DIR/runtime_output_directory/ after build"
3667
fi
68+
log_info "Build complete"
69+
70+
log_step "Step 3: Building unit tests..."
71+
make -j"${PARALLEL_JOBS}" villagesql-unit-tests || die "Unit test build failed"
72+
log_info "Unit tests built"
3773

38-
cmake "$SOURCE_DIR" \
39-
-DCMAKE_INSTALL_PREFIX=/tmp/villagesql-install \
40-
$WITH_DEBUG_FLAG \
41-
-DWITH_SSL=system \
42-
-DMYSQL_MAINTAINER_MODE=OFF \
43-
-DDOWNLOAD_BOOST=1 \
44-
-DWITH_BOOST=/tmp/boost \
45-
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
46-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
47-
${CMAKE_EXTRA_FLAGS}
48-
49-
echo "=== Build Information ==="
50-
51-
# Build the project
52-
echo "=== Building VillageSQL ==="
53-
echo "Starting build with ${PARALLEL_JOBS} parallel jobs..."
54-
make -j"${PARALLEL_JOBS}"
55-
56-
echo "=== Building VillageSQL Unit Tests ==="
57-
make -j"${PARALLEL_JOBS}" villagesql-unit-tests
58-
59-
echo "=== Build Success ==="
60-
echo "VillageSQL built successfully!"
74+
log_step "Build succeeded: $BUILD_DIR/runtime_output_directory/mysqld"

scripts/make_villagesql_dev_server.sh

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -62,54 +62,15 @@ log_info " - mysql-test framework (binaries only, no test/result files)"
6262
log_info " - Support files and SQL scripts"
6363
echo ""
6464

65-
# Step 1: Configure build with CMake
66-
log_step "Step 1: Configuring build with CMake..."
67-
cd "$BUILD_DIR"
68-
69-
# Remove old cache to ensure clean configuration
70-
if [[ -f "CMakeCache.txt" ]]; then
71-
log_info "Removing old CMakeCache.txt..."
72-
rm -f CMakeCache.txt
73-
fi
74-
75-
# Configure CMake with appropriate build flags
76-
# - CMAKE_BUILD_TYPE=RelWithDebInfo: Release optimizations with debug symbols
77-
# - WITH_SSL=system: Use system OpenSSL library
78-
CMAKE_FLAGS=(
79-
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
80-
"-DWITH_SSL=system"
81-
)
82-
83-
# Add any extra flags from environment
84-
if [[ -n "$CMAKE_EXTRA_FLAGS" ]]; then
85-
CMAKE_FLAGS+=($CMAKE_EXTRA_FLAGS)
86-
fi
87-
88-
log_info "CMake flags: ${CMAKE_FLAGS[*]}"
89-
cmake "$SOURCE_DIR" "${CMAKE_FLAGS[@]}" || die "CMake configuration failed"
90-
log_info "CMake configuration complete"
91-
92-
# Step 2: Build binaries
93-
log_step "Step 2: Building binaries..."
94-
95-
# Detect number of CPU cores for parallel build
96-
NCORES=$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo "4")
97-
log_info "Building with $NCORES parallel jobs..."
98-
99-
make -j${NCORES} || die "Build failed"
100-
log_info "Build complete"
101-
102-
# Verify mysqld was built (CMake places it in runtime_output_directory before install)
103-
if [[ ! -x "$BUILD_DIR/runtime_output_directory/mysqld" ]]; then
104-
die "mysqld not found in $BUILD_DIR/runtime_output_directory/ after build"
105-
fi
65+
log_step "Step 1: Configure and build..."
66+
BUILD_DIR="$BUILD_DIR" SOURCE_DIR="$SOURCE_DIR" \
67+
"$SCRIPT_DIR/build-ci.sh" || die "build-ci.sh failed"
10668

107-
# Step 2.5: Build and test bundled extensions (optional, enabled via BUILD_BUNDLED_EXTENSIONS=1)
108-
# TODO(villagesql): Extract build_server.sh and package_dev_server.sh as separate
109-
# scripts so that CI can run build → test → package as discrete steps rather than
69+
# TODO(villagesql): Extract package_dev_server.sh as a separate script so that
70+
# CI can run build → test → package as discrete steps rather than
11071
# embedding the test between two halves of this monolithic script.
11172
if [[ "${BUILD_BUNDLED_EXTENSIONS:-0}" == "1" ]]; then
112-
log_step "Step 2.5: Building bundled extensions..."
73+
log_step "Step 2: Building bundled extensions..."
11374
SDK_STAGING_DIR="$BUILD_DIR/villagesql-extension-sdk-${VSQL_VERSION}"
11475
[[ -d "$SDK_STAGING_DIR" ]] || die "SDK staging directory not found: $SDK_STAGING_DIR"
11576

@@ -135,7 +96,6 @@ fi
13596
mkdir -p "$STAGING_DIR"
13697
cd "$BUILD_DIR"
13798

138-
# Step 3: Generate package with CPack
13999
log_step "Step 3: Generating base package with CPack..."
140100

141101
CPACK_COMPONENTS="Client;Server;Server_Scripts;SharedLibraries;SupportFiles;Readme;Info;ExampleVebs;Test;TestReadme"
@@ -158,7 +118,6 @@ fi
158118
ORIGINAL_SIZE=$(du -h "$BASE_TARBALL" | cut -f1)
159119
log_info "Base package size: $ORIGINAL_SIZE"
160120

161-
# Step 4: Extract the base package
162121
log_step "Step 4: Extracting base package..."
163122
cd "$STAGING_DIR"
164123

@@ -167,7 +126,6 @@ mkdir -p "$PACKAGE_NAME"
167126
cd "$PACKAGE_NAME"
168127
tar xzf "$BUILD_DIR/$BASE_TARBALL"
169128

170-
# Step 4.5: Strip unnecessary test data (keep only villagesql tests and SSL certs)
171129
log_step "Step 4.5: Stripping unnecessary test data..."
172130
if [[ -d "mysql-test" ]]; then
173131
log_info "Removing unnecessary test data from std_data..."

0 commit comments

Comments
 (0)