Преглед изворни кода

cache: enable OnePlus proven flow, add use_cache (default on)

Restore/save were disabled (if: false). Wire use_cache boolean
through main -> prepare -> build (default true, matches OnePlus clean=false).
Gate Setup Cache, ccache restore/save (5.10/5.15) and bazel restore/save (5.15/6.1/6.6/6.12)
on inputs.use_cache; saves now always() like OnePlus and include 12h ccache eviction.
TheWildJames пре 1 недеља
родитељ
комит
9fc528480d
3 измењених фајлова са 39 додато и 5 уклоњено
  1. 21 4
      .github/workflows/build.yml
  2. 11 0
      .github/workflows/main.yml
  3. 7 1
      .github/workflows/prepare.yml

+ 21 - 4
.github/workflows/build.yml

@@ -67,6 +67,11 @@ on:
         required: false
         type: boolean
         default: false
+      use_cache:
+        description: "Enable ccache/bazel cache (restore/save via release buckets)"
+        required: false
+        type: boolean
+        default: true
 
 jobs:
   build-gki:
@@ -388,6 +393,7 @@ jobs:
       continue-on-error: true
 
     - name: 'Setup Cache and Build Environment'
+      if: inputs.use_cache
       uses: ./.github/actions/cache-setup
       with:
         version: ${{ inputs.version }}
@@ -398,7 +404,7 @@ jobs:
     - name: Restore ccache
       id: restore-ccache
       continue-on-error: true
-      if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
+      if: inputs.use_cache && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
       uses: ./.github/actions/cache-restore
       with:
         cache_path: /home/runner/.ccache
@@ -410,7 +416,7 @@ jobs:
     - name: Restore bazel-cache
       id: restore-bazel
       continue-on-error: true
-      if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
+      if: inputs.use_cache && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
       uses: ./.github/actions/cache-restore
       with:
         cache_path: /home/runner/.cache/bazel
@@ -478,10 +484,21 @@ jobs:
       with:
         clear_stats: false
 
+    - name: Prune ccache before save
+      if: always() && inputs.use_cache && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
+      shell: bash
+      run: |
+        if [ -d /home/runner/.ccache ]; then
+          ccache -c 2>/dev/null || true
+          find /home/runner/.ccache -type f -mtime +0.5 -delete 2>/dev/null || true
+          find /home/runner/.ccache -type d -empty -delete 2>/dev/null || true
+          echo "ccache pruned"; ccache -s 2>/dev/null | head -20 || true
+        fi
+
     - name: Save ccache
       continue-on-error: true
       uses: ./.github/actions/cache-save
-      if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
+      if: always() && inputs.use_cache && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
       with:
         cache_path: /home/runner/.ccache
         cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
@@ -492,7 +509,7 @@ jobs:
     - name: Save bazel-cache
       continue-on-error: true
       uses: ./.github/actions/cache-save
-      if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
+      if: always() && inputs.use_cache && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
       with:
         cache_path: /home/runner/.cache/bazel
         cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}

+ 11 - 0
.github/workflows/main.yml

@@ -99,6 +99,10 @@ on:
         description: "Apply kernel version-check bypass hack"
         type: boolean
         default: false
+      use_cache:
+        description: "Use ccache/bazel cache (restore/save)"
+        type: boolean
+        default: true
 
 jobs:
   prepare-ccache:
@@ -626,6 +630,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   build-android13-5-10:
@@ -655,6 +660,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   build-android13-5-15:
@@ -684,6 +690,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   build-android14-5-15:
@@ -713,6 +720,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   build-android14-6-1:
@@ -742,6 +750,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   build-android15-6-6:
@@ -771,6 +780,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   build-android16-6-12:
@@ -800,6 +810,7 @@ jobs:
       brand_name: ${{ inputs.brand_name }}
       os_patch_level: ${{ inputs.os_patch_level }}
       bypass: ${{ inputs.bypass }}
+      use_cache: ${{ inputs.use_cache }}
     secrets: inherit
 
   update-verified-pins:

+ 7 - 1
.github/workflows/prepare.yml

@@ -61,6 +61,11 @@ on:
         required: false
         type: boolean
         default: false
+      use_cache:
+        description: "Enable ccache/bazel cache"
+        required: false
+        type: boolean
+        default: true
       os_patch_level:
         description: "Optional filter: patch date (YYYY-MM), kernel sublevel, lts (LTS branch), or all"
         required: false
@@ -175,4 +180,5 @@ jobs:
       droidspaces_commit: ${{ inputs.droidspaces_commit }}
       brand_name: ${{ inputs.brand_name }}
       bypass: ${{ inputs.bypass }}
-    secrets: inherit
+      use_cache: ${{ inputs.use_cache }}
+    secrets: inherit