appveyor.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. # NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor-woa.yml
  2. # IF APPLICABLE!!!!
  3. #
  4. #
  5. # The config expects the following environment variables to be set:
  6. # - "GN_CONFIG" Build type. One of {'testing', 'release'}.
  7. # - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
  8. # e.g. 'target_cpu="x86"' to build for a 32bit platform.
  9. # https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu
  10. # Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
  11. # if you pass a custom value for 'target_cpu'.
  12. # - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
  13. # - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
  14. # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
  15. # - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64'}.
  16. # Is used in some publishing scripts, but does NOT affect the Electron binary.
  17. # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
  18. # - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
  19. # Otherwise the release will be uploaded to the GitHub Releases.
  20. # (The value is only checked if "ELECTRON_RELEASE" is defined.)
  21. #
  22. # The publishing scripts expect access tokens to be defined as env vars,
  23. # but those are not covered here.
  24. #
  25. # AppVeyor docs on variables:
  26. # https://www.appveyor.com/docs/environment-variables/
  27. # https://www.appveyor.com/docs/build-configuration/#secure-variables
  28. # https://www.appveyor.com/docs/build-configuration/#custom-environment-variables
  29. version: 1.0.{build}
  30. build_cloud: electronhq-16-core
  31. image: e-131.0.6734.0-node-20.17-0
  32. environment:
  33. GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
  34. ELECTRON_OUT_DIR: Default
  35. ELECTRON_ENABLE_STACK_DUMPING: 1
  36. ELECTRON_ALSO_LOG_TO_STDERR: 1
  37. MOCHA_REPORTER: mocha-multi-reporters
  38. MOCHA_MULTI_REPORTERS: "@marshallofsound/mocha-appveyor-reporter, tap"
  39. DEPOT_TOOLS_WIN_TOOLCHAIN: 1
  40. DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL: "https://dev-cdn.electronjs.org/windows-toolchains/_"
  41. GYP_MSVS_HASH_7393122652: 3ba76c5c20
  42. PYTHONIOENCODING: UTF-8
  43. matrix:
  44. - job_name: Build
  45. - job_name: Test
  46. job_depends_on: Build
  47. clone_script:
  48. - ps: git clone -q $("--branch=" + $Env:APPVEYOR_REPO_BRANCH) $("https://github.com/" + $Env:APPVEYOR_REPO_NAME + ".git") $Env:APPVEYOR_BUILD_FOLDER
  49. - ps: if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER) {$("git checkout -qf " + $Env:APPVEYOR_REPO_COMMIT)}
  50. - ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER) {git fetch -q origin +refs/pull/$($Env:APPVEYOR_PULL_REQUEST_NUMBER)/head; git checkout -qf FETCH_HEAD}
  51. clone_folder: C:\projects\src\electron
  52. skip_branch_with_pr: true
  53. # the first failed job cancels other jobs and fails entire build
  54. matrix:
  55. fast_finish: true
  56. for:
  57. - matrix:
  58. only:
  59. - job_name: Build
  60. build_script:
  61. - ps: |
  62. node script/yarn.js install --frozen-lockfile
  63. node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
  64. $env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
  65. if ($LASTEXITCODE -eq 0) {
  66. Write-warning "Skipping build for doc-only change"
  67. $env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
  68. Exit-AppveyorBuild
  69. } else {
  70. $global:LASTEXITCODE = 0
  71. }
  72. - cd ..
  73. - ps: Write-Host "Building $env:GN_CONFIG build"
  74. - git config --global core.longpaths true
  75. - ps: >-
  76. if (Test-Path -Path "$pwd\depot_tools") {
  77. Remove-Item -Recurse -Force $pwd\depot_tools
  78. }
  79. - ps: >-
  80. if (Test-Path -Path "$pwd\build-tools") {
  81. Remove-Item -Recurse -Force $pwd\build-tools
  82. }
  83. - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  84. - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
  85. - depot_tools\bootstrap\win_tools.bat
  86. - ps: |
  87. Set-Content -Path $pwd\depot_tools\build_telemetry.cfg -Value '{"user": "[email protected]", "status": "opt-out", "countdown": 10, "version": 1}'
  88. - ps: $env:PATH="$pwd\depot_tools;$env:PATH"
  89. - ps: >-
  90. if (Test-Path -Path "$pwd\src\electron") {
  91. Remove-Item -Recurse -Force $pwd\src\electron
  92. }
  93. - git clone https://github.com/electron/build-tools.git
  94. - cd build-tools
  95. - npx yarn --ignore-engines
  96. - mkdir third_party
  97. - ps: >-
  98. node -e "require('./src/utils/reclient.js').downloadAndPrepare({})"
  99. - ps: $env:RECLIENT_HELPER = node -p "require('./src/utils/reclient.js').helperPath({})"
  100. - ps: >-
  101. & $env:RECLIENT_HELPER login
  102. - ps: >-
  103. $env:RBE_service = node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"
  104. - ps: >-
  105. $env:RBE_experimental_credentials_helper = $env:RECLIENT_HELPER
  106. - ps: >-
  107. $env:RBE_experimental_credentials_helper_args = "print"
  108. - ps: >-
  109. if ($env:ELECTRON_RBE_JWT -eq '') {
  110. $env:RBE_fail_early_min_action_count = "0"
  111. $env:RBE_fail_early_min_fallback_ratio = "0"
  112. $env:RBE_exec_strategy = "local"
  113. $env:RBE_remote_update_cache= "false"
  114. }
  115. - cd ..\..
  116. - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
  117. - ps: >-
  118. if ($env:GN_CONFIG -ne 'release') {
  119. $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
  120. }
  121. - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
  122. # Patches are applied in the image bake. Check depshash to see if patches have changed.
  123. - ps: $env:RUN_GCLIENT_SYNC="false"
  124. - ps: $depshash_baked = Get-Content .\src\.depshash -Raw
  125. - ps: cd src\electron
  126. - ps: node script\generate-deps-hash.js
  127. - ps: $depshash = Get-Content .\.depshash -Raw
  128. - ps: cd ..\..
  129. - ps: >-
  130. if ($depshash_baked -ne $depshash) {
  131. $env:RUN_GCLIENT_SYNC="true"
  132. }
  133. - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks )
  134. - cd src
  135. - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
  136. - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
  137. - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") use_remoteexec=true %GN_EXTRA_ARGS% "
  138. - gn check out/Default //electron:electron_lib
  139. - gn check out/Default //electron:electron_app
  140. - gn check out/Default //electron/shell/common:mojo
  141. - gn check out/Default //electron/shell/common:plugin
  142. - if DEFINED ELECTRON_RBE_JWT (autoninja -j 300 -C out/Default electron:electron_app) else (autoninja -C out/Default electron:electron_app)
  143. - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
  144. - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true %GN_EXTRA_ARGS%"
  145. - autoninja -C out/ffmpeg electron:electron_ffmpeg_zip
  146. - autoninja -C out/Default electron:electron_dist_zip
  147. - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
  148. # Remove unused args from mksnapshot_args
  149. - ps: >-
  150. Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args
  151. - autoninja -C out/Default electron:electron_mksnapshot_zip
  152. - cd out\Default
  153. - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
  154. - cd ..\..
  155. - autoninja -C out/Default electron:hunspell_dictionaries_zip
  156. - autoninja -C out/Default electron:electron_chromedriver_zip
  157. - autoninja -C out/Default electron:node_headers
  158. - ps: >-
  159. Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json
  160. - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
  161. - 7z a node_headers.zip out\Default\gen\node_headers
  162. - ps: >-
  163. if ($env:GN_CONFIG -eq 'release') {
  164. # Needed for msdia140.dll on 64-bit windows
  165. $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
  166. }
  167. - if "%GN_CONFIG%"=="release" ( autoninja -C out/Default electron:electron_symbols )
  168. - ps: >-
  169. if ($env:GN_CONFIG -eq 'release') {
  170. python3 electron\script\zip-symbols.py
  171. appveyor-retry appveyor PushArtifact out/Default/symbols.zip
  172. } else {
  173. # It's useful to have pdb files when debugging testing builds that are
  174. # built on CI.
  175. 7z a pdb.zip out\Default\*.pdb
  176. }
  177. - ps: |
  178. $manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest"
  179. python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file
  180. if ($LASTEXITCODE -ne 0) {
  181. throw "Zip contains files not listed in the manifest $manifest_file"
  182. }
  183. - ps: |
  184. cd C:\projects\src
  185. $missing_artifacts = $false
  186. if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
  187. Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME"
  188. } else {
  189. $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip'
  190. foreach($artifact_name in $artifacts_to_validate) {
  191. if ($artifact_name -eq 'ffmpeg.zip') {
  192. $artifact_file = "out\ffmpeg\ffmpeg.zip"
  193. } elseif (
  194. $artifact_name -eq 'node_headers.zip') {
  195. $artifact_file = $artifact_name
  196. } else {
  197. $artifact_file = "out\Default\$artifact_name"
  198. }
  199. if (-not(Test-Path $artifact_file)) {
  200. Write-warning "$artifact_name is missing and cannot be added to artifacts"
  201. $missing_artifacts = $true
  202. }
  203. }
  204. }
  205. if ($missing_artifacts) {
  206. throw "Build failed due to missing artifacts"
  207. }
  208. deploy_script:
  209. - cd electron
  210. - ps: >-
  211. if (Test-Path Env:\ELECTRON_RELEASE) {
  212. if (Test-Path Env:\UPLOAD_TO_STORAGE) {
  213. Write-Output "Uploading Electron release distribution to azure"
  214. & python3 script\release\uploaders\upload.py --verbose --upload_to_storage
  215. } else {
  216. Write-Output "Uploading Electron release distribution to github releases"
  217. & python3 script\release\uploaders\upload.py --verbose
  218. }
  219. }
  220. on_finish:
  221. # Uncomment this lines to enable RDP
  222. # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  223. - cd C:\projects\src
  224. - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
  225. - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
  226. - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
  227. - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
  228. - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
  229. - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
  230. - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
  231. - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
  232. - ps: >-
  233. if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
  234. appveyor-retry appveyor PushArtifact pdb.zip
  235. }
  236. - matrix:
  237. only:
  238. - job_name: Test
  239. init:
  240. - ps: |
  241. if ($env:RUN_TESTS -ne 'true') {
  242. Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild
  243. }
  244. build_script:
  245. - ps: |
  246. node script/yarn.js install --frozen-lockfile
  247. node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
  248. if ($LASTEXITCODE -eq 0) {
  249. Write-warning "Skipping build for doc only change"
  250. Exit-AppveyorBuild
  251. } else {
  252. $global:LASTEXITCODE = 0
  253. }
  254. - cd ..
  255. - mkdir out\Default
  256. - cd ..
  257. - ps: |
  258. # Download build artifacts
  259. $apiUrl = 'https://ci.appveyor.com/api'
  260. $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
  261. $artifacts_to_download = @('dist.zip','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
  262. foreach ($job in $build_info.build.jobs) {
  263. if ($job.name -eq "Build") {
  264. $jobId = $job.jobId
  265. foreach($artifact_name in $artifacts_to_download) {
  266. if ($artifact_name -eq 'electron.lib') {
  267. $outfile = "src\out\Default\$artifact_name"
  268. } else {
  269. $outfile = $artifact_name
  270. }
  271. Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
  272. }
  273. # Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
  274. Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
  275. 7z x -y -osrc pdb.zip
  276. }
  277. }
  278. - ps: |
  279. $out_default_zips = @('dist.zip','chromedriver.zip','mksnapshot.zip')
  280. foreach($zip_name in $out_default_zips) {
  281. 7z x -y -osrc\out\Default $zip_name
  282. }
  283. - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
  284. - ps: 7z x -y -osrc node_headers.zip
  285. test_script:
  286. # Workaround for https://github.com/appveyor/ci/issues/2420
  287. - set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
  288. - ps: |
  289. cd src
  290. New-Item .\out\Default\gen\node_headers\Release -Type directory
  291. Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
  292. - cd electron
  293. # Explicitly set npm_config_arch because the .env doesn't persist
  294. - ps: >-
  295. if ($env:TARGET_ARCH -eq 'ia32') {
  296. $env:npm_config_arch = "ia32"
  297. }
  298. - echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging
  299. - cd ..
  300. - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
  301. - echo "About to verify mksnapshot"
  302. - echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
  303. - echo "Done verifying mksnapshot"
  304. - echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
  305. - echo "Done verifying chromedriver"
  306. on_finish:
  307. # Uncomment these lines to enable RDP
  308. # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))