Simplificação total: Clone limpo sempre (v10)
Some checks failed
BotServer CI/CD / build (push) Failing after 3s
Some checks failed
BotServer CI/CD / build (push) Failing after 3s
Mudanças principais: - Remove dependência de estado anterior (/opt/gbo/work/botserver) - Sempre clona repositório gb do zero em /opt/gbo/work/build/workspace - Inicializa apenas botserver e botlib submodules - Prepara Cargo.toml removendo members desnecessários - Adiciona step de deploy automático - Cleanup após build (sucesso ou falha) - Hash buster v10 para reavaliação completa - Caminho simplificado e à prova de falhas Fluxo: 1. rm -rf /opt/gbo/work/build (limpeza) 2. git clone --depth 1 gb.git workspace 3. git submodule update --init botserver botlib 4. cargo build -p botserver 5. Deploy no system container 6. Cleanup
This commit is contained in:
parent
020af83308
commit
7f4774a88a
1 changed files with 68 additions and 59 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# HASH-BUSTER-20260418-UNIQUE-ID-v9
|
# HASH-BUSTER-20260418-SIMPLIFICADO-v10
|
||||||
# WORKFLOW COM CLONE COMPLETO SE FALHAR
|
# SIMPLIFICADO: Clone limpo sempre, sem dependência de estado anterior
|
||||||
name: BotServer CI/CD v2
|
name: BotServer CI/CD
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -9,90 +9,99 @@ on:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
SCCACHE_DIR: /opt/gbo/work/botserver/.sccache
|
SCCACHE_DIR: /opt/gbo/work/.sccache
|
||||||
CARGO_TARGET_DIR: /opt/gbo/work/botserver/target
|
CARGO_TARGET_DIR: /opt/gbo/work/target
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: gbo
|
runs-on: gbo
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Isolado
|
- name: Clone Limpo
|
||||||
run: |
|
run: |
|
||||||
echo "=== Setup Inicial ==="
|
echo "=== Clone Limpo do Workspace ==="
|
||||||
mkdir -p $SCCACHE_DIR
|
|
||||||
mkdir -p $CARGO_TARGET_DIR
|
|
||||||
pkill -9 sccache || true
|
|
||||||
echo "Setup concluído."
|
|
||||||
|
|
||||||
- name: Setup Repository
|
# Limpar diretório de trabalho anterior
|
||||||
run: |
|
rm -rf /opt/gbo/work/build
|
||||||
echo "=== Configurando Repositório ==="
|
mkdir -p /opt/gbo/work/build
|
||||||
cd /opt/gbo/work
|
cd /opt/gbo/work/build
|
||||||
|
|
||||||
# Verificar se repositório gb existe e tem Cargo.toml
|
# Clonar repositório gb (workspace raiz)
|
||||||
if [ ! -f botserver/Cargo.toml ] || [ ! -d botserver/.git ]; then
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git workspace
|
||||||
echo "Repositório inválido ou missing, clonando do zero..."
|
cd workspace
|
||||||
rm -rf botserver
|
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git botserver
|
|
||||||
cd botserver
|
|
||||||
else
|
|
||||||
echo "Repositório existe, atualizando..."
|
|
||||||
cd botserver
|
|
||||||
git fetch origin main
|
|
||||||
git reset --hard origin/main
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Inicializar submodules necessários
|
# Inicializar APENAS submodules necessários
|
||||||
echo "Inicializando submodules..."
|
echo "Inicializando submodules necessários..."
|
||||||
|
git config -f .gitmodules submodule.botserver.url https://alm.pragmatismo.com.br/GeneralBots/BotServer.git
|
||||||
|
git config -f .gitmodules submodule.botlib.url https://alm.pragmatismo.com.br/GeneralBots/botlib.git
|
||||||
git submodule update --init --depth 1 botserver
|
git submodule update --init --depth 1 botserver
|
||||||
git submodule update --init --depth 1 botlib
|
git submodule update --init --depth 1 botlib
|
||||||
|
|
||||||
# Se botserver ainda não tem Cargo.toml, clonar diretamente
|
echo "Estrutura do workspace:"
|
||||||
if [ ! -f botserver/Cargo.toml ]; then
|
|
||||||
echo "botserver submodule inválido, clonando diretamente..."
|
|
||||||
rm -rf botserver
|
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Se botlib não existe, clonar
|
|
||||||
if [ ! -f botlib/Cargo.toml ]; then
|
|
||||||
echo "botlib não existe, clonando..."
|
|
||||||
rm -rf botlib
|
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Estrutura final:"
|
|
||||||
ls -la
|
ls -la
|
||||||
echo "botserver/:"
|
echo "botserver/:"
|
||||||
ls -la botserver/ | head -20
|
ls -la botserver/ | head -15
|
||||||
echo "botlib/:"
|
echo "botlib/:"
|
||||||
ls -la botlib/ | head -10
|
ls -la botlib/ | head -15
|
||||||
|
|
||||||
- name: Build Debug
|
# Preparar Cargo.toml (remover members desnecessários)
|
||||||
|
echo "Preparando Cargo.toml..."
|
||||||
|
grep -v '"botapp\|"botdevice\|"bottest\|"botui\|"botbook\|"botmodels\|"botplugin\|"bottemplates"' Cargo.toml > Cargo.toml.clean || true
|
||||||
|
if [ -s Cargo.toml.clean ]; then
|
||||||
|
mv Cargo.toml.clean Cargo.toml
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Workspace preparado com sucesso!"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
echo "=== Compilando (Debug) ==="
|
echo "=== Build (Debug) ==="
|
||||||
cd /opt/gbo/work/botserver
|
cd /opt/gbo/work/build/workspace
|
||||||
|
|
||||||
# Verificar estrutura
|
# Verificar estrutura
|
||||||
if [ ! -f Cargo.toml ]; then
|
if [ ! -f Cargo.toml ]; then
|
||||||
echo "ERRO: Cargo.toml do workspace não encontrado"
|
echo "ERRO: Cargo.toml não encontrado"
|
||||||
echo "Diretório atual: $(pwd)"
|
|
||||||
ls -la
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f botserver/Cargo.toml ]; then
|
if [ ! -f botserver/Cargo.toml ]; then
|
||||||
echo "ERRO: botserver/Cargo.toml não encontrado"
|
echo "ERRO: botserver/Cargo.toml não encontrado"
|
||||||
echo "Diretório atual: $(pwd)"
|
|
||||||
ls -la botserver/ || echo "botserver/ não existe"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Workspace OK: $(pwd)/Cargo.toml"
|
|
||||||
echo "Botserver OK: $(pwd)/botserver/Cargo.toml"
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
echo "Executando: cargo build -p botserver"
|
|
||||||
cargo build -p botserver
|
cargo build -p botserver
|
||||||
echo "Build finalizado!"
|
|
||||||
|
echo "Build concluído!"
|
||||||
ls -lh target/debug/botserver
|
ls -lh target/debug/botserver
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
echo "=== Deploy ==="
|
||||||
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
||||||
|
|
||||||
|
# Parar serviço atual
|
||||||
|
ssh $SSH system "sudo systemctl stop botserver || true"
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# Copiar binário
|
||||||
|
scp $SSH /opt/gbo/work/build/workspace/target/debug/botserver system:/tmp/botserver
|
||||||
|
|
||||||
|
# Instalar e reiniciar
|
||||||
|
ssh $SSH system "
|
||||||
|
sudo mv /tmp/botserver /opt/gbo/bin/botserver
|
||||||
|
sudo chmod +x /opt/gbo/bin/botserver
|
||||||
|
sudo chown gbuser:gbuser /opt/gbo/bin/botserver
|
||||||
|
sudo systemctl start botserver
|
||||||
|
"
|
||||||
|
|
||||||
|
# Aguardar inicialização
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# Verificar deploy
|
||||||
|
ssh $SSH system "curl -sf http://localhost:8080/health && echo '✅ Deploy OK'" || echo "⚠️ Health check falhou"
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
echo "=== Cleanup ==="
|
||||||
|
rm -rf /opt/gbo/work/build
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue