appveyor.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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-132.0.6834.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, mocha-junit-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 1
  46. job_depends_on: Build
  47. shard: 1
  48. - job_name: Test 2
  49. job_depends_on: Build
  50. shard: 2
  51. clone_script:
  52. - ps: git clone -q $("--branch=" + $Env:APPVEYOR_REPO_BRANCH) $("https://github.com/" + $Env:APPVEYOR_REPO_NAME + ".git") $Env:APPVEYOR_BUILD_FOLDER
  53. - ps: if (!$Env:APPVEYOR_PULL_REQUEST_NUMBER) {$("git checkout -qf " + $Env:APPVEYOR_REPO_COMMIT)}
  54. - ps: if ($Env:APPVEYOR_PULL_REQUEST_NUMBER) {git fetch -q origin +refs/pull/$($Env:APPVEYOR_PULL_REQUEST_NUMBER)/head; git checkout -qf FETCH_HEAD}
  55. clone_folder: C:\projects\src\electron
  56. skip_branch_with_pr: true
  57. # the first failed job cancels other jobs and fails entire build
  58. matrix:
  59. fast_finish: true
  60. for:
  61. - matrix:
  62. only:
  63. - job_name: Build
  64. build_script:
  65. - ps: |
  66. node script/yarn.js install --frozen-lockfile
  67. node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
  68. $env:SHOULD_SKIP_ARTIFACT_VALIDATION = "false"
  69. if ($LASTEXITCODE -eq 0) {
  70. Write-warning "Skipping build for doc-only change"
  71. $env:SHOULD_SKIP_ARTIFACT_VALIDATION = "true"
  72. Exit-AppveyorBuild
  73. } else {
  74. $global:LASTEXITCODE = 0
  75. }
  76. - cd ..
  77. - ps: Write-Host "Building $env:GN_CONFIG build"
  78. - git config --global core.longpaths true
  79. - ps: >-
  80. if (Test-Path -Path "$pwd\depot_tools") {
  81. Remove-Item -Recurse -Force $pwd\depot_tools
  82. }
  83. - ps: >-
  84. if (Test-Path -Path "$pwd\build-tools") {
  85. Remove-Item -Recurse -Force $pwd\build-tools
  86. }
  87. - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  88. - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File
  89. - depot_tools\bootstrap\win_tools.bat
  90. - ps: |
  91. Set-Content -Path $pwd\depot_tools\build_telemetry.cfg -Value '{"user": "[email protected]", "status": "opt-out", "countdown": 10, "version": 1}'
  92. - ps: $env:PATH="$pwd\depot_tools;$env:PATH"
  93. - ps: >-
  94. if (Test-Path -Path "$pwd\src\electron") {
  95. Remove-Item -Recurse -Force $pwd\src\electron
  96. }
  97. - git clone https://github.com/electron/build-tools.git
  98. - cd build-tools
  99. - npx yarn --ignore-engines
  100. - mkdir third_party
  101. - ps: >-
  102. node -e "require('./src/utils/reclient.js').downloadAndPrepare({})"
  103. - ps: $env:RECLIENT_HELPER = node -p "require('./src/utils/reclient.js').helperPath({})"
  104. - ps: >-
  105. & $env:RECLIENT_HELPER login
  106. - ps: >-
  107. $env:RBE_service = node -e "console.log(require('./src/utils/reclient.js').serviceAddress)"
  108. - ps: >-
  109. $env:RBE_credentials_helper = $env:RECLIENT_HELPER
  110. - ps: >-
  111. $env:RBE_credentials_helper_args = "print"
  112. - ps: >-
  113. if ($env:ELECTRON_RBE_JWT -eq '') {
  114. $env:RBE_fail_early_min_action_count = "0"
  115. $env:RBE_fail_early_min_fallback_ratio = "0"
  116. }
  117. - cd ..\..
  118. - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
  119. - ps: >-
  120. if ($env:GN_CONFIG -ne 'release') {
  121. $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
  122. }
  123. - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron"
  124. # Patches are applied in the image bake. Check depshash to see if patches have changed.
  125. - ps: $env:RUN_GCLIENT_SYNC="false"
  126. - ps: $depshash_baked = Get-Content .\src\.depshash -Raw
  127. - ps: cd src\electron
  128. - ps: node script\generate-deps-hash.js
  129. - ps: $depshash = Get-Content .\.depshash -Raw
  130. - ps: cd ..\..
  131. - ps: >-
  132. if ($depshash_baked -ne $depshash) {
  133. $env:RUN_GCLIENT_SYNC="true"
  134. }
  135. - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks )
  136. - cd src
  137. - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH"
  138. - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
  139. - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") use_remoteexec=true %GN_EXTRA_ARGS% "
  140. - gn check out/Default //electron:electron_lib
  141. - gn check out/Default //electron:electron_app
  142. - gn check out/Default //electron/shell/common:mojo
  143. - gn check out/Default //electron/shell/common:plugin
  144. - autoninja -j 300 -C out/Default electron:electron_app
  145. - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
  146. - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true %GN_EXTRA_ARGS%"
  147. - autoninja -C out/ffmpeg electron:electron_ffmpeg_zip
  148. - autoninja -C out/Default electron:electron_dist_zip
  149. - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
  150. # Remove unused args from mksnapshot_args
  151. - ps: >-
  152. 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
  153. - autoninja -C out/Default electron:electron_mksnapshot_zip
  154. - cd out\Default
  155. - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
  156. - cd ..\..
  157. - autoninja -C out/Default electron:hunspell_dictionaries_zip
  158. - autoninja -C out/Default electron:electron_chromedriver_zip
  159. - autoninja -C out/Default electron:node_headers
  160. - ps: >-
  161. 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
  162. - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
  163. - 7z a node_headers.zip out\Default\gen\node_headers
  164. - ps: >-
  165. if ($env:GN_CONFIG -eq 'release') {
  166. # Needed for msdia140.dll on 64-bit windows
  167. $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
  168. }
  169. - if "%GN_CONFIG%"=="release" ( autoninja -C out/Default electron:electron_symbols )
  170. - ps: >-
  171. if ($env:GN_CONFIG -eq 'release') {
  172. python3 electron\script\zip-symbols.py
  173. appveyor-retry appveyor PushArtifact out/Default/symbols.zip
  174. } else {
  175. # It's useful to have pdb files when debugging testing builds that are
  176. # built on CI.
  177. 7z a pdb.zip out\Default\*.pdb
  178. }
  179. - ps: |
  180. $manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest"
  181. python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file
  182. if ($LASTEXITCODE -ne 0) {
  183. throw "Zip contains files not listed in the manifest $manifest_file"
  184. }
  185. - ps: |
  186. cd C:\projects\src
  187. $missing_artifacts = $false
  188. if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {
  189. Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME"
  190. } else {
  191. $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip'
  192. foreach($artifact_name in $artifacts_to_validate) {
  193. if ($artifact_name -eq 'ffmpeg.zip') {
  194. $artifact_file = "out\ffmpeg\ffmpeg.zip"
  195. } elseif (
  196. $artifact_name -eq 'node_headers.zip') {
  197. $artifact_file = $artifact_name
  198. } else {
  199. $artifact_file = "out\Default\$artifact_name"
  200. }
  201. if (-not(Test-Path $artifact_file)) {
  202. Write-warning "$artifact_name is missing and cannot be added to artifacts"
  203. $missing_artifacts = $true
  204. }
  205. }
  206. }
  207. if ($missing_artifacts) {
  208. throw "Build failed due to missing artifacts"
  209. }
  210. deploy_script:
  211. - cd electron
  212. - ps: >-
  213. if (Test-Path Env:\ELECTRON_RELEASE) {
  214. if (Test-Path Env:\UPLOAD_TO_STORAGE) {
  215. Write-Output "Uploading Electron release distribution to azure"
  216. & python3 script\release\uploaders\upload.py --verbose --upload_to_storage
  217. } else {
  218. Write-Output "Uploading Electron release distribution to github releases"
  219. & python3 script\release\uploaders\upload.py --verbose
  220. }
  221. }
  222. on_finish:
  223. # Uncomment this lines to enable RDP
  224. # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  225. - cd C:\projects\src
  226. - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
  227. - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
  228. - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
  229. - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
  230. - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
  231. - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
  232. - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
  233. - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
  234. - ps: >-
  235. if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
  236. appveyor-retry appveyor PushArtifact pdb.zip
  237. }
  238. - matrix:
  239. only:
  240. - job_name: Test 1
  241. - job_name: Test 2
  242. environment:
  243. DD_ENV: ci
  244. DD_SERVICE: electron
  245. DD_CIVISIBILITY_LOGS_ENABLED: true
  246. DD_GIT_REPOSITORY_URL: "https://github.com/electron/electron.git"
  247. ELECTRON_TEST_RESULTS_DIR: C:\projects\src\electron\junit
  248. init:
  249. - ps: |
  250. if ($env:RUN_TESTS -ne 'true') {
  251. Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild
  252. }
  253. build_script:
  254. - ps: |
  255. node script/yarn.js install --frozen-lockfile
  256. node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER
  257. if ($LASTEXITCODE -eq 0) {
  258. Write-warning "Skipping build for doc only change"
  259. Exit-AppveyorBuild
  260. } else {
  261. $global:LASTEXITCODE = 0
  262. }
  263. - npm install -g @datadog/datadog-ci
  264. - cd ..
  265. - mkdir out\Default
  266. - cd ..
  267. - ps: |
  268. # Download build artifacts
  269. $apiUrl = 'https://ci.appveyor.com/api'
  270. $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
  271. $artifacts_to_download = @('dist.zip','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
  272. foreach ($job in $build_info.build.jobs) {
  273. if ($job.name -eq "Build") {
  274. $jobId = $job.jobId
  275. foreach($artifact_name in $artifacts_to_download) {
  276. if ($artifact_name -eq 'electron.lib') {
  277. $outfile = "src\out\Default\$artifact_name"
  278. } else {
  279. $outfile = $artifact_name
  280. }
  281. Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
  282. }
  283. # Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing
  284. Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip
  285. 7z x -y -osrc pdb.zip
  286. }
  287. }
  288. - ps: |
  289. $out_default_zips = @('dist.zip','chromedriver.zip','mksnapshot.zip')
  290. foreach($zip_name in $out_default_zips) {
  291. 7z x -y -osrc\out\Default $zip_name
  292. }
  293. - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
  294. - ps: 7z x -y -osrc node_headers.zip
  295. test_script:
  296. # Workaround for https://github.com/appveyor/ci/issues/2420
  297. - set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
  298. - ps: |
  299. cd src
  300. New-Item .\out\Default\gen\node_headers\Release -Type directory
  301. Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
  302. - cd electron
  303. # Explicitly set npm_config_arch because the .env doesn't persist
  304. - ps: >-
  305. if ($env:TARGET_ARCH -eq 'ia32') {
  306. $env:npm_config_arch = "ia32"
  307. }
  308. - ps: $env:tests_files=node script\split-tests $env:shard 2
  309. - echo "Running shard %shard% specs %tests_files%"
  310. - echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging --files %tests_files%
  311. - cd ..
  312. - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
  313. - echo "About to verify mksnapshot"
  314. - echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
  315. - echo "Done verifying mksnapshot"
  316. - echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
  317. - echo "Done verifying chromedriver"
  318. on_finish:
  319. # Uncomment these lines to enable RDP
  320. # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  321. - if exist electron\junit\test-results-main.xml ( appveyor-retry appveyor PushArtifact electron\junit\test-results-main.xml )
  322. - ps: |
  323. if ($env:RUN_TESTS -eq 'true' -And $env:DD_API_KEY) {
  324. $env:DD_GIT_COMMIT_SHA = $env:APPVEYOR_REPO_COMMIT
  325. $env:DD_GIT_BRANCH = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
  326. $env:DD_TAGS = "os.architecture:$env:TARGET_ARCH,os.family:windows,os.platform:win32"
  327. if (Test-Path -Path "C:\projects\src\electron\junit\test-results-main.xml") {
  328. C:\Users\appveyor\AppData\Roaming\npm\datadog-ci.ps1 junit upload --verbose C:\projects\src\electron\junit\test-results-main.xml
  329. }
  330. }