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

feat(action): add manifest resource summary script and workflow

Co-authored-by: Copilot <copilot@github.com>
TheWildJames 4 месяцев назад
Родитель
Сommit
ae901179a3

+ 12 - 4
.github/actions/download-kernel/action.yml

@@ -46,14 +46,22 @@ runs:
         FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
         FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
         MAIN_MANIFEST_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/common-${FORMATTED_BRANCH}/default.xml?format=TEXT"
         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"
         DEPRECATED_MANIFEST_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/deprecated/common-${FORMATTED_BRANCH}/default.xml?format=TEXT"
-        echo "Checking if branch exists: common-${FORMATTED_BRANCH}"
-        if curl -fsI "https://android.googlesource.com/kernel/manifest/+/refs/heads/common-${FORMATTED_BRANCH}/default.xml" | grep -q '200 OK'; then
+        CHECK_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/common-${FORMATTED_BRANCH}/default.xml"
+        DEPRECATED_CHECK_URL="https://android.googlesource.com/kernel/manifest/+/refs/heads/deprecated/common-${FORMATTED_BRANCH}/default.xml"
+        echo "Checking if branch exists: $CHECK_URL"
+        if curl -fsI "$CHECK_URL" | grep -q '200 OK'; then
           echo "Fetching manifest from $MAIN_MANIFEST_URL"
           echo "Fetching manifest from $MAIN_MANIFEST_URL"
           curl -fsSL "$MAIN_MANIFEST_URL" | base64 -d > manifest.xml
           curl -fsSL "$MAIN_MANIFEST_URL" | base64 -d > manifest.xml
         else
         else
-          echo "Branch not found, trying deprecated/common-${FORMATTED_BRANCH}"
+          echo "Branch not found at $CHECK_URL, trying deprecated: $DEPRECATED_CHECK_URL"
           echo "⚠ Note: Branch common-${FORMATTED_BRANCH} is considered deprecated."
           echo "⚠ Note: Branch common-${FORMATTED_BRANCH} is considered deprecated."
-          curl -fsSL "$DEPRECATED_MANIFEST_URL" | base64 -d > manifest.xml
+          if curl -fsI "$DEPRECATED_CHECK_URL" | grep -q '200 OK'; then
+            echo "Fetching manifest from $DEPRECATED_MANIFEST_URL"
+            curl -fsSL "$DEPRECATED_MANIFEST_URL" | base64 -d > manifest.xml
+          else
+            echo "ERROR: Neither main nor deprecated branch exists for $FORMATTED_BRANCH" >&2
+            exit 22
+          fi
         fi
         fi
 
 
     - name: Debug Show manifest.xml
     - name: Debug Show manifest.xml

+ 43 - 0
.github/scripts/manifest_resource_summary.py

@@ -0,0 +1,43 @@
+import os
+import base64
+import requests
+import xml.etree.ElementTree as ET
+from collections import defaultdict
+
+MANIFEST_URLS = [
+    url.strip()
+    for url in os.environ.get("MANIFEST_URLS", "").splitlines()
+    if url.strip()
+]
+
+manifest_projects = defaultdict(set)  # resource -> set of manifest names
+manifest_names = []
+
+for url in MANIFEST_URLS:
+    # Extract manifest name from URL (branch or last path segment)
+    if "/+/refs/heads/" in url:
+        manifest_name = url.split("/+/refs/heads/")[-1].split("/")[0]
+    else:
+        manifest_name = url.split("/")[-2]
+    manifest_names.append(manifest_name)
+    print(f"Fetching manifest: {manifest_name}")
+    resp = requests.get(url)
+    if resp.status_code != 200:
+        print(f"Failed to fetch {url}")
+        continue
+    # Googlesource returns base64-encoded XML
+    xml_content = base64.b64decode(resp.content).decode("utf-8")
+    root = ET.fromstring(xml_content)
+    for project in root.findall("project"):
+        name = project.get("name")
+        path = project.get("path", name)
+        manifest_projects[(name, path)].add(manifest_name)
+
+# Write summary as markdown
+with open("manifest_resource_summary.md", "w") as f:
+    f.write("| Resource Name | Path | Appears In Manifests |\n")
+    f.write("|--------------|------|----------------------|\n")
+    for (name, path), manifests in sorted(manifest_projects.items()):
+        f.write(f"| `{name}` | `{path}` | {', '.join(sorted(manifests))} |\n")
+
+print("Summary written to manifest_resource_summary.md")

+ 37 - 0
.github/workflows/manifest-resource-summary.yml

@@ -0,0 +1,37 @@
+name: Manifest Resource Summary
+
+on:
+  workflow_dispatch:
+
+jobs:
+  manifest-summary:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout (for summary upload)
+        uses: actions/checkout@v4
+
+      - name: Install requirements
+        run: sudo apt-get update && sudo apt-get install -y python3 python3-pip
+
+      - name: Download and summarize manifests
+        run: |
+          python3 .github/scripts/manifest_resource_summary.py
+        env:
+          MANIFEST_URLS: |
+            https://android.googlesource.com/kernel/manifest/+/refs/heads/common-android14-6.1-2023-06/default.xml?format=TEXT
+            https://android.googlesource.com/kernel/manifest/+/refs/heads/common-android14-6.1-2023-07/default.xml?format=TEXT
+            https://android.googlesource.com/kernel/manifest/+/refs/heads/common-android14-6.1-2025-09/default.xml?format=TEXT
+
+      - name: Upload summary
+        if: always()
+        run: |
+          cat manifest_resource_summary.md
+        shell: bash
+        continue-on-error: true
+        id: summary
+
+      - name: Add summary to GitHub Actions
+        if: always()
+        run: |
+          echo "## Manifest Resource Summary" >> $GITHUB_STEP_SUMMARY
+          cat manifest_resource_summary.md >> $GITHUB_STEP_SUMMARY