generalbots/.forgejo/workflows/botserver-v2.yaml

86 lines
2.8 KiB
YAML
Raw Normal View History

# HASH-BUSTER-20260418-UNIQUE-ID-v7
# OTIMIZADO: Clone apenas submodules necessários (botserver + botlib)
name: BotServer CI/CD v2
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
SCCACHE_DIR: /opt/gbo/work/botserver/.sccache
CARGO_TARGET_DIR: /opt/gbo/work/botserver/target
jobs:
build:
runs-on: gbo
steps:
- name: Setup Isolado
run: |
echo "=== Setup Inicial ==="
mkdir -p $SCCACHE_DIR
mkdir -p $CARGO_TARGET_DIR
pkill -9 sccache || true
echo "Setup concluído."
- name: Setup Repository with Selective Submodules
run: |
echo "=== Configurando Repositório com Submodules Seletivos ==="
cd /opt/gbo/work/botserver
# Verificar se já é um repositório git
if [ ! -d .git ]; then
echo "Repositório não existe, clonando repositório gb..."
git init
git remote add origin https://alm.pragmatismo.com.br/GeneralBots/gb.git
git fetch --depth 1 origin main
git reset --hard origin/main
else
echo "Repositório já existe, atualizando..."
git pull origin main
fi
# Inicializar APENAS os submodules necessários (botserver e botlib)
echo "Inicializando submodule botserver..."
git config -f .gitmodules submodule.botserver.url https://alm.pragmatismo.com.br/GeneralBots/BotServer.git
git submodule update --init --depth 1 botserver
echo "Inicializando submodule botlib..."
git config -f .gitmodules submodule.botlib.url https://alm.pragmatismo.com.br/GeneralBots/botlib.git
git submodule update --init --depth 1 botlib
echo "Submodules inicializados:"
ls -la botserver/
ls -la botlib/ || echo "botlib não encontrado"
- name: Build Debug
run: |
echo "=== Compilando (Debug) ==="
cd /opt/gbo/work/botserver
# Verificar se Cargo.toml do workspace existe
if [ ! -f Cargo.toml ]; then
echo "ERRO: Cargo.toml não encontrado em $(pwd)"
ls -la
exit 1
fi
# Verificar se submodule do botserver foi clonado
if [ ! -f botserver/Cargo.toml ]; then
echo "ERRO: botserver/Cargo.toml não encontrado"
echo "Conteúdo de botserver/:"
ls -la botserver/ || echo "Pasta botserver/ não existe"
exit 1
fi
echo "Workspace Cargo.toml encontrado em $(pwd)/Cargo.toml"
echo "Botserver Cargo.toml encontrado em $(pwd)/botserver/Cargo.toml"
# Build específico para botserver usando workspace
echo "Executando: cargo build -p botserver"
cargo build -p botserver
echo "Build finalizado!"
ls -lh target/debug/botserver