| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- name: 'Download Kernel Repository'
- description: 'Initialize and sync Android kernel source repository'
- inputs:
- android_version:
- description: 'Android version (e.g., android14)'
- required: true
- kernel_version:
- description: 'Kernel version (e.g., 5.15, 6.1)'
- required: true
- version:
- description: 'Combined version (e.g., android14-6.1)'
- required: true
- os_patch_level:
- description: 'OS patch level (e.g., 2024-01)'
- required: true
- outputs:
- deprecated_branch:
- description: 'Whether the branch is deprecated'
- value: ${{ steps.sync.outputs.deprecated }}
- runs:
- using: composite
- steps:
- - name: Initialize and Sync Kernel Repository
- id: sync
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -euo pipefail
- # Derive android and kernel from combined version when available
- VERSION="${{ inputs.version }}"
- ANDROID_PART=$(echo "$VERSION" | cut -d- -f1)
- KERNEL_PART=$(echo "$VERSION" | cut -d- -f2)
- FORMATTED_BRANCH="${ANDROID_PART}-${KERNEL_PART}-${{ inputs.os_patch_level }}"
- init_repo() {
- repo init -u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --depth=1 || { echo "ERROR: repo init failed" >&2; return 1; }
- REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH}) || { echo "ERROR: git ls-remote failed" >&2; return 1; }
- 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
- }
- init_repo || { echo "ERROR: init_repo failed" >&2; exit 1; }
- MAX_RETRIES=3
- RETRY_DELAY_SHORT=15
- SYNC_TIMEOUT="15m"
- attempt=1
- while [ $attempt -le $MAX_RETRIES ]; do
- echo "Attempt $attempt/$MAX_RETRIES: repo sync (timeout $SYNC_TIMEOUT)..."
- # Use minimal-shallow variant: current-branch, shallow init done above, reduce files downloaded
- if timeout $SYNC_TIMEOUT repo sync -c --current-branch --no-clone-bundle --no-tags --jobs-checkout=4 -j4; then
- echo "repo sync succeeded on attempt $attempt."
- break
- fi
- rc=$?
- if [ $rc -eq 124 ]; then
- echo "repo sync timed out after $SYNC_TIMEOUT."
- else
- echo "repo sync failed with exit code $rc."
- fi
- if [ $attempt -lt $MAX_RETRIES ]; then
- echo "Cleaning workspace and retrying after ${RETRY_DELAY_SHORT}s..."
- rm -rf .repo || true
- sleep $RETRY_DELAY_SHORT
- init_repo
- else
- echo "All $MAX_RETRIES attempts failed." >&2
- exit $rc
- fi
- attempt=$((attempt+1))
- done
- # --- Non-repo steps (commented out; we only use repo now) ---
- # - name: Download manifest.xml for branch (with deprecated fallback)
- # shell: bash
- # working-directory: ${{ github.workspace }}/kernel
- # run: |
- # set -euo pipefail
- # VERSION="${{ inputs.version }}"
- # ANDROID_PART=$(echo "$VERSION" | cut -d- -f1)
- # KERNEL_PART=$(echo "$VERSION" | cut -d- -f2)
- # FORMATTED_BRANCH="${ANDROID_PART}-${KERNEL_PART}-${{ inputs.os_patch_level }}"
- # MAIN_MANIFEST_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/common-${FORMATTED_BRANCH}/default.xml?format=TEXT"
- # DEPRECATED_MANIFEST_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/deprecated/common-${FORMATTED_BRANCH}/default.xml?format=TEXT"
- # echo "Trying to fetch manifest from $MAIN_MANIFEST_URL"
- # if curl -fsSL "$MAIN_MANIFEST_URL" | base64 -d > manifest.xml; then
- # echo "Fetched manifest from $MAIN_MANIFEST_URL"
- # else
- # echo "Main manifest fetch failed, trying deprecated branch."
- # echo "⚠ Note: Branch common-${FORMATTED_BRANCH} is considered deprecated."
- # if curl -fsSL "$DEPRECATED_MANIFEST_URL" | base64 -d > manifest.xml; then
- # echo "Fetched manifest from $DEPRECATED_MANIFEST_URL"
- # else
- # echo "ERROR: Neither main nor deprecated branch exists for $FORMATTED_BRANCH" >&2
- # exit 22
- # fi
- # fi
- #
- # - name: Debug Show manifest.xml
- # shell: bash
- # working-directory: ${{ github.workspace }}/kernel
- # run: cat manifest.xml
- #
- # - name: Fast Parallel Archive Download
- # shell: bash
- # working-directory: ${{ github.workspace }}/kernel
- # run: |
- # python "${{ github.workspace }}/.github/actions/download-kernel/fast_parallel_download.py"
- - name: Capture Kernel Common Commit Metadata
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- set -euo pipefail
- if [[ ! -d common ]]; then
- echo "WARNING: common folder not found; skipping commit metadata capture."
- exit 0
- fi
- cd common
- if [[ ! -d .git ]]; then
- echo "WARNING: common is not a git checkout; skipping commit metadata capture."
- exit 0
- fi
- COMMIT_DATE=$(git log -1 --format=%cI)
- COMMIT_MSG=$(git log -1 --format=%s)
- echo "Kernel common commit date: $COMMIT_DATE"
- echo "Kernel common commit msg: $COMMIT_MSG"
|