# 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