action.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. name: 'Checkout'
  2. description: 'Checks out Electron and stores it in the AKS Cache'
  3. inputs:
  4. generate-sas-token:
  5. description: 'Whether to generate and persist a SAS token for the item in the cache'
  6. required: false
  7. default: 'false'
  8. use-cache:
  9. description: 'Whether to persist the cache to the shared drive'
  10. required: false
  11. default: 'true'
  12. runs:
  13. using: "composite"
  14. steps:
  15. - name: Set GIT_CACHE_PATH to make gclient to use the cache
  16. shell: bash
  17. run: |
  18. echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
  19. - name: Install Dependencies
  20. uses: ./src/electron/.github/actions/install-dependencies
  21. - name: Install Build Tools
  22. uses: ./src/electron/.github/actions/install-build-tools
  23. - name: Get Depot Tools
  24. shell: bash
  25. run: |
  26. if [[ ! -d depot_tools ]]; then
  27. git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  28. # Ensure depot_tools does not update.
  29. test -d depot_tools && cd depot_tools
  30. touch .disable_auto_update
  31. fi
  32. - name: Add Depot Tools to PATH
  33. shell: bash
  34. run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
  35. - name: Generate DEPS Hash
  36. shell: bash
  37. run: |
  38. node src/electron/script/generate-deps-hash.js
  39. echo "DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)" >> $GITHUB_ENV
  40. - name: Generate SAS Key
  41. if: ${{ inputs.generate-sas-token == 'true' }}
  42. shell: bash
  43. run: |
  44. curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$DEPSHASH.tar" > sas-token
  45. - name: Save SAS Key
  46. if: ${{ inputs.generate-sas-token == 'true' }}
  47. uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
  48. with:
  49. path: |
  50. sas-token
  51. key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
  52. - name: Check If Cache Exists
  53. id: check-cache
  54. shell: bash
  55. run: |
  56. if [[ "${{ inputs.use-cache }}" == "false" ]]; then
  57. echo "Not using cache this time..."
  58. echo "cache_exists=false" >> $GITHUB_OUTPUT
  59. else
  60. cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
  61. echo "Using cache key: $DEPSHASH"
  62. echo "Checking for cache in: $cache_path"
  63. if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
  64. echo "cache_exists=false" >> $GITHUB_OUTPUT
  65. echo "Cache Does Not Exist for $DEPSHASH"
  66. else
  67. echo "cache_exists=true" >> $GITHUB_OUTPUT
  68. echo "Cache Already Exists for $DEPSHASH, Skipping.."
  69. fi
  70. fi
  71. - name: Check cross instance cache disk space
  72. if: steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true'
  73. shell: bash
  74. run: |
  75. # if there is less than 35 GB free space then creating the cache might fail so exit early
  76. freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
  77. freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
  78. if [ $freespace -le 35000 ]; then
  79. echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
  80. exit 1
  81. else
  82. echo "The cross mount cache has $freespace_human free space - continuing"
  83. fi
  84. - name: Gclient Sync
  85. if: steps.check-cache.outputs.cache_exists == 'false'
  86. shell: bash
  87. run: |
  88. e d gclient config \
  89. --name "src/electron" \
  90. --unmanaged \
  91. ${GCLIENT_EXTRA_ARGS} \
  92. "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
  93. if [ "$TARGET_OS" != "" ]; then
  94. echo "target_os=['$TARGET_OS']" >> ./.gclient
  95. fi
  96. ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 e d gclient sync --with_branch_heads --with_tags -vv
  97. if [ "${{ inputs.is-release }}" != "true" && -n "${{ env.PATCH_UP_APP_CREDS }}" ]; then
  98. # Re-export all the patches to check if there were changes.
  99. python3 src/electron/script/export_all_patches.py src/electron/patches/config.json
  100. cd src/electron
  101. git update-index --refresh || true
  102. if ! git diff-index --quiet HEAD --; then
  103. # There are changes to the patches. Make a git commit with the updated patches
  104. git add patches
  105. GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
  106. # Export it
  107. mkdir -p ../../patches
  108. git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
  109. if node ./script/push-patch.js; then
  110. echo
  111. echo "======================================================================"
  112. echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
  113. echo "A new CI job will kick off shortly"
  114. echo "======================================================================"
  115. exit 1
  116. else
  117. echo
  118. echo "======================================================================"
  119. echo "There were changes to the patches when applying."
  120. echo "Check the CI artifacts for a patch you can apply to fix it."
  121. echo "======================================================================"
  122. echo
  123. cat ../../patches/update-patches.patch
  124. exit 1
  125. fi
  126. fi
  127. fi
  128. # delete all .git directories under src/ except for
  129. # third_party/angle/ and third_party/dawn/ because of build time generation of files
  130. # gen/angle/commit.h depends on third_party/angle/.git/HEAD
  131. # https://chromium-review.googlesource.com/c/angle/angle/+/2074924
  132. # and dawn/common/Version_autogen.h depends on third_party/dawn/.git/HEAD
  133. # https://dawn-review.googlesource.com/c/dawn/+/83901
  134. # TODO: maybe better to always leave out */.git/HEAD file for all targets ?
  135. - name: Delete .git directories under src to free space
  136. if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
  137. shell: bash
  138. run: |
  139. cd src
  140. ( find . -type d -name ".git" -not -path "./third_party/angle/*" -not -path "./third_party/dawn/*" -not -path "./electron/*" ) | xargs rm -rf
  141. - name: Minimize Cache Size for Upload
  142. if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
  143. shell: bash
  144. run: |
  145. rm -rf src/android_webview
  146. rm -rf src/ios/chrome
  147. rm -rf src/third_party/blink/web_tests
  148. rm -rf src/third_party/blink/perf_tests
  149. rm -rf src/chrome/test/data/xr/webvr_info
  150. rm -rf src/third_party/angle/third_party/VK-GL-CTS/src
  151. rm -rf src/third_party/swift-toolchain
  152. rm -rf src/third_party/swiftshader/tests/regres/testlists
  153. cp src/electron/.github/actions/checkout/action.yml ./
  154. rm -rf src/electron
  155. mkdir -p src/electron/.github/actions/checkout
  156. mv action.yml src/electron/.github/actions/checkout
  157. - name: Compress Src Directory
  158. if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
  159. shell: bash
  160. run: |
  161. echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
  162. tar -cf $DEPSHASH.tar src
  163. echo "Compressed src to $(du -sh $DEPSHASH.tar | cut -f1 -d' ')"
  164. cp ./$DEPSHASH.tar /mnt/cross-instance-cache/
  165. - name: Persist Src Cache
  166. if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
  167. shell: bash
  168. run: |
  169. final_cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
  170. echo "Using cache key: $DEPSHASH"
  171. echo "Checking path: $final_cache_path"
  172. if [ ! -f "$final_cache_path" ]; then
  173. echo "Cache key not found"
  174. exit 1
  175. else
  176. echo "Cache key persisted in $final_cache_path"
  177. fi