Fix CI: Use gbuser home directory and restore original Setup Workspace
Some checks failed
BotServer CI/CD / build (push) Failing after 10s

- Changed WORKSPACE from /opt/gbo/data/botserver to /home/gbuser/workspace
- Changed CARGO_TARGET_DIR from /opt/gbo/data/botserver/target to /home/gbuser/target
- Restored original Setup Workspace approach that clones gb-ws and uses its Cargo.toml
- Uses shallow clones (--depth 1) for efficiency
- Only initializes necessary submodules (botlib and botserver)
- Updated build and deploy paths to use gbuser home directory

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-10 12:09:07 -03:00
parent 2634521d9e
commit aaccd741e3

View file

@ -10,8 +10,8 @@ env:
CARGO_BUILD_JOBS: 8
CARGO_NET_RETRY: 10
RUSTC_WRAPPER: sccache
WORKSPACE: /opt/gbo/data/botserver
CARGO_TARGET_DIR: /opt/gbo/data/botserver/target
WORKSPACE: /home/gbuser/workspace
CARGO_TARGET_DIR: /home/gbuser/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:
@ -29,30 +29,23 @@ jobs:
mkdir -p $WORKSPACE
cd $WORKSPACE
# Create minimal Cargo.toml for building botserver only
cat > Cargo.toml << 'EOF'
[workspace]
members = ["botlib", "botserver"]
[workspace.dependencies]
# Empty - all deps defined in member crates
EOF
# Clone or update botlib
if [ -d botlib/.git ]; then
git -C botlib pull --ff-only origin main
# Clone or update gb-ws (main workspace with Cargo.toml)
if [ -d gb-ws/.git ]; then
git -C gb-ws pull --ff-only origin main
else
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git gb-ws
fi
# Clone or update botserver
if [ -d botserver/.git ]; then
git -C botserver pull --ff-only origin main
else
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
fi
# Initialize and update submodules (only botlib and botserver needed)
cd gb-ws
git submodule update --init --depth 1 botlib
git submodule update --init --depth 1 botserver
mkdir -p /opt/gbo/data/botserver/target
# Pull latest updates from submodules
git -C botlib pull --ff-only origin main
git -C botserver pull --ff-only origin main
mkdir -p /home/gbuser/target
- name: Cache sccache
uses: actions/cache@v4
@ -76,14 +69,14 @@ EOF
fi
- name: Build BotServer
working-directory: /opt/gbo/data/botserver
working-directory: /home/gbuser/workspace/gb-ws
run: |
set -e
# Kill any stuck cargo processes
pkill -9 cargo 2>/dev/null || true
pkill -9 rustc 2>/dev/null || true
rm -f target/.cargo-lock 2>/dev/null || true
export SCCACHE_IDLE_TIMEOUT=300
export SCCACHE_CACHE_SIZE=10G
sccache --stop-server 2>/dev/null || true
@ -101,13 +94,13 @@ EOF
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/botserver/target/debug/botserver
ls -lh /home/gbuser/target/debug/botserver
echo "Step 2: Backing up old binary (ignore if not exists)..."
ssh $SSH_ARGS system "cp /opt/gbo/bin/botserver /tmp/botserver.bak 2>/dev/null || true"
echo "Step 3: Stopping botserver service..."
ssh $SSH_ARGS system "sudo systemctl stop botserver || true"
echo "Step 4: Transferring new binary..."
tar cf - -C /opt/gbo/data/botserver/target/debug botserver | gzip -1 | ssh $SSH_ARGS system "gzip -d | tar xf - -C /opt/gbo/bin && chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver && echo 'Transfer complete'"
tar cf - -C /home/gbuser/target/debug botserver | gzip -1 | ssh $SSH_ARGS system "gzip -d | tar xf - -C /opt/gbo/bin && chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver && echo 'Transfer complete'"
echo "Step 5: Starting botserver service..."
ssh $SSH_ARGS system "sudo systemctl start botserver && echo 'Botserver started'"
echo "=== Deploy completed ==="