generalbots/.forgejo/workflows/botserver-v2.yaml
Rodrigo Rodriguez (Pragmatismo) f47f9ade82
Some checks failed
BotServer CI/CD v2 / build (push) Failing after 1s
Fix: Adiciona fallback para clone direto (v8)
- Se git submodule falhar, faz clone direto do repositório
- Verifica se botserver/Cargo.toml existe após tentativa de init
- Fallback: git clone --depth 1 se submodule falhar
- Prepara Cargo.toml do workspace removendo members desnecessários
- Adiciona logging extensivo para debug
- Hash buster v8 força reavaliação completa
2026-04-18 17:19:45 -03:00

116 lines
4.1 KiB
YAML

# HASH-BUSTER-20260418-UNIQUE-ID-v8
# WORKFLOW COM SUBMODULES + FALLBACK PARA CLONE COMPLETO
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 Fallback
run: |
echo "=== Configurando Repositório ==="
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
# Tentar inicializar submodules específicos
echo "Tentando inicializar submodules..."
SUBMODULE_OK=true
# Inicializar botserver
if [ ! -f botserver/Cargo.toml ]; then
echo "botserver submodule não existe, tentando inicializar..."
if ! git submodule update --init --depth 1 botserver 2>/dev/null; then
echo "Falha ao inicializar botserver via submodule, tentando clone direto..."
rm -rf botserver
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
fi
else
echo "botserver já existe, atualizando..."
cd botserver && git pull && cd ..
fi
# Inicializar botlib
if [ ! -f botlib/Cargo.toml ]; then
echo "botlib submodule não existe, tentando inicializar..."
if ! git submodule update --init --depth 1 botlib 2>/dev/null; then
echo "Falha ao inicializar botlib via submodule, tentando clone direto..."
rm -rf botlib
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
fi
else
echo "botlib já existe, atualizando..."
cd botlib && git pull && cd ..
fi
echo "Estrutura final:"
ls -la
echo "botserver/:"
ls -la botserver/ 2>/dev/null || echo "botserver/ não existe"
echo "botlib/:"
ls -la botlib/ 2>/dev/null || echo "botlib/ não existe"
- 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 do workspace 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"
# Preparar Cargo.toml do workspace (remover members desnecessários)
echo "Preparando Cargo.toml do workspace..."
cp Cargo.toml Cargo.toml.bak
grep -v '"botapp\|"botdevice\|"bottest\|"botui\|"botbook\|"botmodels\|"botplugin\|"bottemplates"' Cargo.toml > Cargo.toml.tmp || true
if [ -s Cargo.toml.tmp ]; then
mv Cargo.toml.tmp Cargo.toml
fi
# 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