Update CI: use sccache, separate target dir per project, shared cargo cache
Some checks failed
BotServer CI/CD / build (push) Failing after 3s
Some checks failed
BotServer CI/CD / build (push) Failing after 3s
This commit is contained in:
parent
3a027e6619
commit
5272b308f7
1 changed files with 21 additions and 16 deletions
|
|
@ -6,20 +6,26 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_BUILD_JOBS: 8
|
CARGO_BUILD_JOBS: 8
|
||||||
|
RUSTC_WRAPPER: sccache
|
||||||
|
CARGO_TARGET_DIR: /home/gbuser/workspace/botserver-target
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: gbo
|
runs-on: gbo
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Setup environment
|
||||||
|
run: |
|
||||||
|
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
||||||
|
sccache --start-server 2>/dev/null || true
|
||||||
|
|
||||||
- name: Clone and Build
|
- name: Clone and Build
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Setup directories
|
# Setup project workspace
|
||||||
mkdir -p ~/workspace ~/cache
|
mkdir -p ~/workspace/botserver
|
||||||
|
cd ~/workspace/botserver
|
||||||
cd ~/workspace
|
|
||||||
|
|
||||||
# Clone or update repos
|
# Clone or update repos
|
||||||
if [ ! -d botlib ]; then
|
if [ ! -d botlib ]; then
|
||||||
|
|
@ -28,34 +34,33 @@ jobs:
|
||||||
cd botlib && git pull && cd ..
|
cd botlib && git pull && cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d botserver ]; then
|
if [ ! -d src ]; then
|
||||||
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 src
|
||||||
else
|
else
|
||||||
cd botserver && git pull && cd ..
|
cd src && git pull && cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d ~/gb-ws ]; then
|
if [ ! -d ~/workspace/gb-ws ]; then
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git ~/gb-ws
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git ~/workspace/gb-ws
|
||||||
else
|
else
|
||||||
cd ~/gb-ws && git pull && cd ~/workspace
|
cd ~/workspace/gb-ws && git pull && cd ~/workspace/botserver
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup Cargo.toml
|
# Setup Cargo.toml
|
||||||
cp ~/gb-ws/Cargo.toml ~/workspace/Cargo.toml
|
cp ~/workspace/gb-ws/Cargo.toml .
|
||||||
sed -i '/botapp\|botdevice\|bottest\|botui\|botbook\|botmodels\|botplugin\|bottemplates/d' ~/workspace/Cargo.toml
|
sed -i '/botapp\|botdevice\|bottest\|botui\|botbook\|botmodels\|botplugin\|bottemplates/d' Cargo.toml
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
export PATH="/home/gbuser/.cargo/bin:/home/gbuser/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:$PATH"
|
|
||||||
export CARGO_TARGET_DIR=~/workspace/target
|
|
||||||
cargo build -p botserver
|
cargo build -p botserver
|
||||||
|
sccache --show-stats
|
||||||
|
|
||||||
ls -lh target/debug/botserver
|
ls -lh $CARGO_TARGET_DIR/debug/botserver
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
run: |
|
run: |
|
||||||
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
SSH="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
|
||||||
ssh $SSH system "sudo systemctl stop botserver || true; sleep 2"
|
ssh $SSH system "sudo systemctl stop botserver || true; sleep 2"
|
||||||
scp $SSH ~/workspace/target/debug/botserver system:/tmp/botserver
|
scp $SSH $CARGO_TARGET_DIR/debug/botserver system:/tmp/botserver
|
||||||
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"
|
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"
|
||||||
sleep 5
|
sleep 5
|
||||||
ssh $SSH system "curl -sf http://localhost:5858/api/health && echo Deployed"
|
ssh $SSH system "curl -sf http://localhost:5858/api/health && echo Deployed"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue