ci: Add ccache for faster builds + parallel OTA deployment
Some checks failed
Lint & Build / C/C++ Static Analysis (push) Failing after 32s
Lint & Build / Security Flaw Analysis (push) Successful in 21s
Lint & Build / Secret Scanning (push) Successful in 8s
Lint & Build / Shell Script Analysis (push) Successful in 10s
Lint & Build / Build Firmware (push) Successful in 2m7s
Lint & Build / Deploy to ESP Fleet (push) Successful in 3m0s
Some checks failed
Lint & Build / C/C++ Static Analysis (push) Failing after 32s
Lint & Build / Security Flaw Analysis (push) Successful in 21s
Lint & Build / Secret Scanning (push) Successful in 8s
Lint & Build / Shell Script Analysis (push) Successful in 10s
Lint & Build / Build Firmware (push) Successful in 2m7s
Lint & Build / Deploy to ESP Fleet (push) Successful in 3m0s
Build improvements: - Enable ccache via IDF_CCACHE_ENABLE=1 - Mount /var/cache/ccache volume for persistent cache - Show ccache stats after build Deployment improvements: - Deploy to all sensors in parallel (max 3) - Reduced total deploy time from ~2.5min to ~1min Note: Runner needs /var/cache/ccache directory with write permissions
This commit is contained in:
@@ -23,18 +23,32 @@ jobs:
|
||||
runs-on: anvil
|
||||
container:
|
||||
image: docker.io/espressif/idf:v5.3
|
||||
volumes:
|
||||
- /var/cache/ccache:/ccache
|
||||
env:
|
||||
CCACHE_DIR: /ccache
|
||||
IDF_CCACHE_ENABLE: 1
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth=1 --branch=${{ github.ref_name }} \
|
||||
https://oauth2:${{ github.token }}@git.mymx.me/${{ github.repository }}.git .
|
||||
|
||||
- name: Setup ccache
|
||||
run: |
|
||||
apt-get update && apt-get install -y --no-install-recommends ccache
|
||||
ccache --zero-stats
|
||||
ccache --show-config | grep -E "(cache_dir|max_size)"
|
||||
|
||||
- name: Build firmware
|
||||
run: |
|
||||
. /opt/esp/idf/export.sh
|
||||
cd get-started/csi_recv_router
|
||||
idf.py build
|
||||
|
||||
- name: Show ccache stats
|
||||
run: ccache --show-stats
|
||||
|
||||
- name: Show binary size
|
||||
run: |
|
||||
ls -lh get-started/csi_recv_router/build/*.bin
|
||||
@@ -57,10 +71,15 @@ jobs:
|
||||
container:
|
||||
image: docker.io/espressif/idf:v5.3
|
||||
options: --network host
|
||||
volumes:
|
||||
- /var/cache/ccache:/ccache
|
||||
env:
|
||||
CCACHE_DIR: /ccache
|
||||
IDF_CCACHE_ENABLE: 1
|
||||
steps:
|
||||
- name: Install tools
|
||||
run: |
|
||||
apt-get update && apt-get install -y --no-install-recommends netcat-openbsd curl jq
|
||||
apt-get update && apt-get install -y --no-install-recommends netcat-openbsd curl jq ccache
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
@@ -72,6 +91,7 @@ jobs:
|
||||
. /opt/esp/idf/export.sh
|
||||
cd get-started/csi_recv_router
|
||||
idf.py build
|
||||
ccache --show-stats | head -5
|
||||
|
||||
- name: Create release and upload firmware
|
||||
env:
|
||||
@@ -110,8 +130,8 @@ jobs:
|
||||
- name: Deploy via OTA
|
||||
run: |
|
||||
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
||||
FIRMWARE_PATH="get-started/csi_recv_router/build/csi_recv_router.bin"
|
||||
OTA_PORT=8899
|
||||
MAX_PARALLEL=3
|
||||
|
||||
# Get runner IP (first non-loopback interface)
|
||||
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
||||
@@ -129,15 +149,34 @@ jobs:
|
||||
# Verify server is running
|
||||
curl -sI "http://localhost:${OTA_PORT}/csi_recv_router.bin" | head -1
|
||||
|
||||
# Deploy to each sensor
|
||||
# Deploy function
|
||||
deploy_sensor() {
|
||||
NAME="$1"
|
||||
IP="$2"
|
||||
URL="$3"
|
||||
echo "=== Starting OTA on $NAME ($IP) ==="
|
||||
RESPONSE=$(echo "OTA $URL" | nc -u -w 2 "$IP" 5501 2>/dev/null || echo "no response")
|
||||
echo "$NAME: $RESPONSE"
|
||||
}
|
||||
|
||||
# Deploy to all sensors in parallel (max $MAX_PARALLEL)
|
||||
echo "=== Deploying to all sensors in parallel ==="
|
||||
PIDS=""
|
||||
for entry in $SENSORS; do
|
||||
NAME="${entry%%:*}"
|
||||
IP="${entry##*:}"
|
||||
echo "=== Deploying to $NAME ($IP) ==="
|
||||
echo "OTA $FIRMWARE_URL" | nc -u -w 2 "$IP" 5501 || true
|
||||
sleep 45
|
||||
deploy_sensor "$NAME" "$IP" "$FIRMWARE_URL" &
|
||||
PIDS="$PIDS $!"
|
||||
done
|
||||
|
||||
# Wait for all OTA commands to be sent
|
||||
for PID in $PIDS; do
|
||||
wait $PID 2>/dev/null || true
|
||||
done
|
||||
|
||||
echo "=== OTA commands sent, waiting for devices to update (60s) ==="
|
||||
sleep 60
|
||||
|
||||
# Stop HTTP server
|
||||
kill $HTTP_PID 2>/dev/null || true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user