diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ec60c8..41b3e3e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: mkdir build && cd build cmake .. \ -DWITH_DEBUG=1 \ - -DWITH_UNIT_TESTS=ON \ + -DWITH_UNIT_TESTS=OFF \ -DWITH_ROUTER=OFF - name: Build VillageSQL @@ -43,49 +43,31 @@ jobs: 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() @@ -93,5 +75,4 @@ jobs: with: name: test-logs path: | - build/mysql-test/var/log/*.log - villagesql-server/var/mysqld.log \ No newline at end of file + villagesql-server/build/mysql-test/var/log/*.log diff --git a/local-ci.sh b/local-ci.sh new file mode 100755 index 0000000..b5be922 --- /dev/null +++ b/local-ci.sh @@ -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: $?"