This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a2d22e6089 ci: enable ccache persistence across CI workflow runs
1a2d22e6089 is described below

commit 1a2d22e6089eadf3f64972629860a65e106047f5
Author: Swatantra Yadav <[email protected]>
AuthorDate: Sun Oct 11 00:22:27 2026 +0530

    ci: enable ccache persistence across CI workflow runs
    
    Currently, Linux matrix jobs in .github/workflows/build.yml pass '-c' to 
cibuild.sh to enable ccache inside the Docker container, but the cache 
directory (sources/tools/ccache) is discarded upon container exit and runner 
teardown.
    
    This change enables persistent ccache caching across GitHub Actions 
workflow runs:
    1. Add an actions/cache@v6 step in build.yml to restore and save 
sources/tools/ccache per board matrix job.
    2. Add a post-build permission adjustment step so the runner user can 
archive Docker-created cache files without permission issues.
    3. Configure CCACHE_MAXSIZE (defaulting to 1G per board matrix job) in 
cibuild.sh to prevent unbounded repository cache consumption.
    4. Add the ccache wrapper directory to PATH in tools/ci/platforms/ubuntu.sh.
    
    Addresses #20483.
    
    Signed-off-by: Swatantra Yadav <[email protected]>
---
 .github/workflows/build.yml  | 15 +++++++++++++++
 tools/ci/cibuild.sh          |  1 +
 tools/ci/platforms/ubuntu.sh |  1 +
 3 files changed, 17 insertions(+)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f718d7f62e0..42e9001939f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -326,6 +326,14 @@ jobs:
       - name: Extract sources
         run: tar zxf sources.tar.gz
 
+      - name: Restore ccache
+        uses: actions/cache@v6
+        with:
+          path: sources/tools/ccache
+          key: ${{ runner.os }}-${{ matrix.boards }}-ccache-${{ github.sha }}
+          restore-keys: |
+            ${{ runner.os }}-${{ matrix.boards }}-ccache-
+
       - name: Docker Login
         uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f  # 
v4.6.0
         with:
@@ -395,6 +403,13 @@ jobs:
                 ./cibuild.sh -c -A -N -R -S testlist/${{matrix.boards}}.dat
             fi
 
+      - name: Prepare ccache for caching
+        if: always()
+        run: |
+          if [ -d sources/tools/ccache ]; then
+            sudo chmod -R a+rwX sources/tools/ccache
+          fi
+
       - name: Run host_info sanity check
         uses: ./sources/nuttx/.github/actions/ci-container
         with:
diff --git a/tools/ci/cibuild.sh b/tools/ci/cibuild.sh
index 1aea477655a..204472ee0b5 100755
--- a/tools/ci/cibuild.sh
+++ b/tools/ci/cibuild.sh
@@ -114,6 +114,7 @@ function usage {
 
 function enable_ccache {
   export CCACHE_DIR="${CIWORKSPACE}"/tools/ccache
+  export CCACHE_MAXSIZE="${CCACHE_MAXSIZE:-1G}"
 }
 
 function setup_repos {
diff --git a/tools/ci/platforms/ubuntu.sh b/tools/ci/platforms/ubuntu.sh
index 42a0597a5b3..8a0e3086d49 100755
--- a/tools/ci/platforms/ubuntu.sh
+++ b/tools/ci/platforms/ubuntu.sh
@@ -119,6 +119,7 @@ bloaty() {
 }
 
 c_cache() {
+  add_path "${NUTTXTOOLS}"/ccache/bin
   if ! type ccache > /dev/null 2>&1; then
     sudo apt-get install -y ccache
   fi

Reply via email to