diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7381e85..eacca9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -217,6 +217,16 @@ jobs: ./xupdate.sh -f mkdir -p logs echo "status=success" >> $GITHUB_OUTPUT + rm -rf staging_dir/ + mkdir -p staging_dir/host + + - name: Restore cache for host tools + id: tools_cache_restore + uses: actions/cache/restore@v4 + with: + key: host-tools-${{ runner.os }}-${{ env.FW_VER }}-${{ hashFiles('tools/**') }} + path: | + staging_dir/host - name: Configure id: configure @@ -256,33 +266,17 @@ jobs: cat .config echo "========================" - - name: Prepare for use cache of tools and toolchain - run: | - echo "G_TARGET_ARCH = $G_TARGET_ARCH" - rm -rf staging_dir/ - rm -rf build_dir/ - - - name: Cache host tools - uses: actions/cache@v4 - with: - path: staging_dir/host - key: host-tools-${{ runner.os }}-${{ hashFiles('tools/**') }} - restore-keys: | - host-tools-${{ runner.os }}- - - - name: Cache toolchain - uses: actions/cache@v4 - with: - path: staging_dir/toolchain-* - key: toolchain-${{ env.G_TARGET_ARCH }}-${{ hashFiles('toolchain/**') }} - restore-keys: | - toolchain-${{ env.G_TARGET_ARCH }}- - - name: Monitor memory run: | - free -h - cat /proc/meminfo - + echo "CPU cores = $(nproc)" + echo "Memory and swap:" + sudo free -h + echo + sudo swapon --show + echo + echo "Available storage:" + sudo df -h + - name: Build tools and toolchain id: tools if: ${{ steps.configure.outputs.status == 'success' && github.event.inputs.fake_build != 'true' }} @@ -291,18 +285,13 @@ jobs: echo "status=success" >> $GITHUB_OUTPUT - name: Save cache for host tools - if: ${{ steps.tools.outputs.status == 'success' && github.event.inputs.fake_build != 'true' }} - uses: actions/cache@v4 + id: tools_cache_save + if: steps.tools.outputs.status == 'success' && steps.tools_cache_restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 with: - path: staging_dir/host - key: host-tools-${{ runner.os }}-${{ hashFiles('tools/**') }} - - - name: Save cache for toolchain - if: ${{ steps.tools.outputs.status == 'success' && github.event.inputs.fake_build != 'true' }} - uses: actions/cache@v4 - with: - path: staging_dir/toolchain-* - key: toolchain-${{ env.G_TARGET_ARCH }}-${{ hashFiles('toolchain/**') }} + key: ${{ steps.tools_cache_restore.outputs.cache-primary-key }} + path: | + staging_dir/host - name: Kernel compile id: kernel @@ -313,8 +302,13 @@ jobs: - name: Monitor memory 2 run: | - free -h - cat /proc/meminfo + echo "Memory and swap:" + sudo free -h + echo + sudo swapon --show + echo + echo "Available storage:" + sudo df -h - name: Build the firmware image id: compile @@ -371,6 +365,13 @@ jobs: - name: Check space usage run: df -hT + - name: Check OOM error + if: failure() + run: | + dmesg | grep -i -E 'oom|killed process' || true + echo "================== Memory =================" + free -h + - name: Compress build logs if: always() env: