appveyor-woa.yml 17 KB

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