appveyor.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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/+/master/docs/reference.md#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', 'mips64el'}.
  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-110.0.5481.208
  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: mocha-appveyor-reporter, tap
  39. GOMA_FALLBACK_ON_AUTH_FAILURE: true
  40. DEPOT_TOOLS_WIN_TOOLCHAIN: 0
  41. PYTHONIOENCODING: UTF-8
  42. matrix:
  43. - job_name: Build
  44. - job_name: Test
  45. job_depends_on: Build
  46. clone_folder: C:\projects\src\electron
  47. skip_branch_with_pr: true
  48. # the first failed job cancels other jobs and fails entire build
  49. matrix:
  50. fast_finish: true
  51. for:
  52. - matrix:
  53. only:
  54. - job_name: Build
  55. build_script:
  56. - ps: |
  57. node script/yarn.js install --frozen-lockfile
  58. node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
  59. if ($LASTEXITCODE -eq 0) {
  60. Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
  61. }
  62. $global:LASTEXITCODE = 0
  63. - cd ..
  64. - ps: Write-Host "Building $env:GN_CONFIG build"
  65. - git config --global core.longpaths true
  66. - ps: >-
  67. if (Test-Path -Path "$pwd\depot_tools") {
  68. Remove-Item -Recurse -Force $pwd\depot_tools
  69. }
  70. - ps: >-
  71. if (Test-Path -Path "$pwd\build-tools") {
  72. Remove-Item -Recurse -Force $pwd\build-tools
  73. }
  74. - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  75. - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
  76. - depot_tools\bootstrap\win_tools.bat
  77. - ps: $env:PATH="$pwd\depot_tools;$env:PATH"
  78. - ps: >-
  79. if (Test-Path -Path "$pwd\src\electron") {
  80. Remove-Item -Recurse -Force $pwd\src\electron
  81. }
  82. - ps: >-
  83. if (Test-Path 'env:RAW_GOMA_AUTH') {
  84. $env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config"
  85. $env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE
  86. }
  87. - git clone https://github.com/electron/build-tools.git
  88. - cd build-tools
  89. - npm install
  90. - mkdir third_party
  91. - ps: >-
  92. node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })"
  93. - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)"
  94. - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)"
  95. - cd ..\..
  96. - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR
  97. - ps: >-
  98. if (Test-Path 'env:RAW_GOMA_AUTH') {
  99. $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info
  100. if ($goma_login -eq 'Login as Fermi Planck') {
  101. Write-warning "Goma authentication is correct";
  102. } else {
  103. Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token.";
  104. $host.SetShouldExit(1)
  105. }
  106. }
  107. - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
  108. - ps: >-
  109. if ($env:GN_CONFIG -ne 'release') {
  110. $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
  111. }
  112. - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
  113. # Patches are applied in the image bake. Check depshash to see if patches have changed.
  114. - ps: $env:RUN_GCLIENT_SYNC="false"
  115. - ps: $depshash_baked = Get-Content .\src\.depshash -Raw
  116. - ps: cd src\electron
  117. - ps: node script\generate-deps-hash.js
  118. - ps: $depshash = Get-Content .\.depshash -Raw
  119. - ps: cd ..\..
  120. - ps: >-
  121. if ($depshash_baked -ne $depshash) {
  122. $env:RUN_GCLIENT_SYNC="true"
  123. }
  124. - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks )
  125. - cd src
  126. - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
  127. - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
  128. - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% "
  129. - gn check out/Default //electron:electron_lib
  130. - gn check out/Default //electron:electron_app
  131. - gn check out/Default //electron/shell/common/api:mojo
  132. - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app)
  133. - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
  134. - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
  135. - ninja -C out/ffmpeg electron:electron_ffmpeg_zip
  136. - ninja -C out/Default electron:electron_dist_zip
  137. - ninja -C out/Default shell_browser_ui_unittests
  138. - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
  139. # Remove unused args from mksnapshot_args
  140. - ps: >-
  141. 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
  142. - ninja -C out/Default electron:electron_mksnapshot_zip
  143. - cd out\Default
  144. - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
  145. - cd ..\..
  146. - ninja -C out/Default electron:hunspell_dictionaries_zip
  147. - ninja -C out/Default electron:electron_chromedriver_zip
  148. - ninja -C out/Default third_party/electron_node:headers
  149. - python %LOCAL_GOMA_DIR%\goma_ctl.py stat
  150. - ps: >-
  151. 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
  152. - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
  153. - 7z a node_headers.zip out\Default\gen\node_headers
  154. - ps: >-
  155. if ($env:GN_CONFIG -eq 'release') {
  156. # Needed for msdia140.dll on 64-bit windows
  157. $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
  158. ninja -C out/Default electron:electron_symbols
  159. }
  160. - ps: >-
  161. if ($env:GN_CONFIG -eq 'release') {
  162. python3 electron\script\zip-symbols.py
  163. appveyor-retry appveyor PushArtifact out/Default/symbols.zip
  164. } else {
  165. # It's useful to have pdb files when debugging testing builds that are
  166. # built on CI.
  167. 7z a pdb.zip out\Default\*.pdb
  168. }
  169. - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
  170. - ps: |
  171. cd C:\projects\src
  172. $missing_artifacts = $false
  173. if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
  174. Write-warning "Skipping artifact validation for doc-only PR"
  175. } else {
  176. $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip'
  177. foreach($artifact_name in $artifacts_to_validate) {
  178. if ($artifact_name -eq 'ffmpeg.zip') {
  179. $artifact_file = "out\ffmpeg\ffmpeg.zip"
  180. } elseif ($artifact_name -eq 'node_headers.zip') {
  181. $artifact_file = $artifact_name
  182. } else {
  183. $artifact_file = "out\Default\$artifact_name"
  184. }
  185. if (-not(Test-Path $artifact_file)) {
  186. Write-warning "$artifact_name is missing and cannot be added to artifacts"
  187. $missing_artifacts = $true
  188. }
  189. }
  190. }
  191. if ($missing_artifacts) {
  192. throw "Build failed due to missing artifacts"
  193. }
  194. deploy_script:
  195. - cd electron
  196. - ps: >-
  197. if (Test-Path Env:\ELECTRON_RELEASE) {
  198. if (Test-Path Env:\UPLOAD_TO_STORAGE) {
  199. Write-Output "Uploading Electron release distribution to azure"
  200. & python3 script\release\uploaders\upload.py --verbose --upload_to_storage
  201. } else {
  202. Write-Output "Uploading Electron release distribution to github releases"
  203. & python3 script\release\uploaders\upload.py --verbose
  204. }
  205. }
  206. on_finish:
  207. # Uncomment this lines to enable RDP
  208. # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  209. - cd C:\projects\src
  210. - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
  211. - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
  212. - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe)
  213. - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
  214. - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
  215. - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
  216. - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
  217. - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
  218. - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
  219. - ps: >-
  220. if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
  221. appveyor-retry appveyor PushArtifact pdb.zip
  222. }
  223. - matrix:
  224. only:
  225. - job_name: Test
  226. init:
  227. - ps: |
  228. if ($env:RUN_TESTS -ne 'true') {
  229. Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild
  230. }
  231. build_script:
  232. - ps: |
  233. node script/yarn.js install --frozen-lockfile
  234. node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
  235. if ($LASTEXITCODE -eq 0) {
  236. Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild
  237. }
  238. $global:LASTEXITCODE = 0
  239. - cd ..
  240. - mkdir out\Default
  241. - cd ..
  242. - ps: |
  243. # Download build artifacts
  244. $apiUrl = 'https://ci.appveyor.com/api'
  245. $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
  246. $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
  247. foreach ($job in $build_info.build.jobs) {
  248. if ($job.name -eq "Build") {
  249. $jobId = $job.jobId
  250. foreach($artifact_name in $artifacts_to_download) {
  251. if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') {
  252. $outfile = "src\out\Default\$artifact_name"
  253. } else {
  254. $outfile = $artifact_name
  255. }
  256. Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
  257. }
  258. # Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
  259. # Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
  260. # 7z x -y -osrc pdb.zip
  261. }
  262. }
  263. - ps: |
  264. $out_default_zips = @('dist.zip','chromedriver.zip','mksnapshot.zip')
  265. foreach($zip_name in $out_default_zips) {
  266. 7z x -y -osrc\out\Default $zip_name
  267. }
  268. - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
  269. - ps: 7z x -y -osrc node_headers.zip
  270. test_script:
  271. # Workaround for https://github.com/appveyor/ci/issues/2420
  272. - set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
  273. - ps: |
  274. cd src
  275. New-Item .\out\Default\gen\node_headers\Release -Type directory
  276. Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
  277. - cd electron
  278. # Explicitly set npm_config_arch because the .env doesn't persist
  279. - ps: >-
  280. if ($env:TARGET_ARCH -eq 'ia32') {
  281. $env:npm_config_arch = "ia32"
  282. }
  283. - echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging=file --log-file=%cd%\electron.log
  284. - echo Running native test suite & node script/yarn test -- --trace-uncaught --runners=native --enable-logging=file --log-file=%cd%\electron.log
  285. - cd ..
  286. - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
  287. - echo "About to verify mksnapshot"
  288. - echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
  289. - echo "Done verifying mksnapshot"
  290. - echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
  291. - echo "Done verifying chromedriver"
  292. on_finish:
  293. # Uncomment these lines to enable RDP
  294. # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  295. - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )