pipeline-segment-electron-build.yml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. name: Pipeline Segment - Electron Build
  2. on:
  3. workflow_call:
  4. inputs:
  5. environment:
  6. description: using the production or testing environment
  7. required: false
  8. type: string
  9. target-platform:
  10. type: string
  11. description: 'Platform to run on, can be macos, win or linux'
  12. required: true
  13. target-arch:
  14. type: string
  15. description: 'Arch to build for, can be x64, arm64, ia32 or arm'
  16. required: true
  17. target-variant:
  18. type: string
  19. description: 'Variant to build for, no effect on non-macOS target platforms. Can be darwin, mas or all.'
  20. default: all
  21. build-runs-on:
  22. type: string
  23. description: 'What host to run the build'
  24. required: true
  25. build-container:
  26. type: string
  27. description: 'JSON container information for aks runs-on'
  28. required: false
  29. default: '{"image":null}'
  30. is-release:
  31. description: 'Whether this build job is a release job'
  32. required: true
  33. type: boolean
  34. default: false
  35. gn-build-type:
  36. description: 'The gn build type - testing or release'
  37. required: true
  38. type: string
  39. default: testing
  40. generate-symbols:
  41. description: 'Whether or not to generate symbols'
  42. required: true
  43. type: boolean
  44. default: false
  45. upload-to-storage:
  46. description: 'Whether or not to upload build artifacts to external storage'
  47. required: true
  48. type: string
  49. default: '0'
  50. strip-binaries:
  51. description: 'Strip the binaries before release (Linux only)'
  52. required: false
  53. type: boolean
  54. default: false
  55. is-asan:
  56. description: 'Building the Address Sanitizer (ASan) Linux build'
  57. required: false
  58. type: boolean
  59. default: false
  60. concurrency:
  61. group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.target-variant }}-${{ inputs.is-asan }}-${{ github.ref_protected == true && github.run_id || github.ref }}
  62. cancel-in-progress: ${{ github.ref_protected != true }}
  63. env:
  64. ELECTRON_ARTIFACTS_BLOB_STORAGE: ${{ secrets.ELECTRON_ARTIFACTS_BLOB_STORAGE }}
  65. ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
  66. SUDOWOODO_EXCHANGE_URL: ${{ secrets.SUDOWOODO_EXCHANGE_URL }}
  67. SUDOWOODO_EXCHANGE_TOKEN: ${{ secrets.SUDOWOODO_EXCHANGE_TOKEN }}
  68. GCLIENT_EXTRA_ARGS: ${{ inputs.target-platform == 'macos' && '--custom-var=checkout_mac=True --custom-var=host_os=mac' || inputs.target-platform == 'win' && '--custom-var=checkout_win=True' || '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True' }}
  69. ELECTRON_OUT_DIR: Default
  70. jobs:
  71. build:
  72. defaults:
  73. run:
  74. shell: bash
  75. runs-on: ${{ inputs.build-runs-on }}
  76. container: ${{ fromJSON(inputs.build-container) }}
  77. environment: ${{ inputs.environment }}
  78. env:
  79. TARGET_ARCH: ${{ inputs.target-arch }}
  80. steps:
  81. - name: Create src dir
  82. run: |
  83. mkdir src
  84. - name: Checkout Electron
  85. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
  86. with:
  87. path: src/electron
  88. fetch-depth: 0
  89. ref: ${{ github.event.pull_request.head.sha }}
  90. - name: Free up space (macOS)
  91. if: ${{ inputs.target-platform == 'macos' }}
  92. uses: ./src/electron/.github/actions/free-space-macos
  93. - name: Check disk space after freeing up space
  94. if: ${{ inputs.target-platform == 'macos' }}
  95. run: df -h
  96. - name: Setup Node.js/npm
  97. if: ${{ inputs.target-platform == 'macos' }}
  98. uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
  99. with:
  100. node-version: 20.11.x
  101. cache: yarn
  102. cache-dependency-path: src/electron/yarn.lock
  103. - name: Install Dependencies
  104. uses: ./src/electron/.github/actions/install-dependencies
  105. - name: Install AZCopy
  106. if: ${{ inputs.target-platform == 'macos' }}
  107. run: brew install azcopy
  108. - name: Set GN_EXTRA_ARGS for Linux
  109. if: ${{ inputs.target-platform == 'linux' }}
  110. run: |
  111. if [ "${{ inputs.target-arch }}" = "arm" ]; then
  112. if [ "${{ inputs.is-release }}" = true ]; then
  113. GN_EXTRA_ARGS='target_cpu="arm" build_tflite_with_xnnpack=false symbol_level=1'
  114. else
  115. GN_EXTRA_ARGS='target_cpu="arm" build_tflite_with_xnnpack=false'
  116. fi
  117. elif [ "${{ inputs.target-arch }}" = "arm64" ]; then
  118. GN_EXTRA_ARGS='target_cpu="arm64" fatal_linker_warnings=false enable_linux_installer=false'
  119. elif [ "${{ inputs.is-asan }}" = true ]; then
  120. GN_EXTRA_ARGS='is_asan=true'
  121. fi
  122. echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
  123. - name: Get Depot Tools
  124. timeout-minutes: 5
  125. run: |
  126. git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  127. SEDOPTION="-i"
  128. if [ "`uname`" = "Darwin" ]; then
  129. SEDOPTION="-i ''"
  130. fi
  131. # remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems
  132. sed $SEDOPTION '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
  133. # Ensure depot_tools does not update.
  134. test -d depot_tools && cd depot_tools
  135. touch .disable_auto_update
  136. - name: Add Depot Tools to PATH
  137. run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
  138. - name: Generate DEPS Hash
  139. run: |
  140. node src/electron/script/generate-deps-hash.js
  141. DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)
  142. echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
  143. echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
  144. - name: Restore src cache via AZCopy
  145. if: ${{ inputs.target-platform == 'macos' }}
  146. uses: ./src/electron/.github/actions/restore-cache-azcopy
  147. - name: Restore src cache via AKS
  148. if: ${{ inputs.target-platform == 'linux' }}
  149. uses: ./src/electron/.github/actions/restore-cache-aks
  150. - name: Checkout src via gclient sync
  151. if: ${{ inputs.target-platform == 'win' }}
  152. uses: ./src/electron/.github/actions/checkout
  153. with:
  154. use-cache: 'false'
  155. - name: Checkout Electron
  156. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
  157. with:
  158. path: src/electron
  159. fetch-depth: 0
  160. ref: ${{ github.event.pull_request.head.sha }}
  161. - name: Install Build Tools
  162. uses: ./src/electron/.github/actions/install-build-tools
  163. - name: Init Build Tools
  164. run: |
  165. e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
  166. - name: Run Electron Only Hooks
  167. run: |
  168. e d gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
  169. - name: Regenerate DEPS Hash
  170. run: |
  171. (cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js
  172. echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
  173. - name: Add CHROMIUM_BUILDTOOLS_PATH to env
  174. run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
  175. - name: Fix Sync (macOS)
  176. if: ${{ inputs.target-platform == 'macos' }}
  177. uses: ./src/electron/.github/actions/fix-sync-macos
  178. - name: Setup Number of Ninja Processes
  179. run: |
  180. echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV
  181. - name: Free up space (macOS)
  182. if: ${{ inputs.target-platform == 'macos' }}
  183. uses: ./src/electron/.github/actions/free-space-macos
  184. - name: Build Electron
  185. if: ${{ inputs.target-platform != 'macos' || (inputs.target-variant == 'all' || inputs.target-variant == 'darwin') }}
  186. uses: ./src/electron/.github/actions/build-electron
  187. with:
  188. target-arch: ${{ inputs.target-arch }}
  189. target-platform: ${{ inputs.target-platform }}
  190. artifact-platform: ${{ inputs.target-platform == 'macos' && 'darwin' || inputs.target-platform }}
  191. is-release: '${{ inputs.is-release }}'
  192. generate-symbols: '${{ inputs.generate-symbols }}'
  193. strip-binaries: '${{ inputs.strip-binaries }}'
  194. upload-to-storage: '${{ inputs.upload-to-storage }}'
  195. is-asan: '${{ inputs.is-asan }}'
  196. - name: Set GN_EXTRA_ARGS for MAS Build
  197. if: ${{ inputs.target-platform == 'macos' && (inputs.target-variant == 'all' || inputs.target-variant == 'mas') }}
  198. run: |
  199. echo "MAS_BUILD=true" >> $GITHUB_ENV
  200. GN_EXTRA_ARGS='is_mas_build=true'
  201. echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
  202. - name: Build Electron (MAS)
  203. if: ${{ inputs.target-platform == 'macos' && (inputs.target-variant == 'all' || inputs.target-variant == 'mas') }}
  204. uses: ./src/electron/.github/actions/build-electron
  205. with:
  206. target-arch: ${{ inputs.target-arch }}
  207. target-platform: ${{ inputs.target-platform }}
  208. artifact-platform: 'mas'
  209. is-release: '${{ inputs.is-release }}'
  210. generate-symbols: '${{ inputs.generate-symbols }}'
  211. upload-to-storage: '${{ inputs.upload-to-storage }}'
  212. step-suffix: '(mas)'