Просмотр исходного кода

Split cache-setup into cache-ccache-setup and cache-bazel-setup sub-actions

TheWildJames 1 месяц назад
Родитель
Сommit
369f8e417c

+ 23 - 0
.github/actions/cache-bazel-setup/action.yml

@@ -0,0 +1,23 @@
+name: 'Setup Bazel Cache'
+description: 'Create Bazel cache directory for newer kernels'
+inputs:
+  version:
+    description: 'Kernel config version (e.g., android14-6.1)'
+    required: true
+
+runs:
+  using: 'composite'
+  steps:
+    - name: Setup Bazel Cache
+      shell: bash
+      if: |
+        inputs.version == 'android14-5.15' ||
+        inputs.version == 'android14-6.1' ||
+        inputs.version == 'android15-6.6' ||
+        inputs.version == 'android16-6.12'
+      working-directory: ${{ github.workspace }}
+      run: |
+        set -euo pipefail
+        export BAZEL_CACHE_DIR="/home/runner/.cache/bazel"
+        mkdir -p "$BAZEL_CACHE_DIR"
+        echo "BAZEL_CACHE_DIR: $BAZEL_CACHE_DIR"

+ 82 - 0
.github/actions/cache-ccache-setup/action.yml

@@ -0,0 +1,82 @@
+name: 'Setup ccache'
+description: 'Install and configure ccache for older kernels (android12/13)'
+inputs:
+  version:
+    description: 'Kernel config version (e.g., android14-6.1)'
+    required: true
+
+runs:
+  using: 'composite'
+  steps:
+    - name: Setup ccache
+      shell: bash
+      if: |
+        inputs.version == 'android12-5.10' ||
+        inputs.version == 'android13-5.10' ||
+        inputs.version == 'android13-5.15'
+      working-directory: ${{ github.workspace }}
+      run: |
+        set -euo pipefail
+        echo "Installing ccache..."
+
+        if [ -s "${{ github.workspace }}/ccache-dl/ccache" ]; then
+          sudo cp -f "${{ github.workspace }}/ccache-dl/ccache" /usr/bin/ccache
+          sudo chmod +x /usr/bin/ccache
+          rm -rf "${{ github.workspace }}/ccache-dl"
+          echo "✅ installed from shared artifact"
+        else
+          curl -LfsS --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 30 \
+            -H "User-Agent: Mozilla/5.0" \
+            "https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64" -o ccache
+          sudo cp -f ./ccache /usr/bin/ccache
+          sudo chmod +x /usr/bin/ccache
+          rm -f ./ccache
+          echo "✅ installed from download"
+        fi
+
+        if ! /usr/bin/ccache --version > /dev/null 2>&1; then
+          echo "❌ ccache installation failed"
+          exit 1
+        fi
+        echo "✅ ccache verified: $(/usr/bin/ccache --version | head -1)"
+
+        export CCACHE_DIR="/home/runner/.ccache"
+        echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
+        mkdir -p "$CCACHE_DIR"
+
+        export CCACHE_MAXSIZE="12G"
+        echo CCACHE_MAXSIZE="$CCACHE_MAXSIZE" >> $GITHUB_ENV
+        export CCACHE_COMPILERCHECK="content"
+        echo CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" >> $GITHUB_ENV
+        export CCACHE_BASEDIR="${{ github.workspace }}"
+        echo CCACHE_BASEDIR="${{ github.workspace }}" >> $GITHUB_ENV
+        export CCACHE_NOHASHDIR="true"
+        echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
+        export CCACHE_IGNOREOPTIONS="--sysroot*"
+        echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
+        export CCACHE_COMPRESSION="true"
+        echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
+        export CCACHE_COMPRESSLEVEL="3"
+        echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
+        export CCACHE_DIRECT="true"
+        echo CCACHE_DIRECT="true" >> "$GITHUB_ENV"
+        export CCACHE_FILE_CLONE="true"
+        echo CCACHE_FILE_CLONE="true" >> "$GITHUB_ENV"
+        export CCACHE_INODE_CACHE="true"
+        echo CCACHE_INODE_CACHE="true" >> "$GITHUB_ENV"
+        export CCACHE_IS_KERNEL_COMPILING="true"
+        echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
+        export CCACHE_UMASK="002"
+        echo CCACHE_UMASK="002" >> $GITHUB_ENV
+        export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
+        echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
+
+        if ccache --help 2>&1 | grep -q 'depend_mode'; then
+          export CCACHE_DEPEND=true
+          echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
+        fi
+
+        echo "=== ccache config ==="
+        ccache -p
+        echo "====================="
+        echo "✅ ccache ready"

+ 6 - 144
.github/actions/cache-setup/action.yml

@@ -18,149 +18,11 @@ runs:
   using: 'composite'
   steps:
     - name: Setup ccache
-      shell: bash
-      if: |
-        inputs.version == 'android12-5.10' ||
-        inputs.version == 'android13-5.10' ||
-        inputs.version == 'android13-5.15'
-      working-directory: ${{ github.workspace }}
-      run: |
-        set -euo pipefail
-        echo "🔍 DEBUG: cache-setup action started"
-        echo "🔍 DEBUG: inputs.version=${{ inputs.version }}"
-        echo "🔍 DEBUG: inputs.kernel_version=${{ inputs.kernel_version }}"
-        echo "🔍 DEBUG: inputs.android_version=${{ inputs.android_version }}"
-        echo "🔍 DEBUG: inputs.sublevel=${{ inputs.sublevel }}"
-        echo "🔍 DEBUG: github.workspace=${{ github.workspace }}"
-
-        # Install ccache from shared artifact (downloaded once by prepare-ccache job)
-        echo "🔍 DEBUG: Starting ccache installation"
-        echo "Installing ccache..."
-        echo "🔍 DEBUG: Checking for shared ccache artifact at ${{ github.workspace }}/ccache-dl/ccache"
-        if [ -s "${{ github.workspace }}/ccache-dl/ccache" ]; then
-          echo "🔍 DEBUG: Shared ccache artifact found, installing from artifact"
-          sudo cp -f "${{ github.workspace }}/ccache-dl/ccache" /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
-          sudo chmod +x /usr/bin/ccache
-          rm -rf "${{ github.workspace }}/ccache-dl"
-          echo "✅ installed custom ccache from shared artifact"
-          echo "🔍 DEBUG: Installed ccache from shared artifact"
-        else
-          # Fallback: download directly (prepare-ccache may have failed)
-          echo "🔍 DEBUG: Shared ccache artifact NOT found, downloading directly"
-          echo "⚠️ shared ccache artifact unavailable; downloading directly..."
-          echo "🔍 DEBUG: Downloading ccache from https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64"
-          curl -LfsS --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 30 --tcp-fastopen -H "User-Agent: Mozilla/5.0" "https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64" -o ccache || { echo "❌ Failed to download ccache"; exit 1; }
-          echo "🔍 DEBUG: ccache downloaded successfully"
-          sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
-          sudo chmod +x /usr/bin/ccache
-          rm -f ./ccache
-          echo "🔍 DEBUG: Installed ccache from download"
-        fi
-
-        # Verify ccache
-        echo "🔍 DEBUG: Verifying ccache installation"
-        if ! /usr/bin/ccache --version > /dev/null 2>&1; then
-          echo "🔍 DEBUG: ccache version check FAILED"
-          echo "❌ ccache installation failed or binary is corrupted"
-          exit 1
-        fi
-        echo "🔍 DEBUG: ccache binary verified successfully"
-        echo "✅ ccache binary verified: $(/usr/bin/ccache --version | head -1)"
-
-        # Setup cache directories
-        echo "🔍 DEBUG: Setting up ccache directories and environment"
-        export CCACHE_DIR="/home/runner/.ccache"
-        echo "🔍 DEBUG: CCACHE_DIR=$CCACHE_DIR"
-        echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
-        mkdir -p "$CCACHE_DIR"
-        echo "🔍 DEBUG: Created CCACHE_DIR directory"
-        echo "🔍 DEBUG: CCACHE_DIR contents: $(ls -la $CCACHE_DIR 2>/dev/null | head -5 || echo 'empty')"
-
-        export CCACHE_MAXSIZE="12G"
-        echo "🔍 DEBUG: CCACHE_MAXSIZE=$CCACHE_MAXSIZE"
-        echo CCACHE_MAXSIZE="$CCACHE_MAXSIZE" >> $GITHUB_ENV
-        export CCACHE_COMPILERCHECK="content"
-        echo "🔍 DEBUG: CCACHE_COMPILERCHECK=$CCACHE_COMPILERCHECK"
-        echo CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" >> $GITHUB_ENV
-        export CCACHE_BASEDIR="${{ github.workspace }}"
-        echo "🔍 DEBUG: CCACHE_BASEDIR=$CCACHE_BASEDIR"
-        echo CCACHE_BASEDIR="${{ github.workspace }}" >> $GITHUB_ENV
-        export CCACHE_NOHASHDIR="true"
-        echo "🔍 DEBUG: CCACHE_NOHASHDIR=$CCACHE_NOHASHDIR"
-        echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
-        export CCACHE_IGNOREOPTIONS="--sysroot*"
-        echo "🔍 DEBUG: CCACHE_IGNOREOPTIONS=$CCACHE_IGNOREOPTIONS"
-        echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
-        export CCACHE_COMPRESSION="true"
-        echo "🔍 DEBUG: CCACHE_COMPRESSION=$CCACHE_COMPRESSION"
-        echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
-        export CCACHE_COMPRESSLEVEL="3"
-        echo "🔍 DEBUG: CCACHE_COMPRESSLEVEL=$CCACHE_COMPRESSLEVEL"
-        echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
-        export CCACHE_DIRECT="true"
-        echo "🔍 DEBUG: CCACHE_DIRECT=$CCACHE_DIRECT"
-        echo CCACHE_DIRECT="true" >> "$GITHUB_ENV"
-        export CCACHE_FILE_CLONE="true"
-        echo "🔍 DEBUG: CCACHE_FILE_CLONE=$CCACHE_FILE_CLONE"
-        echo CCACHE_FILE_CLONE="true" >> "$GITHUB_ENV"
-        export CCACHE_INODE_CACHE="true"
-        echo "🔍 DEBUG: CCACHE_INODE_CACHE=$CCACHE_INODE_CACHE"
-        echo CCACHE_INODE_CACHE="true" >> "$GITHUB_ENV"
-        export CCACHE_IS_KERNEL_COMPILING="true"
-        echo "🔍 DEBUG: CCACHE_IS_KERNEL_COMPILING=$CCACHE_IS_KERNEL_COMPILING"
-        echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
-        export CCACHE_UMASK="002"
-        echo "🔍 DEBUG: CCACHE_UMASK=$CCACHE_UMASK"
-        echo CCACHE_UMASK="002" >> $GITHUB_ENV
-        export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
-        echo "🔍 DEBUG: CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS"
-        echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
-        #export CCACHE_HARDLINK="true"
-        #echo CCACHE_HARDLINK="$CCACHE_HARDLINK" >> $GITHUB_ENV
-
-        echo "🔍 DEBUG: Checking if depend_mode is available"
-        if ccache --help 2>&1 | grep -q 'depend_mode'; then
-          export CCACHE_DEPEND=true
-          echo "🔍 DEBUG: depend_mode available, setting CCACHE_DEPEND=true"
-          echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
-        else
-          echo "🔍 DEBUG: depend_mode NOT available"
-        fi
-        
-        echo "🔍 DEBUG: Displaying ccache configuration"
-        echo "=== ccache config ==="
-        echo "====================="
-        ccache -p
-        echo "====================="
-        echo "🔍 DEBUG: ccache config displayed successfully"
-
-        echo "✅ ccache ready"
-        echo "🔍 DEBUG: CCACHE_DIR=$CCACHE_DIR"
-        echo "CCACHE_DIR: $CCACHE_DIR"
-        echo "🔍 DEBUG: cache-setup ccache step complete"
+      uses: ./.github/actions/cache-ccache-setup
+      with:
+        version: ${{ inputs.version }}
 
     - name: Setup Bazel Cache
-      shell: bash
-      if: |
-        inputs.version == 'android14-5.15' ||
-        inputs.version == 'android14-6.1' ||
-        inputs.version == 'android15-6.6' ||
-        inputs.version == 'android16-6.12'
-      working-directory: ${{ github.workspace }}
-      run: |
-        set -euo pipefail
-        echo "🔍 DEBUG: Setup Bazel Cache started"
-        export BAZEL_CACHE_DIR="/home/runner/.cache/bazel"
-        echo "🔍 DEBUG: BAZEL_CACHE_DIR=$BAZEL_CACHE_DIR"
-        mkdir -p "$BAZEL_CACHE_DIR"
-        echo "🔍 DEBUG: Created Bazel cache directory"
-        echo "🔍 DEBUG: Bazel cache directory contents: $(ls -la $BAZEL_CACHE_DIR 2>/dev/null | head -5 || echo 'empty')"
-
-        # Set bazel disk cache size limit to 8GB
-        #export BAZEL_DISK_CACHE_SIZE="8589934592"
-        #echo "BAZEL_DISK_CACHE_SIZE=$BAZEL_DISK_CACHE_SIZE" >> $GITHUB_ENV
-
-        #echo "✅ Bazel Cache ready (max 8GB)"
-        echo "BAZEL_CACHE_DIR: $BAZEL_CACHE_DIR"
-        echo "🔍 DEBUG: Setup Bazel Cache complete"
-
+      uses: ./.github/actions/cache-bazel-setup
+      with:
+        version: ${{ inputs.version }}