From 974ffadb1c85eac61fca15f959c05b7e0927a44c Mon Sep 17 00:00:00 2001 From: user Date: Thu, 5 Feb 2026 22:42:49 +0100 Subject: [PATCH] ci: Add firmware size check and version tag validation - Fail build if binary exceeds 1920 KB partition - Warn at 85% capacity - Warn if git tag differs from embedded version --- .gitea/workflows/lint.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index d830a36..6199d46 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -54,6 +54,26 @@ jobs: run: | ls -lh get-started/csi_recv_router/build/*.bin + - name: Check firmware size + run: | + BIN="get-started/csi_recv_router/build/csi_recv_router.bin" + MAX_SIZE=1966080 # 0x1E0000 = 1920 KB partition + WARN_PERCENT=85 + + SIZE=$(stat -c%s "$BIN") + PERCENT=$((SIZE * 100 / MAX_SIZE)) + + echo "Firmware: $((SIZE/1024)) KB / $((MAX_SIZE/1024)) KB ($PERCENT%)" + + if [ $SIZE -gt $MAX_SIZE ]; then + echo "::error::Firmware exceeds partition size!" + exit 1 + fi + + if [ $PERCENT -gt $WARN_PERCENT ]; then + echo "::warning::Firmware using $PERCENT% of partition" + fi + - name: Upload firmware artifact run: | mkdir -p /tmp/artifacts @@ -82,6 +102,20 @@ jobs: run: | cd workspace && . $HOME/esp/esp-idf/export.sh && cd get-started/csi_recv_router && idf.py build + - name: Validate version tag + working-directory: workspace + run: | + TAG="${{ github.ref_name }}" + # Extract version from binary metadata + BIN_VER=$(strings get-started/csi_recv_router/build/csi_recv_router.bin | grep -oP '^v\d+\.\d+(\.\d+)?' | head -1) + + echo "Git tag: $TAG" + echo "Binary version: $BIN_VER" + + if [ "$TAG" != "$BIN_VER" ]; then + echo "::warning::Tag ($TAG) differs from binary ($BIN_VER)" + fi + - name: Create release and upload firmware env: GITEA_TOKEN: ${{ github.token }}