action.yml 5.7 KB

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