2026-02-05 08:44:21 -03:00
|
|
|
name: BotServer CI
|
2025-12-16 13:25:26 -03:00
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: ["main"]
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: ["main"]
|
|
|
|
|
|
2025-12-17 21:56:28 -03:00
|
|
|
env:
|
2026-02-06 09:26:44 -03:00
|
|
|
CARGO_BUILD_JOBS: 8
|
2025-12-18 17:14:36 -03:00
|
|
|
CARGO_NET_RETRY: 10
|
2026-03-20 21:39:58 -03:00
|
|
|
WORKSPACE: /opt/gbo/ci/botserver
|
|
|
|
|
CARGO_TARGET_DIR: /opt/gbo/ci/botserver/target
|
2025-12-17 21:56:28 -03:00
|
|
|
|
2025-12-16 13:25:26 -03:00
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: gbo
|
|
|
|
|
|
|
|
|
|
steps:
|
2025-12-18 17:14:36 -03:00
|
|
|
- name: Disable SSL verification
|
2025-12-16 13:25:26 -03:00
|
|
|
run: git config --global http.sslVerify false
|
|
|
|
|
|
2026-01-25 12:27:50 -03:00
|
|
|
- name: Setup Workspace
|
|
|
|
|
run: |
|
2026-03-20 21:39:58 -03:00
|
|
|
mkdir -p $WORKSPACE
|
|
|
|
|
cd $WORKSPACE
|
|
|
|
|
# Update or clone botlib
|
|
|
|
|
if [ -d botlib/.git ]; then
|
|
|
|
|
git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD
|
|
|
|
|
else
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
|
|
|
|
fi
|
|
|
|
|
# Update or clone botserver
|
|
|
|
|
if [ -d botserver/.git ]; then
|
|
|
|
|
git -C botserver fetch --depth 1 origin main && git -C botserver checkout FETCH_HEAD
|
|
|
|
|
else
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
|
|
|
|
fi
|
2026-03-20 21:45:17 -03:00
|
|
|
# Get workspace Cargo.toml from gb and strip unused members
|
|
|
|
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /tmp/gb-ws
|
|
|
|
|
cp /tmp/gb-ws/Cargo.toml Cargo.toml
|
|
|
|
|
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
|
|
|
|
|
grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
|
|
|
|
|
done
|
|
|
|
|
rm -rf /tmp/gb-ws
|
2026-01-25 18:01:19 -03:00
|
|
|
|
2025-12-17 22:40:45 -03:00
|
|
|
- name: Install system dependencies
|
|
|
|
|
run: |
|
2026-03-17 13:12:41 -03:00
|
|
|
sudo apt-get update -qq
|
2025-12-18 17:14:36 -03:00
|
|
|
sudo apt-get install -y libpq-dev libssl-dev liblzma-dev pkg-config
|
2025-12-17 22:40:45 -03:00
|
|
|
|
2025-12-16 13:25:26 -03:00
|
|
|
- name: Install Rust
|
2025-12-16 19:17:47 -03:00
|
|
|
run: |
|
2025-12-18 17:14:36 -03:00
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
|
|
|
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
2025-12-16 13:25:26 -03:00
|
|
|
|
2026-01-25 18:01:19 -03:00
|
|
|
- name: Install sccache
|
|
|
|
|
run: |
|
2026-03-20 21:39:58 -03:00
|
|
|
if [ ! -f $HOME/.cargo/bin/sccache ]; then
|
|
|
|
|
wget -q https://github.com/mozilla/sccache/releases/download/v0.8.2/sccache-v0.8.2-x86_64-unknown-linux-musl.tar.gz
|
|
|
|
|
tar xzf sccache-v0.8.2-x86_64-unknown-linux-musl.tar.gz
|
|
|
|
|
mv sccache-v0.8.2-x86_64-unknown-linux-musl/sccache $HOME/.cargo/bin/sccache
|
|
|
|
|
chmod +x $HOME/.cargo/bin/sccache
|
|
|
|
|
fi
|
2026-01-25 18:01:19 -03:00
|
|
|
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
2026-01-25 18:59:25 -03:00
|
|
|
$HOME/.cargo/bin/sccache --start-server || true
|
2026-01-25 18:01:19 -03:00
|
|
|
|
2026-02-05 08:44:21 -03:00
|
|
|
- name: Build BotServer
|
2026-03-20 21:39:58 -03:00
|
|
|
working-directory: /opt/gbo/ci/botserver
|
2025-12-16 21:13:12 -03:00
|
|
|
run: |
|
2026-03-20 22:44:19 -03:00
|
|
|
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log
|
2025-12-18 17:33:04 -03:00
|
|
|
ls -lh target/debug/botserver
|
2026-01-25 18:59:25 -03:00
|
|
|
sccache --show-stats || true
|
2025-12-16 22:29:29 -03:00
|
|
|
|
|
|
|
|
- name: Save build log
|
|
|
|
|
if: always()
|
2026-03-17 13:12:41 -03:00
|
|
|
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
2025-12-16 13:25:26 -03:00
|
|
|
|
2026-03-17 13:12:41 -03:00
|
|
|
- name: Deploy via SSH
|
2025-12-16 13:25:26 -03:00
|
|
|
run: |
|
2026-03-20 20:33:14 -03:00
|
|
|
set +e
|
2026-03-20 22:57:10 -03:00
|
|
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 pragmatismo-system "pkill -f botserver; sleep 2; rm -f /opt/gbo/bin/botserver" 2>&1 | tee /tmp/deploy.log
|
2026-03-20 20:33:14 -03:00
|
|
|
echo "--- scp start ---" >> /tmp/deploy.log
|
2026-03-20 21:39:58 -03:00
|
|
|
scp -o StrictHostKeyChecking=no /opt/gbo/ci/botserver/target/debug/botserver pragmatismo-system:/opt/gbo/bin/botserver 2>&1 | tee -a /tmp/deploy.log
|
2026-03-20 20:33:14 -03:00
|
|
|
SCP_EXIT=${PIPESTATUS[0]}
|
|
|
|
|
echo "scp exit: $SCP_EXIT" >> /tmp/deploy.log
|
|
|
|
|
if [ "$SCP_EXIT" = "0" ]; then
|
2026-03-20 20:59:20 -03:00
|
|
|
ssh -o StrictHostKeyChecking=no pragmatismo-system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver && cd /opt/gbo/bin && nohup sudo -u gbuser ./botserver --noconsole >> /opt/gbo/logs/error.log 2>&1 &" 2>&1 | tee -a /tmp/deploy.log
|
2026-03-20 20:33:14 -03:00
|
|
|
fi
|
2026-03-20 19:51:08 -03:00
|
|
|
|
|
|
|
|
- name: Save deploy log
|
|
|
|
|
if: always()
|
|
|
|
|
run: sudo cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true
|