ci: Fixed workspace path for incremental builds, no more full recompile
This commit is contained in:
parent
d0b527a4a8
commit
1fb1e06bdb
1 changed files with 43 additions and 20 deletions
|
|
@ -9,6 +9,8 @@ on:
|
||||||
env:
|
env:
|
||||||
CARGO_BUILD_JOBS: 8
|
CARGO_BUILD_JOBS: 8
|
||||||
CARGO_NET_RETRY: 10
|
CARGO_NET_RETRY: 10
|
||||||
|
WORKSPACE: /opt/gbo/ci/botserver
|
||||||
|
CARGO_TARGET_DIR: /opt/gbo/ci/botserver/target
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -20,19 +22,39 @@ jobs:
|
||||||
|
|
||||||
- name: Setup Workspace
|
- name: Setup Workspace
|
||||||
run: |
|
run: |
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git workspace
|
mkdir -p $WORKSPACE
|
||||||
cd workspace
|
cd $WORKSPACE
|
||||||
git submodule update --init --depth 1 botlib
|
# Update or clone botlib
|
||||||
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver-ci
|
if [ -d botlib/.git ]; then
|
||||||
rm -rf botserver && mv botserver-ci botserver
|
git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD
|
||||||
sed -i '/"botapp",/d' Cargo.toml
|
else
|
||||||
sed -i '/"botdevice",/d' Cargo.toml
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
||||||
sed -i '/"bottest",/d' Cargo.toml
|
fi
|
||||||
sed -i '/"botui",/d' Cargo.toml
|
# Update or clone botserver
|
||||||
sed -i '/"botbook",/d' Cargo.toml
|
if [ -d botserver/.git ]; then
|
||||||
sed -i '/"botmodels",/d' Cargo.toml
|
git -C botserver fetch --depth 1 origin main && git -C botserver checkout FETCH_HEAD
|
||||||
sed -i '/"botplugin",/d' Cargo.toml
|
else
|
||||||
sed -i '/"bottemplates",/d' Cargo.toml
|
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
||||||
|
fi
|
||||||
|
# Write minimal Cargo.toml workspace
|
||||||
|
cat > Cargo.toml << 'EOF'
|
||||||
|
[workspace]
|
||||||
|
members = ["botlib", "botserver"]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
[workspace.lints.rust]
|
||||||
|
unsafe_code = "forbid"
|
||||||
|
|
||||||
|
[workspace.lints.clippy]
|
||||||
|
all = "warn"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level = "z"
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
strip = true
|
||||||
|
panic = "abort"
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -46,15 +68,17 @@ jobs:
|
||||||
|
|
||||||
- name: Install sccache
|
- name: Install sccache
|
||||||
run: |
|
run: |
|
||||||
|
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
|
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
|
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
|
mv sccache-v0.8.2-x86_64-unknown-linux-musl/sccache $HOME/.cargo/bin/sccache
|
||||||
chmod +x $HOME/.cargo/bin/sccache
|
chmod +x $HOME/.cargo/bin/sccache
|
||||||
|
fi
|
||||||
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
|
||||||
$HOME/.cargo/bin/sccache --start-server || true
|
$HOME/.cargo/bin/sccache --start-server || true
|
||||||
|
|
||||||
- name: Build BotServer
|
- name: Build BotServer
|
||||||
working-directory: workspace
|
working-directory: /opt/gbo/ci/botserver
|
||||||
run: |
|
run: |
|
||||||
cargo build -p botserver -j 8 2>&1 | tee /tmp/build.log
|
cargo build -p botserver -j 8 2>&1 | tee /tmp/build.log
|
||||||
ls -lh target/debug/botserver
|
ls -lh target/debug/botserver
|
||||||
|
|
@ -65,12 +89,11 @@ jobs:
|
||||||
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
|
||||||
|
|
||||||
- name: Deploy via SSH
|
- name: Deploy via SSH
|
||||||
working-directory: workspace
|
|
||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 pragmatismo-system "pkill -f /opt/gbo/bin/botserver; sleep 2; rm -f /opt/gbo/bin/botserver" 2>&1 | tee /tmp/deploy.log
|
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 pragmatismo-system "pkill -f /opt/gbo/bin/botserver; sleep 2; rm -f /opt/gbo/bin/botserver" 2>&1 | tee /tmp/deploy.log
|
||||||
echo "--- scp start ---" >> /tmp/deploy.log
|
echo "--- scp start ---" >> /tmp/deploy.log
|
||||||
scp -o StrictHostKeyChecking=no target/debug/botserver pragmatismo-system:/opt/gbo/bin/botserver 2>&1 | tee -a /tmp/deploy.log
|
scp -o StrictHostKeyChecking=no /opt/gbo/ci/botserver/target/debug/botserver pragmatismo-system:/opt/gbo/bin/botserver 2>&1 | tee -a /tmp/deploy.log
|
||||||
SCP_EXIT=${PIPESTATUS[0]}
|
SCP_EXIT=${PIPESTATUS[0]}
|
||||||
echo "scp exit: $SCP_EXIT" >> /tmp/deploy.log
|
echo "scp exit: $SCP_EXIT" >> /tmp/deploy.log
|
||||||
if [ "$SCP_EXIT" = "0" ]; then
|
if [ "$SCP_EXIT" = "0" ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue