فهرست منبع

refactor: update kernel branding and build actions for improved version handling

TheWildJames 3 ماه پیش
والد
کامیت
c5da8ef5a1

+ 12 - 35
.github/actions/apply-kernel-branding/action.yml

@@ -30,39 +30,16 @@ runs:
 
         DEFCONFIG="${{ github.workspace }}/kernel/common/arch/arm64/configs/gki_defconfig"
 
-        #VERSION="${{ inputs.version }}"
-        #ANDROID_PART=$(echo "$VERSION" | cut -d- -f1)
-        #KERNEL_PART=$(echo "$VERSION" | cut -d- -f2)
+        VERSION="${{ inputs.version }}"
+        ANDROID_PART=$(echo "$VERSION" | cut -d- -f1)
+        KERNEL_PART=$(echo "$VERSION" | cut -d- -f2)
 
-        #if [ "${{ inputs.variant }}" == "Wild" ]; then
-        #  tac scripts/setlocalversion | awk '!seen && /^echo / {seen=1; next} 1' | tac > scripts/setlocalversion.tmp
-        #  mv scripts/setlocalversion.tmp scripts/setlocalversion
-        #  if [[ "$KERNEL_PART" == "6.6" || "$KERNEL_PART" == "6.12" ]]; then
-        #    KERNEL_STRING="$KERNEL_PART.${{ inputs.sublevel }}-$ANDROID_PART"
-        #    echo "echo \"$KERNEL_STRING-Wild\"" >> scripts/setlocalversion
-        #  else
-        #    echo 'echo "-Wild"' >> scripts/setlocalversion
-        #  fi
-        #  chmod +x scripts/setlocalversion
-        #else
-        #  if grep -q '^CONFIG_LOCALVERSION=' "$DEFCONFIG"; then
-        #   LOCALVERSION_VALUE="$(grep -m1 '^CONFIG_LOCALVERSION=' "$DEFCONFIG" | sed -E 's/^CONFIG_LOCALVERSION="?([^"]*)"?$/\1/')"
-        #   echo "CONFIG_LOCALVERSION=\"${LOCALVERSION_VALUE}-Wild\"" >> "$CONFIG_FRAGMENT"
-        #  else
-        #    echo 'CONFIG_LOCALVERSION="-Wild"' >> "$CONFIG_FRAGMENT"
-        #  fi
-        #fi
-
-    - name: Apply Kernel Configuration
-      shell: bash
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        CONFIG_FRAGMENT="${{ github.workspace }}/wild_gki.fragment"
-        touch "$CONFIG_FRAGMENT"
-
-        DEFCONFIG="${{ github.workspace }}/kernel/common/arch/arm64/configs/gki_defconfig"
-        
-        cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
-        CONFIG_LOCALVERSION="-Wild"
-        # CONFIG_LOCALVERSION_AUTO is not set
-        EOF
+        tac scripts/setlocalversion | awk '!seen && /^echo / {seen=1; next} 1' | tac > scripts/setlocalversion.tmp
+        mv scripts/setlocalversion.tmp scripts/setlocalversion
+        if [[ ${{ inputs.version }} == "android15-6.6" || ${{ inputs.version }} == "android16-6.12" ]]; then
+          KERNEL_STRING="$KERNEL_PART.${{ inputs.sublevel }}-$ANDROID_PART"
+          echo "echo \"$KERNEL_STRING-Wild\"" >> scripts/setlocalversion
+        else
+          echo 'echo "-Wild"' >> scripts/setlocalversion
+        fi
+        chmod +x scripts/setlocalversion

+ 9 - 3
.github/actions/build-kernel/action.yml

@@ -77,19 +77,25 @@ runs:
         tools/bazel info output_base
         cp "${{ github.workspace }}/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
         if [[ ${{ inputs.version }} == "android16-6.12" ]]; then
-            tools/bazel run \
+          tools/bazel run \
               --config=fast \
               --lto=default \
               --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
               --disk_cache=/home/runner/.cache/bazel \
+              --experimental_disk_cache_gc_max_size=12G \
+              --experimental_disk_cache_gc_max_age=30d \
+              --experimental_disk_cache_gc_idle_delay=5m \
               //common:kernel_aarch64_dist \
-              -- --distdir=/home/runner/out
+              -- --destdir=/home/runner/out
           else
             tools/bazel run \
               --config=fast \
               --lto=default \
               --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
               --disk_cache=/home/runner/.cache/bazel \
+              --experimental_disk_cache_gc_max_size=12G \
+              --experimental_disk_cache_gc_max_age=30d \
+              --experimental_disk_cache_gc_idle_delay=5m \
               //common:kernel_aarch64_dist \
               -- --dist_dir=/home/runner/out
           fi
@@ -125,7 +131,7 @@ runs:
 
       exit 1
 
-  - name: 'Gather Build Artifacts'
+  - name: 'Patch AnyKernel3 for Bypass Hack'
     shell: bash
     if: ${{ inputs.bypass == 'true' }}
     working-directory: ${{ github.workspace }}/AnyKernel3

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

@@ -41,20 +41,20 @@ jobs:
     - name: Checkout Repository
       uses: actions/checkout@v5
 
-
     - name: 🧹 Emergency Disk Cleanup
+      if: false
       uses: ./.github/actions/disk-cleanup
 
     - 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
         remove_dotnet: true
         remove_haskell: true
         remove_tool_cache: true
-        #remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
-        #remove_packages_one_command: true
+        remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
+        remove_packages_one_command: true
         remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
         rm_cmd: "rmz"  # Use 'rmz' for faster deletion (default: 'rm')
         rmz_version: "3.1.1"  # Required when rm_cmd is 'rmz'
@@ -63,7 +63,7 @@ jobs:
     - name: Setup more Swap (for LTO)
       uses: thejerrybao/setup-swap-space@v1   # or pierotofy/set-swap-space
       with:
-        swap-size-gb: 16          # 10-24 GB is common for heavy LTO
+        swap-size-gb: 10          # 10-24 GB is common for heavy LTO
         # swap-space-path: /mnt/swapfile   # optional
 
     - name: Setup Build Environment
@@ -264,7 +264,6 @@ jobs:
 
     - name: Restore bazel-cache
       id: restore-bazel
-      if: false
       uses: ./.github/actions/cache-restore
       with:
         cache_path: /home/runner/.cache/bazel
@@ -277,7 +276,6 @@ jobs:
 
     - name: Restore lto-cache (bazel versions)
       id: restore-lto-bazel
-      if: false
       uses: ./.github/actions/cache-restore
       with:
         cache_path: /home/runner/.ld_cache
@@ -289,7 +287,6 @@ jobs:
           ${{ inputs.android_version }}-${{ inputs.kernel_version }}-
 
     - name: Check cache hit
-      if: false
       run: |
         echo "Cache restore status:"        CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
         LTO_CCACHE_HIT="${{ steps.restore-lto-ccache.outputs.cache-hit || 'skipped' }}"
@@ -301,7 +298,6 @@ jobs:
         echo "  lto (bazel versions): $LTO_BAZEL_HIT"
 
     - name: Get Cache Stats
-      if: false
       uses: ./.github/actions/cache-stats
       with:
         clear_stats: true
@@ -316,13 +312,11 @@ jobs:
         bypass: false
 
     - name: Get Cache Stats
-      if: false
       uses: ./.github/actions/cache-stats
       with:
         clear_stats: false
 
     - name: Save ccache
-      if: false
       uses: ./.github/actions/cache-save
       with:
         cache_path: /home/runner/.ccache
@@ -331,8 +325,7 @@ jobs:
         compression_level: 9
         github_token: ${{ secrets.GITHUB_TOKEN }}
 
-    - name: Save lto-cache (ccache versions)
-      if: false
+    - name: Save lto-cache
       uses: ./.github/actions/cache-save
       with:
         cache_path: /home/runner/.ld_cache
@@ -342,7 +335,6 @@ jobs:
         github_token: ${{ secrets.GITHUB_TOKEN }}
 
     - name: Save bazel-cache
-      if: false
       uses: ./.github/actions/cache-save
       with:
         cache_path: /home/runner/.cache/bazel
@@ -351,16 +343,6 @@ jobs:
         compression_level: 9
         github_token: ${{ secrets.GITHUB_TOKEN }}
 
-    - name: Save lto-cache (bazel versions)
-      if: false
-      uses: ./.github/actions/cache-save
-      with:
-        cache_path: /home/runner/.ld_cache
-        cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
-        cache_bucket: lto-cache
-        compression_level: 9
-        github_token: ${{ secrets.GITHUB_TOKEN }}
-
     - name: Build Bypass Kernel
       env:
         SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}

+ 0 - 119
.github/workflows/fetch-latest-commits.yml

@@ -1,119 +0,0 @@
-name: fetch-latest-commits
-
-permissions:
-  contents: write
-
-"on":
-  workflow_dispatch:
-    inputs:
-      apply_changes:
-        description: "Write updated commits to .github/config/commits.json and push"
-        type: boolean
-        default: false
-      target_branch:
-        description: "Branch to push changes to (only used when apply_changes=true)"
-        type: string
-        default: "main"
-
-jobs:
-  gather-commits:
-    runs-on: ubuntu-latest
-
-    steps:
-      - name: Checkout repository
-        uses: actions/checkout@v5
-        with:
-          ref: ${{ inputs.target_branch }}
-
-      - name: Gather latest commit pins
-        id: gather
-        shell: bash
-        run: |
-          set -euo pipefail
-
-          COMMITS_FILE=".github/config/commits.json"
-          KSU_REPO="https://github.com/KernelSU-Next/KernelSU-Next.git"
-          SUSFS_REPO="https://gitlab.com/simonpunk/susfs4ksu.git"
-
-          if [[ ! -f "$COMMITS_FILE" ]]; then
-            echo "Missing commits file: $COMMITS_FILE"
-            exit 1
-          fi
-
-          # Validate JSON early so we fail loudly on malformed edits.
-          jq -e . "$COMMITS_FILE" >/dev/null
-
-          KSU_BRANCH="dev"
-          KSU_LATEST=$(git ls-remote "$KSU_REPO" "refs/heads/$KSU_BRANCH" | awk '{print $1}')
-
-          if [[ -z "${KSU_LATEST:-}" ]]; then
-            echo "Failed to resolve KernelSU branch: $KSU_BRANCH"
-            exit 1
-          fi
-
-          TMP_FILE=$(mktemp)
-          jq --arg commit "$KSU_LATEST" '.kernelsu.dev = $commit' "$COMMITS_FILE" > "$TMP_FILE"
-          mv "$TMP_FILE" "$COMMITS_FILE"
-
-          echo "KernelSU dev -> $KSU_LATEST"
-
-          # Iterate current SUSFS keys (e.g. gki-android14-6.1) and fetch latest heads.
-          while IFS= read -r branch; do
-            [[ -n "$branch" ]] || continue
-
-            latest=$(git ls-remote "$SUSFS_REPO" "refs/heads/$branch" | awk '{print $1}')
-            if [[ -z "${latest:-}" ]]; then
-              echo "Warning: could not resolve SUSFS branch: $branch"
-              continue
-            fi
-
-            tmp=$(mktemp)
-            jq --arg branch "$branch" --arg commit "$latest" '.susfs[$branch] = $commit' "$COMMITS_FILE" > "$tmp"
-            mv "$tmp" "$COMMITS_FILE"
-
-            echo "SUSFS $branch -> $latest"
-          done < <(jq -r '.susfs | keys[]' "$COMMITS_FILE")
-
-          echo "diff_present=false" >> "$GITHUB_OUTPUT"
-          if ! git diff --quiet -- "$COMMITS_FILE"; then
-            echo "diff_present=true" >> "$GITHUB_OUTPUT"
-          fi
-
-      - name: Show changes
-        shell: bash
-        run: |
-          set -euo pipefail
-          if git diff --quiet -- .github/config/commits.json; then
-            echo "No updates found."
-          else
-            echo "Updated commit pins:"
-            git --no-pager diff -- .github/config/commits.json
-          fi
-
-      - name: Commit and push changes
-        if: inputs.apply_changes == true && steps.gather.outputs.diff_present == 'true'
-        shell: bash
-        run: |
-          set -euo pipefail
-
-          git config user.name "github-actions[bot]"
-          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
-
-          git add .github/config/commits.json
-          git commit -m "chore(ci): refresh KernelSU and SUSFS commit pins"
-          git push origin "HEAD:${{ inputs.target_branch }}"
-
-      - name: Summary
-        if: always()
-        shell: bash
-        run: |
-          {
-            echo "## Commit Pin Refresh"
-            echo "- apply_changes: ${{ inputs.apply_changes }}"
-            echo "- target_branch: ${{ inputs.target_branch }}"
-            if git diff --quiet -- .github/config/commits.json; then
-              echo "- result: no changes"
-            else
-              echo "- result: commits file updated"
-            fi
-          } >> "$GITHUB_STEP_SUMMARY"

+ 0 - 165
.github/workflows/lts-download-speed-test.yml

@@ -1,165 +0,0 @@
-name: LTS Download Speed Test
-
-on:
-  workflow_dispatch:
-
-permissions:
-  contents: read
-  actions: read
-
-jobs:
-  benchmark-download:
-    runs-on: ubuntu-latest
-    timeout-minutes: 180
-    strategy:
-      fail-fast: false
-      max-parallel: 7
-      matrix:
-        branch:
-          - android12-5.10-lts
-          - android13-5.10-lts
-          - android13-5.15-lts
-          - android14-5.15-lts
-          - android14-6.1-lts
-          - android15-6.6-lts
-          - android16-6.12-lts
-    name: ${{ matrix.branch }} / minimal-shallow
-    steps:
-      - name: Install repo tool
-        shell: bash
-        run: |
-          set -euo pipefail
-          mkdir -p "$HOME/.local/bin"
-          curl -fsSL https://storage.googleapis.com/git-repo-downloads/repo -o "$HOME/.local/bin/repo"
-          chmod +x "$HOME/.local/bin/repo"
-          echo "$HOME/.local/bin" >> "$GITHUB_PATH"
-
-      - name: Benchmark repo sync
-        shell: bash
-        run: |
-          set -euo pipefail
-          workdir="$RUNNER_TEMP/kernel-speed-test/${{ matrix.branch }}/minimal-shallow"
-          mkdir -p "$workdir"
-          cd "$workdir"
-
-          combo_name="minimal-shallow"
-          result_file="$RUNNER_TEMP/kernel-speed-test-result.json"
-
-          branch="common-${{ matrix.branch }}"
-
-          init_start_ns=$(date +%s%N)
-          init_status=0
-          sync_status=0
-          error_message=""
-
-          set +e
-          repo init -u https://android.googlesource.com/kernel/manifest -b "$branch" --depth=1
-          init_status=$?
-          set -e
-          if [ "$init_status" -ne 0 ]; then
-            error_message="repo init failed (exit ${init_status})"
-          fi
-          init_end_ns=$(date +%s%N)
-          init_elapsed_ms=$(( (init_end_ns - init_start_ns) / 1000000 ))
-
-          sync_cmd=(repo sync -c --current-branch --no-clone-bundle --no-tags --jobs-checkout=4 -j4)
-
-          sync_elapsed_ms=""
-          total_elapsed_ms=""
-          if [ "$init_status" -eq 0 ]; then
-            sync_start_ns=$(date +%s%N)
-            set +e
-            timeout 20m "${sync_cmd[@]}"
-            sync_status=$?
-            set -e
-            sync_end_ns=$(date +%s%N)
-            sync_elapsed_ms=$(( (sync_end_ns - sync_start_ns) / 1000000 ))
-            total_elapsed_ms=$(( (sync_end_ns - init_start_ns) / 1000000 ))
-            if [ "$sync_status" -ne 0 ] && [ -z "$error_message" ]; then
-              error_message="repo sync failed (exit ${sync_status})"
-            fi
-          fi
-
-          status_value="ok"
-          if [ -n "$error_message" ]; then
-            status_value="failed"
-          fi
-
-          cat > "$result_file" <<EOF
-          {
-            "branch": "$branch",
-            "profile": "$combo_name",
-            "mode": "unset",
-            "init_ms": ${init_elapsed_ms},
-            "sync_ms": ${sync_elapsed_ms:-null},
-            "total_ms": ${total_elapsed_ms:-null},
-            "init_status": ${init_status},
-            "sync_status": ${sync_status},
-            "status": "${status_value}",
-            "error": "${error_message}"
-          }
-          EOF
-
-      - name: Upload benchmark result
-        if: always()
-        uses: actions/upload-artifact@v4
-        with:
-          name: benchmark-${{ matrix.branch }}-minimal-shallow
-          path: ${{ runner.temp }}/kernel-speed-test-result.json
-          if-no-files-found: error
-
-  summarize-results:
-    runs-on: ubuntu-latest
-    needs: benchmark-download
-    if: always()
-    steps:
-      - name: Download benchmark results
-        uses: actions/download-artifact@v4
-        with:
-          path: benchmark-results
-
-      - name: Build summary table
-        shell: bash
-        run: |
-          set -euo pipefail
-          python3 - <<'PY'
-          import json
-          from pathlib import Path
-
-          root = Path('benchmark-results')
-          rows = []
-          for path in sorted(root.glob('*/kernel-speed-test-result.json')):
-              rows.append(json.loads(path.read_text()))
-
-          rows.sort(key=lambda row: (row.get('total_ms') is None, row.get('total_ms') or 10**18))
-
-          def fmt_ms(value):
-              return f"{value/1000:.2f}s" if value is not None else 'n/a'
-
-          summary = []
-          summary.append('## LTS download benchmark summary')
-          summary.append('')
-          summary.append('| Branch | Profile | Repo init | Repo sync | Total | Status |')
-          summary.append('| --- | --- | ---: | ---: | ---: | --- |')
-          for row in rows:
-              summary.append(
-                  f"| {row['branch']} | {row['profile']} | {fmt_ms(row.get('init_ms'))} | {fmt_ms(row.get('sync_ms'))} | {fmt_ms(row.get('total_ms'))} | {row.get('status', 'unknown')} |"
-              )
-
-          if rows:
-              summary.append('')
-              summary.append('### Best total times')
-              for row in rows[:5]:
-                  summary.append(f"- {fmt_ms(row['total_ms'])} - {row['branch']} / {row['profile']}")
-
-              summary.append('')
-              summary.append('### Worst total times')
-              for row in rows[-5:][::-1]:
-                  summary.append(f"- {fmt_ms(row['total_ms'])} - {row['branch']} / {row['profile']}")
-
-          Path('benchmark-summary.md').write_text('\n'.join(summary) + '\n')
-          PY
-
-      - name: Publish benchmark summary
-        shell: bash
-        run: cat benchmark-summary.md >> "$GITHUB_STEP_SUMMARY"