Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbf2e9a7c1 | ||
|
|
1377abe248 |
@@ -68,35 +68,26 @@ jobs:
|
|||||||
runs-on: anvil
|
runs-on: anvil
|
||||||
needs: build
|
needs: build
|
||||||
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
||||||
container:
|
# Run directly on host (no container) to access local network
|
||||||
image: docker.io/espressif/idf:v5.3
|
|
||||||
options: --network host
|
|
||||||
volumes:
|
|
||||||
- /var/cache/ccache:/ccache
|
|
||||||
env:
|
|
||||||
CCACHE_DIR: /ccache
|
|
||||||
IDF_CCACHE_ENABLE: 1
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install tools
|
|
||||||
run: |
|
|
||||||
apt-get update && apt-get install -y --no-install-recommends netcat-openbsd curl jq ccache
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=1 --branch=${{ github.ref_name }} \
|
git clone --depth=1 --branch=${{ github.ref_name }} \
|
||||||
https://oauth2:${{ github.token }}@git.mymx.me/${{ github.repository }}.git .
|
https://oauth2:${{ github.token }}@git.mymx.me/${{ github.repository }}.git workspace
|
||||||
|
cd workspace
|
||||||
|
|
||||||
- name: Build firmware
|
- name: Build firmware
|
||||||
run: |
|
run: |
|
||||||
. /opt/esp/idf/export.sh
|
cd workspace
|
||||||
|
. $HOME/esp/esp-idf/export.sh
|
||||||
cd get-started/csi_recv_router
|
cd get-started/csi_recv_router
|
||||||
idf.py build
|
idf.py build
|
||||||
ccache --show-stats | head -5
|
|
||||||
|
|
||||||
- name: Create release and upload firmware
|
- name: Create release and upload firmware
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ github.token }}
|
GITEA_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
|
cd workspace
|
||||||
TAG="${{ github.ref_name }}"
|
TAG="${{ github.ref_name }}"
|
||||||
REPO="${{ github.repository }}"
|
REPO="${{ github.repository }}"
|
||||||
API_URL="https://git.mymx.me/api/v1"
|
API_URL="https://git.mymx.me/api/v1"
|
||||||
@@ -129,9 +120,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Deploy via OTA
|
- name: Deploy via OTA
|
||||||
run: |
|
run: |
|
||||||
|
cd workspace
|
||||||
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
||||||
OTA_PORT=8899
|
OTA_PORT=8899
|
||||||
MAX_PARALLEL=3
|
EXPECTED_VERSION="${{ github.ref_name }}"
|
||||||
|
|
||||||
# Get runner IP (first non-loopback interface)
|
# Get runner IP (first non-loopback interface)
|
||||||
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
||||||
@@ -149,38 +141,65 @@ jobs:
|
|||||||
# Verify server is running
|
# Verify server is running
|
||||||
curl -sI "http://localhost:${OTA_PORT}/csi_recv_router.bin" | head -1
|
curl -sI "http://localhost:${OTA_PORT}/csi_recv_router.bin" | head -1
|
||||||
|
|
||||||
# Deploy function
|
# Deploy to all sensors in parallel
|
||||||
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 ==="
|
echo "=== Deploying to all sensors in parallel ==="
|
||||||
PIDS=""
|
|
||||||
for entry in $SENSORS; do
|
for entry in $SENSORS; do
|
||||||
NAME="${entry%%:*}"
|
NAME="${entry%%:*}"
|
||||||
IP="${entry##*:}"
|
IP="${entry##*:}"
|
||||||
deploy_sensor "$NAME" "$IP" "$FIRMWARE_URL" &
|
echo "OTA $FIRMWARE_URL" | nc -u -w 2 "$IP" 5501 &
|
||||||
PIDS="$PIDS $!"
|
|
||||||
done
|
done
|
||||||
|
wait
|
||||||
|
|
||||||
# Wait for all OTA commands to be sent
|
# Monitor progress
|
||||||
for PID in $PIDS; do
|
echo "=== Monitoring OTA progress (timeout: 90s) ==="
|
||||||
wait $PID 2>/dev/null || true
|
TIMEOUT=90
|
||||||
|
INTERVAL=5
|
||||||
|
ELAPSED=0
|
||||||
|
|
||||||
|
while [ $ELAPSED -lt $TIMEOUT ]; do
|
||||||
|
sleep $INTERVAL
|
||||||
|
ELAPSED=$((ELAPSED + INTERVAL))
|
||||||
|
|
||||||
|
echo "--- Progress check at ${ELAPSED}s ---"
|
||||||
|
ALL_UPDATED=true
|
||||||
|
|
||||||
|
for entry in $SENSORS; do
|
||||||
|
NAME="${entry%%:*}"
|
||||||
|
IP="${entry##*:}"
|
||||||
|
|
||||||
|
# Query sensor version via UDP STATUS command
|
||||||
|
RESPONSE=$(echo "STATUS" | nc -u -w 1 "$IP" 5501 2>/dev/null || echo "")
|
||||||
|
VERSION=$(echo "$RESPONSE" | grep -oP 'version=\K[^ ]+' || echo "offline")
|
||||||
|
|
||||||
|
if [ "$VERSION" = "$EXPECTED_VERSION" ]; then
|
||||||
|
echo " $NAME: ✓ $VERSION"
|
||||||
|
elif [ "$VERSION" = "offline" ] || [ -z "$VERSION" ]; then
|
||||||
|
echo " $NAME: ⟳ updating..."
|
||||||
|
ALL_UPDATED=false
|
||||||
|
else
|
||||||
|
echo " $NAME: $VERSION (waiting for $EXPECTED_VERSION)"
|
||||||
|
ALL_UPDATED=false
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$ALL_UPDATED" = true ]; then
|
||||||
|
echo "=== All sensors updated to $EXPECTED_VERSION ==="
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "=== OTA commands sent, waiting for devices to update (60s) ==="
|
|
||||||
sleep 60
|
|
||||||
|
|
||||||
# Stop HTTP server
|
# Stop HTTP server
|
||||||
kill $HTTP_PID 2>/dev/null || true
|
kill $HTTP_PID 2>/dev/null || true
|
||||||
|
|
||||||
echo "=== Deployment complete ==="
|
# Final status
|
||||||
|
echo "=== Final sensor status ==="
|
||||||
|
for entry in $SENSORS; do
|
||||||
|
NAME="${entry%%:*}"
|
||||||
|
IP="${entry##*:}"
|
||||||
|
RESPONSE=$(echo "STATUS" | nc -u -w 1 "$IP" 5501 2>/dev/null || echo "")
|
||||||
|
VERSION=$(echo "$RESPONSE" | grep -oP 'version=\K[^ ]+' || echo "offline")
|
||||||
|
echo " $NAME: $VERSION"
|
||||||
|
done
|
||||||
|
|
||||||
cppcheck:
|
cppcheck:
|
||||||
name: C/C++ Static Analysis
|
name: C/C++ Static Analysis
|
||||||
|
|||||||
Reference in New Issue
Block a user