Swatantra-66 opened a new pull request, #20580:
URL: https://github.com/apache/nuttx/pull/20580

   ## Summary
   
   Following the discussion in #20483 with @acassis and the suggestion from 
@casaroli, this PR implements the first phase of CI optimization: **enabling 
persistent `ccache` caching across GitHub Actions workflow runs**.
   
   ### Background & Problem
   In `.github/workflows/build.yml`, Linux matrix jobs already pass `-c` to 
`./cibuild.sh`, which configures `ccache` wrappers and tools inside the 
`ghcr.io/apache/nuttx/apache-nuttx-ci-linux` Docker container. However, because 
GitHub Actions did not configure `actions/cache` for the ccache directory 
(`sources/tools/ccache`), the entire cache was destroyed upon container 
teardown. As a result, every CI job compiled from scratch with an empty cache.
   
   ### Key Changes
   1. **GitHub Actions Cache Integration**:
      - Added `actions/cache@v6` in `.github/workflows/build.yml` for each 
board matrix job (`sources/tools/ccache`).
      - Keyed per board matrix: `${{ runner.os }}-${{ matrix.boards 
}}-ccache-${{ github.sha }}` with fallback `restore-keys: ${{ runner.os }}-${{ 
matrix.boards }}-ccache-` so matrix partitions (e.g. `arm-01`, `risc-v-01`, 
`sim-01`) maintain isolated, non-conflicting compiler caches.
   2. **Container Permission Adjustment**:
      - Added a post-build step (`sudo chmod -R a+rwX sources/tools/ccache`) 
with `if: always()` so the non-root runner user can archive Docker-created 
cache directories without permission errors.
   3. **Repository Cache Quota Protection**:
      - Configured `export CCACHE_MAXSIZE="${CCACHE_MAXSIZE:-1G}"` in 
`tools/ci/cibuild.sh` to cap disk usage per matrix job, preventing eviction 
from GitHub's 10GB repository cache limit.
   4. **Environment Path Fix**:
      - Added `add_path "${NUTTXTOOLS}"/ccache/bin` in 
`tools/ci/platforms/ubuntu.sh` for parity with `msys2.sh`.
   
   Addresses #20483 (Phase 1).
   
   ## Impact
   
   - **Build Process**: Substantially reduces compilation times for re-runs, 
sequential PR commits, and architecture rebuilds by reusing cached object files.
   - **Resource Utilization**: Bounded to 1GB per matrix partition to stay well 
within GitHub Actions repository storage quotas.
   - **Compatibility**: Completely non-breaking; fallback behavior maintains 
clean builds on cache misses.
   
   ## Testing
   
   - Verified script syntax and toolchain wrappers locally with 
`tools/checkpatch.sh` (0 warnings, 0 errors).
   - Validated YAML schema and indentation in `.github/workflows/build.yml`.
   - Verified directory path resolution: `CIWORKSPACE` 
(`/github/workspace/sources`) inside Docker maps directly to host runner path 
`sources/tools/ccache`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to