ci: run as gbuser, use sccache, rename ci to data
Some checks failed
BotServer CI/CD / build (push) Failing after 2s
Some checks failed
BotServer CI/CD / build (push) Failing after 2s
- Change runner service from root to gbuser - Add sccache for build caching (RUSTC_WRAPPER=sccache) - Rename /opt/gbo/ci to /opt/gbo/data for consistency - Persist gb-ws clone instead of re-cloning every build - Add sccache --show-stats to build output for monitoring
This commit is contained in:
parent
263ca4ed11
commit
1779f4f2fd
1 changed files with 17 additions and 11 deletions
|
|
@ -9,9 +9,10 @@ on:
|
||||||
env:
|
env:
|
||||||
CARGO_BUILD_JOBS: 8
|
CARGO_BUILD_JOBS: 8
|
||||||
CARGO_NET_RETRY: 10
|
CARGO_NET_RETRY: 10
|
||||||
WORKSPACE: /opt/gbo/ci/botserver
|
RUSTC_WRAPPER: sccache
|
||||||
CARGO_TARGET_DIR: /opt/gbo/ci/botserver/target
|
WORKSPACE: /opt/gbo/data/botserver
|
||||||
PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
CARGO_TARGET_DIR: /opt/gbo/data/botserver/target
|
||||||
|
PATH: /home/gbuser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -40,12 +41,15 @@ jobs:
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
||||||
fi
|
fi
|
||||||
# Get workspace Cargo.toml from gb and strip unused members
|
# 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
|
if [ -d /opt/gbo/data/gb-ws/.git ]; then
|
||||||
cp /tmp/gb-ws/Cargo.toml Cargo.toml
|
git -C /opt/gbo/data/gb-ws fetch --depth 1 origin main && git -C /opt/gbo/data/gb-ws checkout FETCH_HEAD
|
||||||
|
else
|
||||||
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/data/gb-ws
|
||||||
|
fi
|
||||||
|
cp /opt/gbo/data/gb-ws/Cargo.toml Cargo.toml
|
||||||
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
|
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
|
grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
|
||||||
done
|
done
|
||||||
rm -rf /tmp/gb-ws
|
|
||||||
|
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -62,27 +66,29 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build BotServer
|
- name: Build BotServer
|
||||||
working-directory: /opt/gbo/ci/botserver
|
working-directory: /opt/gbo/data/botserver
|
||||||
run: |
|
run: |
|
||||||
|
sccache --start-server 2>/dev/null || true
|
||||||
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log
|
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log
|
||||||
|
sccache --show-stats
|
||||||
ls -lh target/debug/botserver
|
ls -lh target/debug/botserver
|
||||||
|
|
||||||
- name: Save build log
|
- name: Save build log
|
||||||
if: always()
|
if: always()
|
||||||
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
run: cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
||||||
|
|
||||||
- name: Deploy via ssh tar gzip
|
- name: Deploy via ssh tar gzip
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
echo "=== Deploy started ==="
|
echo "=== Deploy started ==="
|
||||||
echo "Step 1: Checking binary..."
|
echo "Step 1: Checking binary..."
|
||||||
ls -lh /opt/gbo/ci/botserver/target/debug/botserver
|
ls -lh /opt/gbo/data/botserver/target/debug/botserver
|
||||||
echo "Step 2: Killing old botserver..."
|
echo "Step 2: Killing old botserver..."
|
||||||
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "pgrep -f botserver && killall botserver 2>/dev/null || echo 'No running botserver'"
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "pgrep -f botserver && killall botserver 2>/dev/null || echo 'No running botserver'"
|
||||||
echo "Step 3: Removing old binary..."
|
echo "Step 3: Removing old binary..."
|
||||||
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'"
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'"
|
||||||
echo "Step 4: Starting tar+gzip transfer..."
|
echo "Step 4: Starting tar+gzip transfer..."
|
||||||
tar cf - -C /opt/gbo/ci/botserver/target/debug botserver | gzip -1 | ssh -o StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=10 system "gzip -d | tar xf - -C /opt/gbo/bin && echo 'Transfer complete'"
|
tar cf - -C /opt/gbo/data/botserver/target/debug botserver | gzip -1 | ssh -o StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=10 system "gzip -d | tar xf - -C /opt/gbo/bin && echo 'Transfer complete'"
|
||||||
echo "Step 5: Verifying transfer..."
|
echo "Step 5: Verifying transfer..."
|
||||||
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "ls -lh /opt/gbo/bin/botserver"
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "ls -lh /opt/gbo/bin/botserver"
|
||||||
echo "Step 6: Setting permissions..."
|
echo "Step 6: Setting permissions..."
|
||||||
|
|
@ -95,4 +101,4 @@ jobs:
|
||||||
|
|
||||||
- name: Save deploy log
|
- name: Save deploy log
|
||||||
if: always()
|
if: always()
|
||||||
run: sudo cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true
|
run: cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue