diff --git a/.forgejo/workflows/botserver.yaml b/.forgejo/workflows/botserver.yaml index 4773b752..199b4314 100644 --- a/.forgejo/workflows/botserver.yaml +++ b/.forgejo/workflows/botserver.yaml @@ -7,23 +7,31 @@ on: - 'botlib/**' - 'Cargo.lock' - '.forgejo/workflows/botserver.yaml' +env: + SCCACHE_DIR: /opt/gbo/work/.sccache + CARGO_TARGET_DIR: /opt/gbo/work/target + RUSTC_WRAPPER: sccache + PATH: /home/gbuser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin jobs: build: runs-on: gbo steps: + - name: Setup + run: | + cd /opt/gbo/work/generalbots + git reset --hard HEAD + git clean -fd + git pull - name: Build run: | - cd /opt/gbo/work/botserver - git reset --hard HEAD && git clean -fd - git pull - git submodule update --init --recursive botlib botserver + cd /opt/gbo/work/generalbots cargo build -p botserver - name: Deploy run: | - sudo incus exec system -- systemctl stop botserver || true - sudo incus exec system -- pkill -x botserver || true - sleep 1 - sudo incus file push /opt/gbo/work/botserver/target/debug/botserver system:/opt/gbo/bin/botserver --mode=0755 - sudo incus exec system -- systemctl start botserver - sleep 2 - sudo incus exec system -- pgrep -x botserver && echo "✅ BotServer Deployed" || echo "❌ Failed" + timeout 5 bash -c 'while pgrep -x botserver > /dev/null; do pkill -x botserver; sleep 0.5; done' || true + mkdir -p /opt/gbo/bin + cp -f /opt/gbo/work/generalbots/target/debug/botserver /opt/gbo/bin/ + chmod +x /opt/gbo/bin/botserver + cd /opt/gbo/bin && ./botserver --noconsole & + sleep 3 + pgrep -x botserver && echo "✅ BotServer Deployed" || echo "❌ Failed" diff --git a/botapp/.forgejo/workflows/botapp.yaml b/botapp/.forgejo/workflows/botapp.yaml deleted file mode 100644 index c9ce6789..00000000 --- a/botapp/.forgejo/workflows/botapp.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: GBCI - -on: - workflow_dispatch: - # Disabled auto-trigger - enable when needed - # push: - # branches: ["main"] - # pull_request: - # branches: ["main"] - -jobs: - build: - runs-on: gbo - - steps: - - name: Disable SSL verification (temporary) - run: git config --global http.sslVerify false - - - uses: actions/checkout@v4 - - - name: Checkout botlib dependency - uses: actions/checkout@v4 - with: - repository: GeneralBots/botlib - path: ../botlib - - - name: Checkout botui dependency - uses: actions/checkout@v4 - with: - repository: GeneralBots/botui - path: ../botui - - - name: Cache Cargo registry - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-android-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-android- - - - name: Install Rust - uses: msrd0/rust-toolchain@v1 - with: - toolchain: stable - targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android - - - name: Setup Android SDK - run: | - export ANDROID_HOME=/opt/android-sdk - export NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125 - export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools - - - name: Install Tauri CLI - run: | - if ! command -v cargo-tauri &> /dev/null; then - cargo install tauri-cli - fi - - - name: Build Android APK - run: | - export ANDROID_HOME=/opt/android-sdk - export NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125 - export JAVA_HOME=/usr/lib/jvm/java-17-openjdk - cargo tauri android build - - - name: Deploy APK - run: | - sudo mkdir -p /opt/gbo/releases/botapp - sudo cp ./gen/android/app/build/outputs/apk/universal/release/*.apk /opt/gbo/releases/botapp/ || true - sudo cp ./gen/android/app/build/outputs/apk/release/*.apk /opt/gbo/releases/botapp/ || true - sudo chmod 644 /opt/gbo/releases/botapp/*.apk diff --git a/botbook/.forgejo/workflows/botbook.yaml b/botbook/.forgejo/workflows/botbook.yaml deleted file mode 100644 index 4e21ed07..00000000 --- a/botbook/.forgejo/workflows/botbook.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: GBCI - -on: - workflow_dispatch: - push: - branches: ["main"] - pull_request: - branches: ["main"] - -jobs: - build: - runs-on: gbo - - steps: - - name: Disable SSL verification (temporary) - run: git config --global http.sslVerify false - - - uses: actions/checkout@v4 - - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Install mdBook - run: | - if ! command -v mdbook &> /dev/null; then - cargo install mdbook - fi - - - name: Build documentation - run: mdbook build - - - name: Deploy documentation - run: | - sudo rm -rf /opt/gbo/bin/proxy/docs.pragmatismo.com.br/* - sudo cp -r ./book/* /opt/gbo/bin/proxy/docs.pragmatismo.com.br/ - sudo chmod -R 777 /opt/gbo/bin/proxy/docs.pragmatismo.com.br/ diff --git a/botdevice/.forgejo/workflows/botdevice.yaml b/botdevice/.forgejo/workflows/botdevice.yaml deleted file mode 100644 index 15c2d93c..00000000 --- a/botdevice/.forgejo/workflows/botdevice.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: GBCI - -on: - workflow_dispatch: - # Disabled auto-trigger - enable when needed - # push: - # branches: ["main"] - # pull_request: - # branches: ["main"] - -jobs: - build: - runs-on: gbo - - steps: - - name: Disable SSL verification (temporary) - run: git config --global http.sslVerify false - - - uses: actions/checkout@v4 - - - name: Checkout botlib dependency - uses: actions/checkout@v4 - with: - repository: GeneralBots/botlib - path: ../botlib - - - name: Cache Cargo registry - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-botdevice-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-botdevice- - - - name: Install Rust - uses: msrd0/rust-toolchain@v1 - with: - toolchain: stable - - - name: Install Android SDK and NDK - run: | - sudo apt-get update - sudo apt-get install -y android-sdk android-ndk - - - name: Add Android targets - run: | - rustup target add aarch64-linux-android - rustup target add armv7-linux-androideabi - rustup target add x86_64-linux-android - rustup target add i686-linux-android - - - name: Install Tauri CLI - run: | - if ! command -v cargo-tauri &> /dev/null; then - cargo install tauri-cli - fi - - - name: Compile ROM - run: | - chmod +x ./rom/install.sh - ./rom/install.sh - - - name: Build Android APK - run: | - cargo tauri android build - - - name: Deploy ROM artifacts - run: | - sudo mkdir -p /opt/gbo/bin/botdevice/rom - sudo cp -r ./rom/gsi/* /opt/gbo/bin/botdevice/rom/ - sudo cp ./target/aarch64-linux-android/release/*.apk /opt/gbo/bin/botdevice/ || true - sudo chmod -R 755 /opt/gbo/bin/botdevice diff --git a/botlib/.forgejo/workflows/botlib.yaml b/botlib/.forgejo/workflows/botlib.yaml deleted file mode 100644 index 41f62d5a..00000000 --- a/botlib/.forgejo/workflows/botlib.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: GBCI - -on: - workflow_dispatch: - # Disabled auto-trigger - enable when needed - # push: - # branches: ["main"] - # pull_request: - # branches: ["main"] - -jobs: - build: - runs-on: gbo - - steps: - - name: Disable SSL verification (temporary) - run: git config --global http.sslVerify false - - - uses: actions/checkout@v4 - - - name: Cache Cargo registry - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-botlib-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-botlib- - - - name: Install Rust - uses: msrd0/rust-toolchain@v1 - with: - toolchain: stable - - - name: Build library (default features) - run: cargo build --locked - - - name: Build library (full features) - run: cargo build --locked --features full - - - name: Run tests - run: cargo test --locked --features full - - - name: Build release - run: cargo build --locked --release --features full - - - name: Deploy library - run: | - sudo mkdir -p /opt/gbo/lib/botlib - sudo cp ./target/release/libbotlib.rlib /opt/gbo/lib/botlib/ || true - sudo cp ./target/release/libbotlib.a /opt/gbo/lib/botlib/ || true - sudo cp ./target/release/libbotlib.so /opt/gbo/lib/botlib/ || true diff --git a/botmodels/.forgejo/workflows/botmodels.yaml b/botmodels/.forgejo/workflows/botmodels.yaml deleted file mode 100644 index be0d5d41..00000000 --- a/botmodels/.forgejo/workflows/botmodels.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: BotModels CI/CD - -on: - push: - branches: ["main"] - -jobs: - build: - runs-on: gbo - - steps: - - name: Clone and Build - run: | - set -e - - mkdir -p ~/workspace/botmodels - cd ~/workspace/botmodels - - # Clone fresh every time - rm -rf botmodels - git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botmodels.git - - # Build in alm-ci (create venv, install deps) - cd botmodels - python3 -m venv venv - ./venv/bin/pip install --upgrade pip - ./venv/bin/pip install fastapi uvicorn pydantic numpy scipy - - - name: Deploy to models container - run: | - SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5" - TARGET="10.157.134.251" - - # Setup models container if needed - ssh $SSH $TARGET "mkdir -p /opt/gbo/bin 2>/dev/null || true" - - # Stop any running process - ssh $SSH $TARGET "pkill -f anomaly_detection.py 2>/dev/null || true; pkill -f main.py 2>/dev/null || true; sleep 2" - - # Transfer code - cd ~/workspace/botmodels/botmodels - tar czf - src requirements.txt | ssh $SSH $TARGET "mkdir -p /opt/gbo/bin/botmodels && cd /opt/gbo/bin/botmodels && rm -rf venv && tar xzf -" - - # Install deps and start - ssh $SSH $TARGET "cd /opt/gbo/bin/botmodels && python3 -m venv venv && ./venv/bin/pip install --upgrade pip && ./venv/bin/pip install fastapi uvicorn pydantic numpy scipy" - - # Start in background - ssh $SSH $TARGET "cd /opt/gbo/bin/botmodels && nohup ./venv/bin/python src/main.py > /tmp/botmodels.log 2>&1 &" - - # Health check - for i in $(seq 1 30); do - if ssh $SSH $TARGET "curl -sf http://localhost:8082/health" 2>/dev/null; then - echo "Deployed" - break - fi - sleep 2 - done - - - name: Verify - run: | - SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5" - TARGET="10.157.134.251" - ssh $SSH $TARGET "pgrep -f 'main.py|anomaly_detection' && echo Running || echo FAIL" \ No newline at end of file diff --git a/botplugin/.forgejo/workflows/botplugin.yaml b/botplugin/.forgejo/workflows/botplugin.yaml deleted file mode 100644 index 935b4d72..00000000 --- a/botplugin/.forgejo/workflows/botplugin.yaml +++ /dev/null @@ -1,53 +0,0 @@ -name: GBCI - -on: - workflow_dispatch: - # Disabled auto-trigger - enable when needed - # push: - # branches: ["main"] - # pull_request: - # branches: ["main"] - -jobs: - build: - runs-on: gbo - - steps: - - name: Disable SSL verification (temporary) - run: git config --global http.sslVerify false - - - uses: actions/checkout@v4 - - - name: Install zip utility - run: | - which zip || sudo apt-get update && sudo apt-get install -y zip - - - name: Generate extension ZIP - run: | - VERSION=$(jq -r '.version' manifest.json) - ZIP_NAME="general-bots-extension-v${VERSION}.zip" - - zip -r "$ZIP_NAME" \ - manifest.json \ - background.js \ - content.js \ - popup.html \ - popup.js \ - popup.css \ - options.html \ - styles.css \ - icons/ - - echo "Created: $ZIP_NAME" - ls -la "$ZIP_NAME" - - - name: Deploy extension ZIP - run: | - VERSION=$(jq -r '.version' manifest.json) - ZIP_NAME="general-bots-extension-v${VERSION}.zip" - - sudo mkdir -p /opt/gbo/releases/botplugin - sudo cp "$ZIP_NAME" /opt/gbo/releases/botplugin/ - sudo cp "$ZIP_NAME" /opt/gbo/releases/botplugin/general-bots-extension-latest.zip - - echo "Deployed extension to /opt/gbo/releases/botplugin/" diff --git a/botserver/.forgejo/workflows/botserver-v2.yaml b/botserver/.forgejo/workflows/botserver-v2.yaml deleted file mode 100644 index 858bdec6..00000000 --- a/botserver/.forgejo/workflows/botserver-v2.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# v26 - Clean submodule state -name: BotServer CI - -on: - push: - branches: [main] - -env: - SCCACHE_DIR: /opt/gbo/work/.sccache - CARGO_TARGET_DIR: /opt/gbo/work/target - RUSTC_WRAPPER: sccache - PATH: /home/gbuser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - -jobs: - build: - runs-on: gbo - steps: - - name: Setup - run: | - cd /opt/gbo/work/botserver - git rebase --abort 2>/dev/null || true - git reset --hard HEAD - git clean -fd - git pull - # CRITICAL: Reset submodules to clean state - git submodule foreach --recursive git reset --hard HEAD 2>/dev/null || true - git submodule foreach --recursive git clean -fd 2>/dev/null || true - git submodule update --init --recursive botlib botserver - # Verify clean - echo "Submodule status:" - git submodule status | head -5 - - - name: Build - run: | - cd /opt/gbo/work/botserver - cargo build -p botserver - - - name: Deploy - run: | - echo "1. Kill old..." - timeout 5 bash -c 'while pgrep -x botserver > /dev/null; do pkill -x botserver; sleep 0.5; done' || true - echo "2. Copy..." - mkdir -p /opt/gbo/bin - cp -f /opt/gbo/work/botserver/target/debug/botserver /opt/gbo/bin/ - chmod +x /opt/gbo/bin/botserver - echo "3. Start..." - cd /opt/gbo/bin && ./botserver --noconsole & - sleep 3 - echo "4. Verify..." - pgrep -x botserver && echo "✅ Running" || echo "❌ Failed" diff --git a/bottest/.forgejo/workflows/bottest.yaml b/bottest/.forgejo/workflows/bottest.yaml deleted file mode 100644 index 440db10b..00000000 --- a/bottest/.forgejo/workflows/bottest.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: GBCI - -on: - workflow_dispatch: - # Disabled auto-trigger - enable when needed - # push: - # branches: ["main"] - # pull_request: - # branches: ["main"] - -jobs: - test: - runs-on: gbo - - steps: - - name: Disable SSL verification (temporary) - run: git config --global http.sslVerify false - - - uses: actions/checkout@v4 - - - name: Checkout botlib dependency - uses: actions/checkout@v4 - with: - repository: GeneralBots/botlib - path: ../botlib - - - name: Checkout botserver dependency - uses: actions/checkout@v4 - with: - repository: GeneralBots/botserver - path: ../botserver - - - name: Cache Cargo registry - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-bottest-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-bottest- - - - name: Install Rust - uses: msrd0/rust-toolchain@v1 - with: - toolchain: stable - - - name: Run build - run: | - cargo build --locked - - - name: Run unit tests - run: | - cargo test --locked - - - name: Run integration tests - run: | - cargo test --locked --features integration - - - name: Run all tests with full features - run: | - cargo test --locked --features full diff --git a/botui/.forgejo/workflows/botui.yaml b/botui/.forgejo/workflows/botui.yaml deleted file mode 100644 index a762d06b..00000000 --- a/botui/.forgejo/workflows/botui.yaml +++ /dev/null @@ -1,119 +0,0 @@ -name: BotUI CI/CD - -on: - push: - branches: ["main"] - pull_request: - branches: ["main"] - -env: - CARGO_BUILD_JOBS: 8 - CARGO_NET_RETRY: 10 - RUSTC_WRAPPER: sccache - WORKSPACE: /opt/gbo/data/botui - CARGO_TARGET_DIR: /opt/gbo/data/botui/target - PATH: /home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - -jobs: - build: - runs-on: gbo - - steps: - - name: Setup Git - run: | - git config --global http.sslVerify false - git config --global --add safe.directory "*" - - - name: Setup Workspace - run: | - mkdir -p $WORKSPACE - cd $WORKSPACE - # Update or clone botlib - if [ -d botlib/.git ]; then - git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD - else - git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib - fi - # Update or clone botui - if [ -d botui/.git ]; then - git -C botui fetch --depth 1 origin main && git -C botui checkout FETCH_HEAD - else - git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botui.git botui - fi - # Get workspace Cargo.toml from gb and strip unused members - if [ -d /opt/gbo/data/gb-ws/.git ]; then - git -C /opt/gbo/data/gb-ws fetch --depth 1 origin main && git -C /opt/gbo/data/gb-ws checkout FETCH_HEAD - else - git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/data/gb-ws - fi - cp /opt/gbo/data/gb-ws/Cargo.toml Cargo.toml - for m in botapp botdevice bottest botserver botbook botmodels botplugin bottemplates; do - grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml - done - - - name: Install system dependencies - run: | - PKGS="libpq-dev libssl-dev liblzma-dev pkg-config" - MISSING="" - for pkg in $PKGS; do - dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg" - done - if [ -n "$MISSING" ]; then - sudo apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30 - sudo apt-get install -y --no-install-recommends $MISSING - else - echo "All system dependencies already installed" - fi - - - name: Clean up all workspaces - run: | - set -e - SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes" - echo "=== Cleaning up all workspaces on system container ===" - # Clean /opt/gbo/data/botui workspace (keep only target) - ssh $SSH_ARGS system "find /opt/gbo/data/botui -maxdepth 1 ! -path '*/target' ! -path '*/.git' -print0 2>/dev/null | xargs -0 rm -rf || true" - # Clean /opt/gbo/data/botui/target (keep only current build) - ssh $SSH_ARGS system "find /opt/gbo/data/botui/target -name '*.rlib' -type f -printf '%T@%p\n' 2>/dev/null | sort -r | tail -n +4 | while read t f; do [ -n \"\$f\" ] && rm -f \"\$f\"; done" - # Clean alm-ci workspaces (keep only what CI uses) - ssh $SSH_ARGS system "find /opt/gbo/data -maxdepth 2 ! -path '*/botserver' ! -path '*/botui' ! -path '*/gb-ws' -print0 2>/dev/null | xargs -0 rm -rf || true" - # Clean old log files - ssh $SSH_ARGS system "find /tmp -name '*.log' -type f -mtime +7 -print0 2>/dev/null | xargs -0 rm -f || true" - - - name: Build BotUI - working-directory: /opt/gbo/data/botui - run: | - sccache --start-server 2>/dev/null || true - cargo build -p botui --features embed-ui -j 8 2>&1 | tee /tmp/build.log - sccache --show-stats - ls -lh target/debug/botui - - - name: Save build log - if: always() - run: cp /tmp/build.log /tmp/botui-$(date +%Y%m%d-%H%M%S).log || true - - - name: Deploy via ssh tar gzip - run: | - set -e - SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes" - echo "=== Deploy started ===" - echo "Step 1: Checking binary..." - ls -lh /opt/gbo/data/botui/target/debug/botui - echo "Step 2: Backing up old binary..." - ssh $SSH_ARGS system "cp /opt/gbo/bin/botui /tmp/botui.bak" - echo "Step 3: Stopping botui service..." - ssh $SSH_ARGS system "sudo systemctl stop ui || true" - echo "Step 4: Transferring new binary..." - tar cf - -C /opt/gbo/data/botui/target/debug botui | gzip -1 | ssh $SSH_ARGS system "gzip -d | tar xf - -C /opt/gbo/bin && chmod +x /opt/gbo/bin/botui && chown gbuser:gbuser /opt/gbo/bin/botui && echo 'Transfer complete'" - echo "Step 5: Starting botui service..." - ssh $SSH_ARGS system "sudo systemctl start ui && echo 'BotUI started'" - echo "=== Deploy completed ===" - - - name: Verify botui started - run: | - sleep 15 - SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes" - ssh $SSH_ARGS system "pgrep -f botui >/dev/null && echo 'OK: ui is running' || echo 'WARNING: ui may still be starting'" - - - name: Save deploy log - if: always() - run: cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true