Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 20 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,63 +35,44 @@ jobs:
mkdir build && cd build
cmake .. \
-DWITH_DEBUG=1 \
-DWITH_UNIT_TESTS=ON \
-DWITH_UNIT_TESTS=OFF \
-DWITH_ROUTER=OFF

- name: Build VillageSQL
run: |
cd build
make -j$(nproc)

- name: Initialize datadir
run: |
mkdir -p $PWD/var
./build/runtime_output_directory/mysqld --initialize-insecure --datadir=$PWD/var/mysqld.1

- name: Start MySQL server
run: |
./build/runtime_output_directory/mysqld \
--datadir=$PWD/var/mysqld.1 \
--socket=$PWD/var/mysql.sock \
--port=3306 \
--log-error=$PWD/var/mysqld.log \
&>/dev/null &
echo "Waiting for MySQL to start..."
for i in {1..30}; do
if mysql -S $PWD/var/mysql.sock -u root -e "SELECT 1" 2>/dev/null; then
echo "MySQL is ready"
break
fi
sleep 1
done

- name: Build extension
working-directory: extension
run: |
cd extension
mkdir build && cd build
cmake .. -DVillageSQL_BUILD_DIR=$PWD/../villagesql-server/build
cmake .. -DVillageSQL_BUILD_DIR=$GITHUB_WORKSPACE/villagesql-server/build
make -j$(nproc)

- name: Install extension
run: |
mysql -S $PWD/var/mysql.sock -u root \
-e "INSTALL EXTENSION $PWD/extension/build/prometheus_exporter.veb"

- name: Run MTR tests
run: |
cd build/mysql-test
perl mysql-test-run.pl \
--suite=$PWD/../extension/mysql-test \
--parallel=auto \
--tmpdir=$PWD/var \
--socket=$PWD/../var/mysql.sock \
--report-features
VEB_DIR=$GITHUB_WORKSPACE/veb
mkdir -p $VEB_DIR
cp $GITHUB_WORKSPACE/extension/build/prometheus_exporter.veb $VEB_DIR/

# Copy test files into the server's test suite
SUITE_DIR=$GITHUB_WORKSPACE/villagesql-server/mysql-test/suite/villagesql/prometheus_exporter
mkdir -p $SUITE_DIR/t $SUITE_DIR/r
cp $GITHUB_WORKSPACE/extension/mysql-test/t/*.test $SUITE_DIR/t/
cp $GITHUB_WORKSPACE/extension/mysql-test/r/*.result $SUITE_DIR/r/

cd build
perl ./mysql-test/mysql-test-run.pl \
--do-suite=villagesql/prometheus_exporter \
--parallel=1 \
--nounit-tests \
--mysqld=--veb-dir=$VEB_DIR

- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: |
build/mysql-test/var/log/*.log
villagesql-server/var/mysqld.log
villagesql-server/build/mysql-test/var/log/*.log
50 changes: 50 additions & 0 deletions local-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# Local CI simulation - mirrors what the GitHub Actions workflow should do
# Key insight: MTR manages its own MySQL server. Do NOT start one manually.

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EXTENSION_DIR="$SCRIPT_DIR"
VILLAGESQL_BUILD_DIR="${VILLAGESQL_BUILD_DIR:-/data/rene/build}"
VEB_DIR="/tmp/vsql-ci-veb-$$"

log() { echo "[local-ci] $(date '+%H:%M:%S') - $1"; }

cleanup() {
log "Cleaning up..."
rm -rf "$VEB_DIR" 2>/dev/null || true
}
trap cleanup EXIT

# Step 1: Build extension
log "Building extension..."
cd "$EXTENSION_DIR"
rm -rf build
mkdir -p build && cd build
cmake .. -DVillageSQL_BUILD_DIR="$VILLAGESQL_BUILD_DIR" 2>&1 | tail -5
make -j"$(nproc)" 2>&1 | tail -5

if [ ! -f prometheus_exporter.veb ]; then
log "ERROR: prometheus_exporter.veb not found after build"
exit 1
fi
log "Extension built successfully"

# Step 2: Set up VEB directory
mkdir -p "$VEB_DIR"
cp prometheus_exporter.veb "$VEB_DIR/"
log "VEB placed in $VEB_DIR"

# Step 3: Run MTR - let it manage its own server
# --mysqld=--veb-dir=... tells MTR to pass that flag to the server it starts
log "Running MTR tests..."
cd "$VILLAGESQL_BUILD_DIR"

perl ./mysql-test/mysql-test-run.pl \
--do-suite=villagesql/prometheus_exporter \
--parallel=1 \
--nounit-tests \
--mysqld=--veb-dir="$VEB_DIR"

log "MTR finished with exit code: $?"
Loading