action.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. name: 'Setup Cache'
  2. description: 'Sets up ccache and Bazel remote cache configuration for the build environment'
  3. inputs:
  4. version:
  5. description: 'Kernel config version (e.g., android14-6.1)'
  6. required: true
  7. kernel_version:
  8. description: 'Kernel version (e.g., 6.1)'
  9. required: true
  10. android_version:
  11. description: 'Android version (e.g., android14)'
  12. required: true
  13. sublevel:
  14. description: 'Sublevel of kernel version (e.g., 1)'
  15. required: true
  16. runs:
  17. using: 'composite'
  18. steps:
  19. - name: Setup ccache
  20. shell: bash
  21. if: |
  22. inputs.version == 'android12-5.10' ||
  23. inputs.version == 'android13-5.10' ||
  24. inputs.version == 'android13-5.15'
  25. working-directory: ${{ github.workspace }}
  26. run: |
  27. set -euo pipefail
  28. # Download and install ccache
  29. echo "Installing ccache..."
  30. 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; }
  31. sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
  32. sudo chmod +x /usr/bin/ccache
  33. rm -f ./ccache
  34. # Verify ccache
  35. if ! /usr/bin/ccache --version > /dev/null 2>&1; then
  36. echo "❌ ccache installation failed or binary is corrupted"
  37. exit 1
  38. fi
  39. echo "✅ ccache binary verified: $(/usr/bin/ccache --version | head -1)"
  40. # Setup cache directories
  41. export CCACHE_DIR="/home/runner/.ccache"
  42. echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
  43. mkdir -p "$CCACHE_DIR"
  44. export CCACHE_MAXSIZE="12G"
  45. echo CCACHE_MAXSIZE="$CCACHE_MAXSIZE" >> $GITHUB_ENV
  46. export CCACHE_COMPILERCHECK="content"
  47. echo CCACHE_COMPILERCHECK="$CCACHE_COMPILERCHECK" >> $GITHUB_ENV
  48. export CCACHE_BASEDIR="${{ github.workspace }}"
  49. echo CCACHE_BASEDIR="${{ github.workspace }}" >> $GITHUB_ENV
  50. export CCACHE_NOHASHDIR="true"
  51. echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
  52. export CCACHE_IGNOREOPTIONS="--sysroot*"
  53. echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
  54. export CCACHE_COMPRESSION="true"
  55. echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
  56. export CCACHE_COMPRESSLEVEL="3"
  57. echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
  58. export CCACHE_DIRECT="true"
  59. echo CCACHE_DIRECT="true" >> "$GITHUB_ENV"
  60. export CCACHE_FILE_CLONE="true"
  61. echo CCACHE_FILE_CLONE="true" >> "$GITHUB_ENV"
  62. export CCACHE_INODE_CACHE="true"
  63. echo CCACHE_INODE_CACHE="true" >> "$GITHUB_ENV"
  64. export CCACHE_IS_KERNEL_COMPILING="true"
  65. echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
  66. export CCACHE_UMASK="002"
  67. echo CCACHE_UMASK="002" >> $GITHUB_ENV
  68. export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
  69. echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
  70. #export CCACHE_HARDLINK="true"
  71. #echo CCACHE_HARDLINK="$CCACHE_HARDLINK" >> $GITHUB_ENV
  72. if ccache --help 2>&1 | grep -q 'depend_mode'; then
  73. export CCACHE_DEPEND=true
  74. echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
  75. fi
  76. echo "=== ccache config ==="
  77. echo "====================="
  78. ccache -p
  79. echo "====================="
  80. echo "✅ ccache ready"
  81. echo "CCACHE_DIR: $CCACHE_DIR"
  82. - name: Setup Bazel Cache
  83. shell: bash
  84. if: |
  85. inputs.version == 'android14-5.15' ||
  86. inputs.version == 'android14-6.1' ||
  87. inputs.version == 'android15-6.6' ||
  88. inputs.version == 'android16-6.12'
  89. working-directory: ${{ github.workspace }}
  90. run: |
  91. set -euo pipefail
  92. export BAZEL_CACHE_DIR="/home/runner/.cache/bazel"
  93. echo "BAZEL_CACHE_DIR=$BAZEL_CACHE_DIR" >> $GITHUB_ENV
  94. mkdir -p "$BAZEL_CACHE_DIR"
  95. # Set bazel disk cache size limit to 8GB
  96. export BAZEL_DISK_CACHE_SIZE="8589934592"
  97. echo "BAZEL_DISK_CACHE_SIZE=$BAZEL_DISK_CACHE_SIZE" >> $GITHUB_ENV
  98. echo "✅ Bazel Cache ready (max 8GB)"
  99. echo "BAZEL_CACHE_DIR: $BAZEL_CACHE_DIR"
  100. - name: Setup ld cache
  101. shell: bash
  102. working-directory: ${{ github.workspace }}
  103. run: |
  104. set -euo pipefail
  105. export LDCACHE_DIR="/home/runner/.ld_cache"
  106. echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
  107. mkdir -p "$LDCACHE_DIR"
  108. # Create LD wrapper for thin-LTO caching
  109. cat > "${{ github.workspace }}/kernel/common/ld-wrapper" << 'EOF'
  110. #!/bin/bash
  111. ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
  112. EOF
  113. chmod +x "${{ github.workspace }}/kernel/common/ld-wrapper"
  114. # Set size limit via environment (4GB)
  115. echo "LDCACHE_MAX_SIZE=4294967296" >> "$GITHUB_ENV"
  116. echo "✅ LD Cache ready (max 4GB)"
  117. echo "LDCACHE_DIR: $LDCACHE_DIR"