build.yml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. kernel_version:
  9. required: true
  10. type: string
  11. variant:
  12. required: false
  13. type: string
  14. feature_set:
  15. required: true
  16. type: string
  17. use_repo:
  18. required: false
  19. type: boolean
  20. jobs:
  21. build-gki:
  22. name: "${{ inputs.kernel_version }} (${{ inputs.variant }})"
  23. runs-on: ubuntu-latest
  24. timeout-minutes: 60
  25. steps:
  26. - name: Checkout Repository
  27. uses: actions/checkout@v5
  28. - name: Parse kernel version
  29. id: parse
  30. uses: ./.github/actions/parse-kernel-version
  31. with:
  32. kernel_version: ${{ inputs.kernel_version }}
  33. - name: Free Disk Space
  34. if: true
  35. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  36. with:
  37. remove_android: true
  38. remove_dotnet: true
  39. remove_haskell: true
  40. remove_tool_cache: true
  41. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  42. remove_packages_one_command: true
  43. 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"
  44. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  45. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  46. testing: false
  47. - name: Setup more Swap (for LTO)
  48. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  49. with:
  50. swap-size-gb: 10 # 10-24 GB is common for heavy LTO
  51. # swap-space-path: /mnt/swapfile # optional
  52. - name: Setup Build Environment
  53. uses: ./.github/actions/setup-build-environment
  54. env:
  55. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  56. - name: Download Kernel Repository
  57. uses: ./.github/actions/download-kernel
  58. with:
  59. android_version: ${{ steps.parse.outputs.android_version }}
  60. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  61. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  62. use_repo: ${{ inputs.use_repo }}
  63. - name: Extract Sublevel and Set File Name
  64. id: extract
  65. uses: ./.github/actions/extract-sublevel-file-name
  66. with:
  67. variant: ${{ inputs.variant }}
  68. - name: Kernel Fixes
  69. uses: ./.github/actions/kernel-fixes
  70. with:
  71. android_version: ${{ steps.parse.outputs.android_version }}
  72. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  73. sublevel: ${{ steps.extract.outputs.sublevel }}
  74. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  75. - name: Setup KernelSU-Next
  76. if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'FULL'
  77. uses: ./.github/actions/kernelsu
  78. - name: SUSFS
  79. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'FULL'
  80. uses: ./.github/actions/susfs
  81. with:
  82. android_version: ${{ steps.parse.outputs.android_version }}
  83. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  84. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  85. sublevel: ${{ steps.extract.outputs.sublevel }}
  86. - name: Baseband Guard
  87. if: contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'FULL'
  88. uses: ./.github/actions/bbg
  89. - name: Setup Networking
  90. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'FULL'
  91. uses: ./.github/actions/networking
  92. with:
  93. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  94. android_version: ${{ steps.parse.outputs.android_version }}
  95. - name: DroidSpaces-OSS Patches
  96. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'FULL'
  97. uses: ./.github/actions/droidspaces
  98. with:
  99. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  100. - name: Setup Misc Configs
  101. uses: ./.github/actions/misc
  102. with:
  103. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  104. android_version: ${{ steps.parse.outputs.android_version }}
  105. - name: Apply Module Check Bypass
  106. if: ${{ inputs.variant == 'Bypass' }}
  107. uses: ./.github/actions/module-check-bypass
  108. with:
  109. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  110. - name: Apply Device-Specific Patches
  111. uses: ./.github/actions/apply-device-patches
  112. with:
  113. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  114. - name: Apply ABI Compare Bypass
  115. if: false
  116. working-directory: ${{ github.workspace }}/kernel
  117. run: |
  118. # ABI compare bypass per kernel/android version
  119. # Edit each block as needed per version
  120. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  121. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  122. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  123. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  124. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  125. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  126. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  127. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  128. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  129. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  130. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  131. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  132. fi
  133. - name: Apply Kernel Branding
  134. uses: ./.github/actions/apply-kernel-branding
  135. with:
  136. variant: ${{ inputs.variant }}
  137. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  138. android_version: ${{ steps.parse.outputs.android_version }}
  139. sublevel: ${{ steps.extract.outputs.sublevel }}
  140. - name: Remove Protected Exports
  141. uses: ./.github/actions/remove-protected-exports
  142. - name: Clean Kernel Flags
  143. uses: ./.github/actions/clean-kernel-flags
  144. - name: Scan and collect patch rejects
  145. id: scan
  146. if: ${{ always() && inputs.variant == 'Normal' }}
  147. uses: ./.github/actions/scan-patch-rejects
  148. - name: Upload Rejects
  149. if: ${{ always() && inputs.variant == 'Normal' }}
  150. uses: actions/upload-artifact@v7
  151. with:
  152. name: ${{ steps.extract.outputs.file_name }}-Rejects
  153. path: patch-rejects/
  154. if-no-files-found: ignore
  155. compression-level: 9
  156. - name: Restore build caches (ccache)
  157. id: restore-ccache
  158. uses: ./.github/actions/restore-cache
  159. with:
  160. cache_path: /home/runner/.ccache
  161. cache_key: buildcache-${{ inputs.kernel_version }}
  162. cache_bucket: "ccache-cache"
  163. compression_level: 9
  164. restore_keys: |
  165. buildcache-
  166. - name: Check ccache hit
  167. run: |
  168. if [ "${{ steps.restore-ccache.outputs.cache-hit }}" = "true" ]; then
  169. echo "✅ ccache HIT - Key: ${{ steps.restore-ccache.outputs.cache-key }} - Size: ${{ steps.restore-ccache.outputs.cache-size }}"
  170. else
  171. echo "❌ ccache MISS - Fresh build"
  172. fi
  173. - name: Restore build caches (bazel)
  174. id: restore-bazel-cache
  175. uses: ./.github/actions/restore-cache
  176. with:
  177. cache_path: /home/runner/.cache/bazel
  178. cache_key: buildcache-${{ inputs.kernel_version }}
  179. cache_bucket: "bazel-cache"
  180. compression_level: 9
  181. restore_keys: |
  182. buildcache-
  183. - name: Check bazel cache hit
  184. run: |
  185. if [ "${{ steps.restore-bazel-cache.outputs.cache-hit }}" = "true" ]; then
  186. echo "✅ bazel cache HIT - Key: ${{ steps.restore-bazel-cache.outputs.cache-key }} - Size: ${{ steps.restore-bazel-cache.outputs.cache-size }}"
  187. else
  188. echo "❌ bazel cache MISS - Fresh build"
  189. fi
  190. - name: Restore build caches (LTO/ld_cache)
  191. id: restore-ldcache
  192. uses: ./.github/actions/restore-cache
  193. with:
  194. cache_path: /home/runner/.ld_cache
  195. cache_key: buildcache-${{ inputs.kernel_version }}
  196. cache_bucket: "lto-cache"
  197. compression_level: 9
  198. restore_keys: |
  199. buildcache-
  200. - name: Check ld_cache hit
  201. run: |
  202. if [ "${{ steps.restore-ldcache.outputs.cache-hit }}" = "true" ]; then
  203. echo "✅ ld_cache HIT - Key: ${{ steps.restore-ldcache.outputs.cache-key }} - Size: ${{ steps.restore-ldcache.outputs.cache-size }}"
  204. else
  205. echo "❌ ld_cache MISS - Fresh build"
  206. fi
  207. - name: Pre-build cache stats
  208. id: pre-cache-stats
  209. run: |
  210. set -euo pipefail
  211. stats=$(ccache -s || true)
  212. pre_hits=$(echo "$stats" | awk '/cache hit/ {h+=$NF} END{print (h+0)}')
  213. pre_misses=$(echo "$stats" | awk '/cache miss/ {m+=$NF} END{print (m+0)}')
  214. echo "pre_hits=$pre_hits" >> $GITHUB_OUTPUT
  215. echo "pre_misses=$pre_misses" >> $GITHUB_OUTPUT
  216. pre_ld_size=$(du -sh "/home/runner/.ld_cache" 2>/dev/null | awk '{print $1}' || echo "0B")
  217. pre_ld_files=$(find "/home/runner/.ld_cache" -type f 2>/dev/null | wc -l || true)
  218. echo "pre_ld_size=$pre_ld_size" >> $GITHUB_OUTPUT
  219. echo "pre_ld_files=$pre_ld_files" >> $GITHUB_OUTPUT
  220. - name: 'Setup ccache and Build Environment'
  221. shell: bash
  222. working-directory: ${{ github.workspace }}
  223. run: |
  224. set -euo pipefail
  225. # Download and install ccache
  226. echo "Installing ccache..."
  227. 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; }
  228. sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
  229. sudo chmod +x /usr/bin/ccache
  230. rm -f ./ccache
  231. # Step 1: Verify ccache is installed
  232. echo "Verifying ccache installation..."
  233. /usr/bin/ccache --version || { echo "❌ ccache not found"; exit 1; }
  234. echo "✅ ccache installed at /usr/bin/ccache"
  235. # Step 2: Create symlinks directory
  236. SYMLINK_DIR="/usr/lib/ccache"
  237. echo "Creating symlinks directory: $SYMLINK_DIR"
  238. sudo mkdir -p "$SYMLINK_DIR"
  239. # Step 3: Create symlinks for compilers (DO USE symlinks, NOT hard links)
  240. echo "Creating compiler symlinks..."
  241. for compiler in gcc g++ cc c++ clang clang++; do
  242. sudo ln -sf /usr/bin/ccache "$SYMLINK_DIR/$compiler" || { echo "❌ Failed to create symlink for $compiler"; exit 1; }
  243. done
  244. echo "✅ Symlinks created in $SYMLINK_DIR"
  245. # Step 4: Prepend symlinks directory to PATH (MUST come before /usr/bin)
  246. echo "Prepending $SYMLINK_DIR to PATH..."
  247. echo "export PATH=\"$SYMLINK_DIR:\$PATH\"" >> "$GITHUB_ENV"
  248. export PATH="$SYMLINK_DIR:$PATH"
  249. # Step 5: Verify the setup
  250. echo "Verifying compiler masquerading..."
  251. which gcc | grep "$SYMLINK_DIR" || { echo "❌ gcc not pointing to ccache symlinks"; exit 1; }
  252. which g++ | grep "$SYMLINK_DIR" || { echo "❌ g++ not pointing to ccache symlinks"; exit 1; }
  253. echo "✅ gcc and g++ now routed through ccache"
  254. # Step 6: Configure ccache (optional - set max size, compression, etc.)
  255. CCACHE_MAX_SIZE="12G"
  256. echo "Setting max cache size to $CCACHE_MAX_SIZE..."
  257. sudo ccache -M "$CCACHE_MAX_SIZE" || ccache -M "$CCACHE_MAX_SIZE"
  258. # Enable compression (faster cache, slightly slower compilation)
  259. ccache --set-config compression=true
  260. # Step 7: Show ccache stats setup
  261. echo "✅ ccache setup complete!"
  262. ccache --show-stats
  263. # Step 8: Print what's done for debugging
  264. echo "--- ccache setup info ---"
  265. echo "ccache binary: $(which ccache)"
  266. echo "gcc via ccache: $(which gcc)"
  267. echo "g++ via ccache: $(which g++)"
  268. echo "symlinks dir: $SYMLINK_DIR"
  269. echo "max size: $(ccache --show-stats | grep 'cache size' | awk '{print $3}')"
  270. - name: 'Setup ccache and Build Environment'
  271. shell: bash
  272. if: false
  273. working-directory: ${{ github.workspace }}
  274. run: |
  275. set -euo pipefail
  276. # Download and install ccache
  277. #echo "Installing ccache..."
  278. #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; }
  279. #sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
  280. #sudo chmod +x /usr/bin/ccache
  281. #rm -f ./ccache
  282. # Verify ccache
  283. if ! /usr/bin/ccache --version > /dev/null 2>&1; then
  284. echo "❌ ccache installation failed or binary is corrupted"
  285. exit 1
  286. fi
  287. echo "✅ ccache binary verified: $(/usr/bin/ccache --version | head -1)"
  288. # Setup cache directories
  289. #export CCACHE_DIR="/home/runner/.ccache"
  290. #echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
  291. #export LDCACHE_DIR="/home/runner/.ld_cache"
  292. #echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
  293. #mkdir -p "$CCACHE_DIR" "$LDCACHE_DIR"
  294. # Create LD wrapper for thin-LTO caching
  295. #cat > "$GITHUB_WORKSPACE/kernel/common/ld-wrapper" << 'EOF'
  296. #!/bin/bash
  297. #ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
  298. #EOF
  299. #chmod +x "$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
  300. # Setup ccache compiler wrappers in PATH (masquerade method)
  301. # This intercepts compiler invocations regardless of how the build system calls them
  302. #mkdir -p "$GITHUB_WORKSPACE/ccache-bin"
  303. #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/clang"
  304. #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/clang++"
  305. #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/gcc"
  306. #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/g++"
  307. #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/ld.lld"
  308. #chmod +x "$GITHUB_WORKSPACE/ccache-bin"/*
  309. # Export environment variables for subsequent steps
  310. #echo "PATH=$GITHUB_WORKSPACE/ccache-bin:$PATH" >> $GITHUB_ENV
  311. #export CC="/usr/bin/ccache clang"
  312. #echo "CC=$CC" >> $GITHUB_ENV
  313. #export CXX="/usr/bin/ccache clang++"
  314. #echo "CXX=$CXX" >> $GITHUB_ENV
  315. #export HOSTCC="/usr/bin/ccache clang"
  316. #echo "HOSTCC=$HOSTCC" >> $GITHUB_ENV
  317. #export HOSTCXX="/usr/bin/ccache clang++"
  318. #echo "HOSTCXX=$HOSTCXX" >> $GITHUB_ENV
  319. #export LD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
  320. #echo "LD=$LD" >> $GITHUB_ENV
  321. #export HOSTLD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
  322. #echo "HOSTLD=$HOSTLD" >> $GITHUB_ENV
  323. #echo "CLANG_PREBUILT_BIN=$GITHUB_WORKSPACE/ccache-bin" >> $GITHUB_ENV
  324. export CCACHE_MAXSIZE="12G"
  325. echo CCACHE_MAXSIZE="$CCACHE_MAXSIZE" >> $GITHUB_ENV
  326. export CCACHE_COMPILERCHECK="%compiler% -dumpmachine; %compiler% -dumpversion"
  327. echo CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" >> $GITHUB_ENV
  328. #export CCACHE_BASEDIR="${GITHUB_WORKSPACE}"
  329. #echo CCACHE_BASEDIR="${GITHUB_WORKSPACE}" >> $GITHUB_ENV
  330. export CCACHE_NOHASHDIR="true"
  331. echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
  332. #export CCACHE_IGNOREOPTIONS="--sysroot*"
  333. #echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
  334. #export CCACHE_COMPRESSION="true"
  335. #echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
  336. #export CCACHE_COMPRESSLEVEL="3"
  337. #echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
  338. #export CCACHE_DIRECT="true"
  339. #echo CCACHE_DIRECT="true" >> $GITHUB_ENV
  340. #export CCACHE_FILE_CLONE="true"
  341. #echo CCACHE_FILE_CLONE="true" >> $GITHUB_ENV
  342. #export CCACHE_INODE_CACHE="true"
  343. #echo CCACHE_INODE_CACHE="true" >> $GITHUB_ENV
  344. #export CCACHE_IS_KERNEL_COMPILING="true"
  345. #echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
  346. #export CCACHE_UMASK="002"
  347. #echo CCACHE_UMASK="002" >> $GITHUB_ENV
  348. #export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
  349. #echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
  350. export CCACHE_HARDLINK="true"
  351. echo CCACHE_HARDLINK="$CCACHE_HARDLINK" >> $GITHUB_ENV
  352. #if ccache --help 2>&1 | grep -q 'depend_mode'; then
  353. # export CCACHE_DEPEND=true
  354. # echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
  355. #fi
  356. # Initialize ccache
  357. #ccache -M 100G
  358. #ccache -p
  359. #ccache -s
  360. #ccache -z
  361. echo "✅ Build environment ready"
  362. echo " CCACHE_DIR: $CCACHE_DIR"
  363. #echo " LDCACHE_DIR: $LDCACHE_DIR"
  364. #echo " Compiler wrappers: $GITHUB_WORKSPACE/ccache-bin"
  365. - name: Build Kernel
  366. env:
  367. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  368. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  369. uses: ./.github/actions/build-kernel
  370. - name: 'Report Cache Sizes'
  371. shell: bash
  372. run: |
  373. set -euo pipefail
  374. echo "📊 Cache sizes after build:"
  375. echo " CCACHE usage:"
  376. du -sh "$CCACHE_DIR" || echo " (no ccache directory)"
  377. #echo " LDCACHE usage:"
  378. #du -sh "$LDCACHE_DIR" || echo " (no ldcache directory)"
  379. echo "Perform cache eviction!"
  380. # 3h = 10800s using seconds to support older ccache
  381. ccache --evict-older-than 10800s
  382. - name: Post-build cache stats
  383. id: post-cache-stats
  384. run: |
  385. set -euo pipefail
  386. stats=$(ccache -s || true)
  387. post_hits=$(echo "$stats" | awk '/cache hit/ {h+=$NF} END{print (h+0)}')
  388. post_misses=$(echo "$stats" | awk '/cache miss/ {m+=$NF} END{print (m+0)}')
  389. pre_hits=${{ steps.pre-cache-stats.outputs.pre_hits }}
  390. pre_misses=${{ steps.pre-cache-stats.outputs.pre_misses }}
  391. delta_hits=$((post_hits - pre_hits)) || true
  392. delta_misses=$((post_misses - pre_misses)) || true
  393. delta_total=$((delta_hits + delta_misses))
  394. if [ "$delta_total" -gt 0 ]; then
  395. percent=$(( delta_hits * 100 / delta_total ))
  396. echo "ccache hit during build: ${percent}% (${delta_hits} hits / ${delta_total} accesses)"
  397. else
  398. echo "No compiler activity detected (no ccache accesses)."
  399. fi
  400. post_ld_size=$(du -sh "/home/runner/.ld_cache" 2>/dev/null | awk '{print $1}' || echo "0B")
  401. post_ld_files=$(find "/home/runner/.ld_cache" -type f 2>/dev/null | wc -l || true)
  402. echo "ld_cache size before: ${{ steps.pre-cache-stats.outputs.pre_ld_size }}, after: $post_ld_size"
  403. echo "ld_cache files before: ${{ steps.pre-cache-stats.outputs.pre_ld_files }}, after: $post_ld_files"
  404. - name: List cache contents
  405. working-directory: ${{ github.workspace }}
  406. run: |
  407. echo "=== .ccache ==="
  408. du -sh /home/runner/.ccache || true
  409. ls -l /home/runner/.ccache || true
  410. echo "=== .cache/bazel ==="
  411. du -sh /home/runner/.cache/bazel || true
  412. ls -l /home/runner/.cache/bazel || true
  413. - name: Save ccache cache
  414. uses: ./.github/actions/save-cache
  415. with:
  416. cache_path: /home/runner/.ccache
  417. cache_key: buildcache-${{ inputs.kernel_version }}
  418. cache_bucket: "ccache-cache"
  419. compression_level: 9
  420. github_token: ${{ secrets.GITHUB_TOKEN }}
  421. - name: Save bazel cache
  422. uses: ./.github/actions/save-cache
  423. with:
  424. cache_path: /home/runner/.cache/bazel
  425. cache_key: buildcache-${{ inputs.kernel_version }}
  426. cache_bucket: "bazel-cache"
  427. compression_level: 9
  428. github_token: ${{ secrets.GITHUB_TOKEN }}
  429. - name: Save LTO LD cache
  430. uses: ./.github/actions/save-cache
  431. with:
  432. cache_path: /home/runner/.ld_cache
  433. cache_key: buildcache-${{ inputs.kernel_version }}
  434. cache_bucket: "lto-cache"
  435. compression_level: 9
  436. github_token: ${{ secrets.GITHUB_TOKEN }}
  437. - name: Create Bootimgs Folder and Build Boot Images
  438. uses: ./.github/actions/build-boot-images
  439. - name: Upload Boot Image (boot.img)
  440. uses: actions/upload-artifact@v7
  441. with:
  442. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  443. if-no-files-found: error
  444. archive: false
  445. - name: Upload Boot Image (boot-gz.img)
  446. uses: actions/upload-artifact@v7
  447. with:
  448. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  449. if-no-files-found: error
  450. archive: false
  451. - name: Upload Boot Image (boot-lz4.img)
  452. uses: actions/upload-artifact@v7
  453. with:
  454. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  455. if-no-files-found: error
  456. archive: false
  457. - name: Prepare AnyKernel3 Zip
  458. uses: ./.github/actions/prepare-anykernel3
  459. - name: Upload Artifacts
  460. uses: actions/upload-artifact@v7
  461. with:
  462. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  463. path: ${{ github.workspace }}/AnyKernel3/**
  464. if-no-files-found: ignore
  465. compression-level: 9