1 # The config expects the following environment variables to be set:
2 # - "GN_CONFIG" Build type. One of {'testing', 'release'}.
3 # - "GN_EXTRA_ARGS" Additional gn arguments for a build config,
4 # e.g. 'target_cpu="x86"' to build for a 32bit platform.
5 # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu
6 # Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly
7 # if you pass a custom value for 'target_cpu'.
8 # - "ELECTRON_RELEASE" Set it to '1' upload binaries on success.
9 # - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules.
10 # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value.
11 # - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64', 'mips64el'}.
12 # Is used in some publishing scripts, but does NOT affect the Electron binary.
13 # Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
14 # - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
15 # Otherwise the release will be uploaded to the GitHub Releases.
16 # (The value is only checked if "ELECTRON_RELEASE" is defined.)
18 # The publishing scripts expect access tokens to be defined as env vars,
19 # but those are not covered here.
21 # AppVeyor docs on variables:
22 # https://www.appveyor.com/docs/environment-variables/
23 # https://www.appveyor.com/docs/build-configuration/#secure-variables
24 # https://www.appveyor.com/docs/build-configuration/#custom-environment-variables
27 build_cloud: electron-16-core
28 image: vs2019bt-16.16.11
30 GIT_CACHE_PATH: C:\Users\electron\libcc_cache
31 ELECTRON_OUT_DIR: Default
32 ELECTRON_ENABLE_STACK_DUMPING: 1
33 ELECTRON_ALSO_LOG_TO_STDERR: 1
34 MOCHA_REPORTER: mocha-multi-reporters
35 MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap
36 GOMA_FALLBACK_ON_AUTH_FAILURE: true
45 clone_folder: C:\projects\src\electron
47 # the first failed job cancels other jobs and fails entire build
60 if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
61 Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild
66 node script/yarn.js install --frozen-lockfile
67 node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
68 if ($LASTEXITCODE -eq 0) {
69 Write-warning "Skipping tests for doc only change"; Exit-AppveyorBuild
71 $global:LASTEXITCODE = 0
73 - ps: Write-Host "Building $env:GN_CONFIG build"
74 - git config --global core.longpaths true
75 - update_depot_tools.bat
77 if (Test-Path 'env:RAW_GOMA_AUTH') {
78 $env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config"
79 $env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE
81 - git clone https://github.com/electron/build-tools.git
86 node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })"
87 - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)"
88 - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)"
90 - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR
92 if (Test-Path 'env:RAW_GOMA_AUTH') {
93 $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info
94 if ($goma_login -eq 'Login as Fermi Planck') {
95 Write-warning "Goma authentication is correct";
97 Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token.";
98 $host.SetShouldExit(1)
101 - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools"
103 if ($env:GN_CONFIG -ne 'release') {
104 $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] "
108 --name "src\electron"
111 "https://github.com/electron/electron"
113 if ($env:GN_CONFIG -eq 'release') {
114 $env:RUN_GCLIENT_SYNC="true"
117 node script\generate-deps-hash.js
118 $depshash = Get-Content .\.depshash -Raw
119 $zipfile = "Z:\$depshash.7z"
121 if (Test-Path -Path $zipfile) {
122 # file exists, unzip and then gclient sync
123 7z x -y $zipfile -mmt=14 -aoa
124 if (-not (Test-Path -Path "src\buildtools")) {
125 # the zip file must be corrupt - resync
126 $env:RUN_GCLIENT_SYNC="true"
127 if ($env:TARGET_ARCH -ne 'ia32') {
128 # only save on x64/woa to avoid contention saving
129 $env:SAVE_GCLIENT_SRC="true"
133 cd src\third_party\angle
134 git remote set-url origin https://chromium.googlesource.com/angle/angle.git
139 # file does not exist, gclient sync, then zip
140 $env:RUN_GCLIENT_SYNC="true"
141 if ($env:TARGET_ARCH -ne 'ia32') {
142 # only save on x64/woa to avoid contention saving
143 $env:SAVE_GCLIENT_SRC="true"
147 - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync )
149 if ($env:SAVE_GCLIENT_SRC -eq 'true') {
150 # archive current source for future use
151 # only run on x64/woa to avoid contention saving
152 $(7z a $zipfile src -xr!android_webview -xr!electron -xr'!*\.git' -xr!third_party\WebKit\LayoutTests! -xr!third_party\blink\web_tests -xr!third_party\blink\perf_tests -slp -t7z -mmt=30)
153 if ($LASTEXITCODE -ne 0) {
154 Write-warning "Could not save source to shared drive; continuing anyway"
156 # build time generation of file gen/angle/angle_commit.h depends on
157 # third_party/angle/.git
158 # https://chromium-review.googlesource.com/c/angle/angle/+/2074924
159 $(7z a $zipfile src\third_party\angle\.git)
160 if ($LASTEXITCODE -ne 0) {
161 Write-warning "Failed to add third_party\angle\.git; continuing anyway"
163 # build time generation of file dawn/common/Version_autogen.h depends on third_party/dawn/.git/HEAD
164 # https://dawn-review.googlesource.com/c/dawn/+/83901
165 $(7z a $zipfile src\third_party\dawn\.git)
166 if ($LASTEXITCODE -ne 0) {
167 Write-warning "Failed to add third_party\dawn\.git; continuing anyway"
171 - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn
172 - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% "
173 - gn check out/Default //electron:electron_lib
174 - gn check out/Default //electron:electron_app
175 - gn check out/Default //electron/shell/common/api:mojo
176 - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app)
177 - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default )
178 - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%"
179 - ninja -C out/ffmpeg electron:electron_ffmpeg_zip
180 - ninja -C out/Default electron:electron_dist_zip
181 - ninja -C out/Default shell_browser_ui_unittests
182 - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args
184 # Remove unused args from mksnapshot_args
186 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
187 - ninja -C out/Default electron:electron_mksnapshot_zip
189 - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S
191 - ninja -C out/Default electron:hunspell_dictionaries_zip
192 - ninja -C out/Default electron:electron_chromedriver_zip
193 - ninja -C out/Default third_party/electron_node:headers
194 - python %LOCAL_GOMA_DIR%\goma_ctl.py stat
195 - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json
196 - 7z a node_headers.zip out\Default\gen\node_headers
198 if ($env:GN_CONFIG -eq 'release') {
199 # Needed for msdia140.dll on 64-bit windows
200 $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin"
201 ninja -C out/Default electron:electron_symbols
204 if ($env:GN_CONFIG -eq 'release') {
205 python3 electron\script\zip-symbols.py
206 appveyor-retry appveyor PushArtifact out/Default/symbols.zip
208 # It's useful to have pdb files when debugging testing builds that are
210 7z a pdb.zip out\Default\*.pdb
212 - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
217 if (Test-Path Env:\ELECTRON_RELEASE) {
218 if (Test-Path Env:\UPLOAD_TO_STORAGE) {
219 Write-Output "Uploading Electron release distribution to azure"
220 & python3 script\release\uploaders\upload.py --verbose --upload_to_storage
222 Write-Output "Uploading Electron release distribution to github releases"
223 & python3 script\release\uploaders\upload.py --verbose
225 } elseif (Test-Path Env:\TEST_WOA) {
226 node script/release/ci-release-build.js --job=electron-woa-testing --ci=GHA --appveyorJobId=$env:APPVEYOR_JOB_ID $env:APPVEYOR_REPO_BRANCH
229 # Uncomment this lines to enable RDP
230 #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
232 - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json )
233 - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip)
234 - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe)
235 - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip)
236 - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip)
237 - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip)
238 - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip)
239 - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip)
240 - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib)
242 if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) {
243 appveyor-retry appveyor PushArtifact pdb.zip
253 if ($env:RUN_TESTS -ne 'true') {
254 Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild
256 if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) {
257 Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild
261 node script/yarn.js install --frozen-lockfile
262 node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH
263 if ($LASTEXITCODE -eq 0) {
264 Write-warning "Skipping tests for doc only change"; Exit-AppveyorBuild
266 $global:LASTEXITCODE = 0
271 # Download build artifacts
272 $apiUrl = 'https://ci.appveyor.com/api'
273 $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID"
274 $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib')
275 foreach ($job in $build_info.build.jobs) {
276 if ($job.name -eq "Build") {
278 foreach($artifact_name in $artifacts_to_download) {
279 if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') {
280 $outfile = "src\out\Default\$artifact_name"
282 $outfile = $artifact_name
284 Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile
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
293 - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip
294 - ps: 7z x -y -osrc node_headers.zip
297 # Workaround for https://github.com/appveyor/ci/issues/2420
298 - set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
301 New-Item .\out\Default\gen\node_headers\Release -Type directory
302 Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib
304 - echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging=file --log-file=%cd%\electron.log
305 - echo Running native test suite & node script/yarn test -- --trace-uncaught --runners=native --enable-logging=file --log-file=%cd%\electron.log
307 - echo Verifying non proprietary ffmpeg & python3 electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
308 - echo "About to verify mksnapshot"
309 - echo Verifying mksnapshot & python3 electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
310 - echo "Done verifying mksnapshot"
311 - echo Verifying chromedriver & python3 electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
312 - echo "Done verifying chromedriver"
315 - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log )