Explorar el Código

feat(action): add 'use_repo' input for kernel source downloading and enhance cleanup script

Co-authored-by: Copilot <copilot@github.com>
TheWildJames hace 4 meses
padre
commit
7ed54d93e2

+ 24 - 17
.github/actions/download-kernel/action.yml

@@ -11,6 +11,9 @@ inputs:
   os_patch_level:
     description: 'OS patch level (e.g., 2024-01)'
     required: true
+  use_repo:
+    description: 'Use repo for downloading kernel source'
+    required: false
 
 outputs:
   deprecated_branch:
@@ -20,26 +23,28 @@ outputs:
 runs:
   using: composite
   steps:
-    # - name: Initialize and Sync Kernel Repository
-    #   id: sync
-    #   shell: bash
-    #   working-directory: ${{ github.workspace }}/kernel
-    #   run: |
-    #     FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
-    #       repo init -u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --depth=1 --partial-clone --clone-filter=blob:limit=10M
-    #       REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
-    #     DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
-    #     DEPRECATED=false
-    #     if grep -q deprecated <<< $REMOTE_BRANCH; then
-    #       sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
-    #       echo "⚠ Note: Branch ${FORMATTED_BRANCH} is considered deprecated."
-    #       DEPRECATED=true
-    #     fi
-    #     echo "deprecated=$DEPRECATED" >> $GITHUB_OUTPUT
-    #     repo sync -c -j$(nproc --all) --fail-fast --no-tags --force-sync --no-clone-bundle
+    - name: Initialize and Sync Kernel Repository
+      if: ${{ inputs.use_repo }}
+      id: sync
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel
+      run: |
+        FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
+          repo init -u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --depth=1 --partial-clone --clone-filter=blob:limit=10M
+          REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
+        DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
+        DEPRECATED=false
+        if grep -q deprecated <<< $REMOTE_BRANCH; then
+          sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
+          echo "⚠ Note: Branch ${FORMATTED_BRANCH} is considered deprecated."
+          DEPRECATED=true
+        fi
+        echo "deprecated=$DEPRECATED" >> $GITHUB_OUTPUT
+        repo sync -c -j$(nproc --all) --fail-fast --no-tags --force-sync --no-clone-bundle
 
     - name: Download manifest.xml for branch (with deprecated fallback)
       shell: bash
+      if: ${{ !inputs.use_repo }}
       working-directory: ${{ github.workspace }}/kernel
       run: |
         set -e
@@ -62,11 +67,13 @@ runs:
 
     - name: Debug Show manifest.xml
       shell: bash
+      if: ${{ !inputs.use_repo }}
       working-directory: ${{ github.workspace }}/kernel
       run: cat manifest.xml
 
     - name: Fast Parallel Archive Download
       shell: python
+      if: ${{ !inputs.use_repo }}
       working-directory: ${{ github.workspace }}/kernel
       run: |
         import xml.etree.ElementTree as ET

+ 6 - 2
.github/workflows/build.yml

@@ -27,6 +27,9 @@ on:
       feature_set:
         required: true
         type: string
+      use_repo:
+        required: false
+        type: boolean
 
 jobs:
   build-gki:
@@ -45,7 +48,7 @@ jobs:
         kernel_version: ${{ inputs.kernel_version }}
 
     - name: Free Disk Space
-      if: false
+      if: true
       uses: endersonmenezes/free-disk-space@v3  # Use @main for latest, @v3 for stable
       with:
         remove_android: true
@@ -60,7 +63,7 @@ jobs:
         testing: false
 
     - name: Disk Cleanup by Deleting files
-      if: true
+      if: false
       uses: ./.github/actions/disk-cleanup
 
     - name: Setup more Swap (for LTO)
@@ -83,6 +86,7 @@ jobs:
         android_version: ${{ steps.parse.outputs.android_version }}
         kernel_version: ${{ steps.parse.outputs.kernel_version }}
         os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
+        use_repo: ${{ inputs.use_repo }}
 
     - name: Grep for vm_flags_clear after download
       run: |

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

@@ -58,6 +58,10 @@ on:
           - Bypass
           - Wild
         default: Normal
+      use_repo:
+        description: "Use repo for downloading kernel source"
+        type: boolean
+        default: false
 
 jobs:
   fetch-commits:
@@ -88,6 +92,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   build-a13-5-10:
@@ -102,6 +107,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   build-a13-5-15:
@@ -116,6 +122,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   build-a14-5-15:
@@ -130,6 +137,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   build-a14-6-1:
@@ -144,6 +152,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   build-a15-6-6:
@@ -158,6 +167,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   build-a16-6-12:
@@ -172,6 +182,7 @@ jobs:
       susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set || 'FULL' }}
       variant: ${{ inputs.variant || 'Normal' }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit
 
   rej:

+ 6 - 0
.github/workflows/prepare.yml

@@ -31,6 +31,11 @@ on:
         description: "Build Variant (All, Normal, Bypass, Wild)"
         required: false
         type: string
+      use_repo:
+        description: "Use repo for downloading kernel source"
+        required: false
+        type: boolean
+        default: false
 
 jobs:
   generate-matrix:
@@ -87,4 +92,5 @@ jobs:
       patches_commit: ${{ inputs.patches_commit }}
       susfs_commit: ${{ inputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set }}
+      use_repo: ${{ inputs.use_repo }}
     secrets: inherit

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 OnePlus_KernelSU_SUSFS/
 6.12/
+free-disk-space/
 manifest.yml

+ 52 - 0
clean_space.sh

@@ -0,0 +1,52 @@
+#!/bin/bash
+# clean_space.sh - Aggressive disk cleanup for CI runners or local use
+# Usage: bash clean_space.sh
+
+set -e
+
+# Remove Android SDKs and packages
+echo "Removing Android SDKs and packages..."
+sudo rm -rf /usr/local/lib/android /opt/android /usr/local/android-sdk /home/runner/Android || true
+ANDROID_PKGS=$(dpkg -l | grep -E "^ii.*(android|adb)" | awk '{print $2}' | tr '\n' ' ')
+if [ -n "$ANDROID_PKGS" ]; then
+  sudo apt-get remove -y $ANDROID_PKGS || true
+  sudo apt-get autoremove -y || true
+  sudo apt-get clean || true
+fi
+
+# Remove .NET SDKs and packages
+echo "Removing .NET SDKs and packages..."
+sudo rm -rf /usr/share/dotnet /usr/share/doc/dotnet-* || true
+DOTNET_PKGS=$(dpkg -l | grep -E "^ii.*dotnet" | awk '{print $2}' | tr '\n' ' ')
+if [ -n "$DOTNET_PKGS" ]; then
+  sudo apt-get remove -y $DOTNET_PKGS || true
+  sudo apt-get autoremove -y || true
+  sudo apt-get clean || true
+fi
+
+# Remove Haskell SDKs and packages
+echo "Removing Haskell SDKs and packages..."
+sudo rm -rf /opt/ghc /usr/local/.ghcup /opt/cabal /home/runner/.ghcup /home/runner/.cabal || true
+HASKELL_PKGS=$(dpkg -l | grep -E "^ii.*(ghc|haskell|cabal)" | awk '{print $2}' | tr '\n' ' ')
+if [ -n "$HASKELL_PKGS" ]; then
+  sudo apt-get remove -y $HASKELL_PKGS || true
+  sudo apt-get autoremove -y || true
+  sudo apt-get clean || true
+fi
+
+# Remove tool cache (set AGENT_TOOLSDIRECTORY if needed)
+if [ -n "$AGENT_TOOLSDIRECTORY" ]; then
+  echo "Removing tool cache at $AGENT_TOOLSDIRECTORY..."
+  sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
+fi
+
+# Remove swap storage
+echo "Removing swap storage..."
+sudo swapoff -a || true
+sudo rm -f /mnt/swapfile || true
+
+# Remove extra large folders (add your own as needed)
+# Example: sudo rm -rf /path/to/large/folder
+
+# Done
+echo "Disk cleanup complete."