ci: check for changes before building, optimize git fetch
All checks were successful
BotServer CI/CD / build (push) Successful in 1m23s
All checks were successful
BotServer CI/CD / build (push) Successful in 1m23s
This commit is contained in:
parent
6fdf2b1fd1
commit
8e56fc5828
1 changed files with 53 additions and 7 deletions
|
|
@ -28,30 +28,64 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mkdir -p $WORKSPACE
|
mkdir -p $WORKSPACE
|
||||||
cd $WORKSPACE
|
cd $WORKSPACE
|
||||||
# Update or clone botlib (preserve git history for sccache fingerprints)
|
|
||||||
|
# Fetch latest changes first
|
||||||
|
echo "=== Checking for updates ==="
|
||||||
|
|
||||||
|
# Update or clone botlib
|
||||||
if [ -d botlib/.git ]; then
|
if [ -d botlib/.git ]; then
|
||||||
git -C botlib pull origin main
|
echo "Updating botlib..."
|
||||||
|
git -C botlib fetch origin main
|
||||||
|
if ! git -C botlib diff origin/main --quiet 2>/dev/null; then
|
||||||
|
echo "botlib has changes, pulling..."
|
||||||
|
git -C botlib pull --ff-only origin main
|
||||||
|
else
|
||||||
|
echo "botlib up to date"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git clone --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
git clone --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
|
||||||
fi
|
fi
|
||||||
# Update or clone botserver (preserve git history for sccache fingerprints)
|
|
||||||
|
# Update or clone botserver
|
||||||
if [ -d botserver/.git ]; then
|
if [ -d botserver/.git ]; then
|
||||||
git -C botserver pull origin main
|
echo "Updating botserver..."
|
||||||
|
git -C botserver fetch origin main
|
||||||
|
if ! git -C botserver diff origin/main --quiet 2>/dev/null; then
|
||||||
|
echo "botserver has changes, pulling..."
|
||||||
|
git -C botserver pull --ff-only origin main
|
||||||
|
else
|
||||||
|
echo "botserver up to date"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git clone --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
|
git clone --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
|
||||||
if [ -d /opt/gbo/data/gb-ws/.git ]; then
|
if [ -d /opt/gbo/data/gb-ws/.git ]; then
|
||||||
git -C /opt/gbo/data/gb-ws pull origin main
|
git -C /opt/gbo/data/gb-ws fetch origin main
|
||||||
|
if ! git -C /opt/gbo/data/gb-ws diff origin/main --quiet 2>/dev/null; then
|
||||||
|
echo "gb-ws has changes, pulling..."
|
||||||
|
git -C /opt/gbo/data/gb-ws pull --ff-only origin main
|
||||||
|
else
|
||||||
|
echo "gb-ws up to date"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
git clone --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/data/gb-ws
|
git clone --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /opt/gbo/data/gb-ws
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Only rebuild if there were actual changes
|
||||||
|
echo "$WORKSPACE" > /tmp/workspace_path
|
||||||
|
|
||||||
cp /opt/gbo/data/gb-ws/Cargo.toml Cargo.toml
|
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
|
||||||
|
|
||||||
# Ensure target dir exists (use persistent location for sccache)
|
# Ensure target dir exists (use persistent location for sccache)
|
||||||
mkdir -p /opt/gbo/data/botserver/target
|
mkdir -p /opt/gbo/data/botserver/target
|
||||||
|
|
||||||
|
# Pre-fetch dependencies
|
||||||
|
cargo fetch 2>/dev/null || true
|
||||||
|
|
||||||
- name: Cache sccache
|
- name: Cache sccache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
|
|
@ -83,7 +117,19 @@ jobs:
|
||||||
sccache --stop-server 2>/dev/null || true
|
sccache --stop-server 2>/dev/null || true
|
||||||
sleep 1
|
sleep 1
|
||||||
sccache --start-server
|
sccache --start-server
|
||||||
|
|
||||||
|
# Check if there are changes to rebuild
|
||||||
|
CHANGES=$(git -C /opt/gbo/data/botserver/botserver diff origin/main --name-only 2>/dev/null || echo "changed")
|
||||||
|
if [ -z "$CHANGES" ]; then
|
||||||
|
echo "No changes detected in botserver, checking if binary exists..."
|
||||||
|
if [ -f /opt/gbo/data/botserver/target/debug/botserver ]; then
|
||||||
|
echo "Binary already exists, skipping build"
|
||||||
|
echo "=== sccache stats (before) ==="
|
||||||
|
sccache --show-stats || true
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== Starting build in background ==="
|
echo "=== Starting build in background ==="
|
||||||
cargo build -p botserver -j 8 > /tmp/build.log 2>&1 &
|
cargo build -p botserver -j 8 > /tmp/build.log 2>&1 &
|
||||||
BUILD_PID=$!
|
BUILD_PID=$!
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue