Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: explicitly download electron mirror #2596

Merged
merged 29 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
70d26ea
refactor electron mirror step
karanbirsingh Apr 21, 2020
cc81f56
rename env var
karanbirsingh Apr 21, 2020
553e525
Remove env var from electron builder step
karanbirsingh Apr 21, 2020
fdecfbb
remove unneeded variable
karanbirsingh Apr 21, 2020
b2e0459
remove explicit envvar mapping
karanbirsingh Apr 21, 2020
b8a69e3
rename to test if filename issues lead to mac read failure
karanbirsingh Apr 22, 2020
0c6c632
add path.resolve
karanbirsingh Apr 22, 2020
c3e713c
use open directory instead of stream
karanbirsingh Apr 22, 2020
d0c5722
switch to async api
karanbirsingh Apr 22, 2020
7bfcf71
more log statements
karanbirsingh Apr 22, 2020
dee9586
Follow symlinks
karanbirsingh Apr 22, 2020
84f6dab
use mirrored chromedriver
karanbirsingh Apr 22, 2020
fe76ca8
show logs
karanbirsingh Apr 22, 2020
9a452b1
continue on error
karanbirsingh Apr 22, 2020
37253ef
chromedriver args
karanbirsingh Apr 22, 2020
2b285c8
revert chromedriver args
karanbirsingh Apr 22, 2020
508e3cd
remove unneeded fs reference
karanbirsingh Apr 22, 2020
24ee7c3
try just sandbox
karanbirsingh Apr 22, 2020
f91ae5f
merge with master
karanbirsingh Apr 29, 2020
831db0f
Try without chromedriver mirror
karanbirsingh Apr 30, 2020
2d1c7a7
switch to same library used by electron yarn install script to unzip
karanbirsingh Apr 30, 2020
993c076
fix casing
karanbirsingh Apr 30, 2020
51d8f62
typo
karanbirsingh Apr 30, 2020
73ea47d
add comments and remove logging code
karanbirsingh Apr 30, 2020
7c71e80
Remove unzipper
karanbirsingh Apr 30, 2020
8796909
revert order change in package.json
karanbirsingh Apr 30, 2020
a8df26a
remove dev dep
karanbirsingh May 1, 2020
e9d084c
update comment
karanbirsingh May 1, 2020
6f3cba8
merge with master
karanbirsingh May 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"with:mock-service-for-android": "npm-run-all --race --parallel serve:mock-service-for-android"
},
"devDependencies": {
"7zip-bin": "^5.0.3",
karanbirsingh marked this conversation as resolved.
Show resolved Hide resolved
"@electron/get": "^1.10.0",
"@types/applicationinsights-js": "^1.0.7",
"@types/chrome": "0.0.106",
"@types/enzyme": "^3.10.5",
Expand All @@ -76,7 +78,6 @@
"@types/serve-static": "^1.13.3",
"@types/ua-parser-js": "^0.7.33",
"@types/uuid": "^7.0.3",
"7zip-bin": "^5.0.3",
"app-builder-lib": "^22.6.0",
"case-sensitive-paths-webpack-plugin": "^2.3.0",
"codecov": "^3.6.5",
Expand All @@ -85,10 +86,10 @@
"cross-env": "^7.0.2",
"css-loader": "^3.5.3",
"electron-builder": "^22.6.0",
"electron-download": "^4.1.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"express": "^4.16.4",
"extract-zip": "^2.0.0",
"fake-indexeddb": "^3.0.0",
"fork-ts-checker-webpack-plugin": "^4.1.3",
"grunt": "^1.1.0",
Expand Down Expand Up @@ -129,7 +130,6 @@
"typed-scss-modules": "^1.3.0",
"typemoq": "^2.1.0",
"typescript": "^3.8.3",
"unzipper": "^0.10.11",
"webdriverio": "^4.13.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
Expand Down
71 changes: 50 additions & 21 deletions pipeline/scripts/download-electron-mirror.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const pkg = require('../../package.json');
const download = require('electron-download');
karanbirsingh marked this conversation as resolved.
Show resolved Hide resolved
const unzipper = require('unzipper');
const { downloadArtifact } = require('@electron/get');
const extract = require('extract-zip');
const fs = require('fs');
const path = require('path');

download(
{
version: pkg.dependencies.electron,
cache: 'drop/zips',
},
function (err, zipPath) {
// zipPath will be the path of the zip that it downloaded.
// If the zip was already cached it will skip
// downloading and call the cb with the cached zip path.
// If it wasn't cached it will download the zip and save
// it in the cache path.
if (err) {
console.log('Failed to download: ', err);
} else {
console.log('zipPath= ', zipPath);
fs.createReadStream(zipPath).pipe(unzipper.Extract({ path: 'drop/electron-local' }));
}
},
);
/*
This script replaces existing electron & chromedriver modules
with mirror dependencies specified by ELECTRON_MIRROR_VAR
and ELECTRON_CUSTOM_DIR_VAR (see @electron/get). We use this
to avoid bundling non-freely-redistributable media codecs
in our release builds. The version of Electron published to npm
includes these as part of Chromium; our release builds use a
Microsoft-maintained build of Electron that removes those codecs.
*/

if (
process.env.ELECTRON_MIRROR_VAR === undefined ||
process.env.ELECTRON_CUSTOM_DIR_VAR === undefined
) {
console.error('ELECTRON_MIRROR_VAR and ELECTRON_CUSTOM_DIR_VAR must be defined');
process.exit(1);
}

const downloadMirrors = async () => {
await downloadElectronArtifact('electron', 'node_modules/electron/dist');
await downloadElectronArtifact('chromedriver', 'node_modules/electron-chromedriver/bin');
};

const downloadElectronArtifact = async (artifactName, destinationPath) => {
destinationPath = path.resolve(destinationPath);
console.log(`downloading ${artifactName} at ${pkg.dependencies.electron}`);
const zipFilePath = await downloadArtifact({
version: `${pkg.dependencies.electron}`,
artifactName,
mirrorOptions: {
mirror: process.env.ELECTRON_MIRROR_VAR,
customDir: process.env.ELECTRON_CUSTOM_DIR_VAR,
},
force: true,
});
console.log(`zip downloaded to dir ${zipFilePath}`);
console.log(`extracting to ${destinationPath}`);

fs.rmdirSync(destinationPath, { recursive: true });

await extract(zipFilePath, { dir: destinationPath });
};

downloadMirrors().catch(err => {
console.error(err);
process.exit(1);
});
3 changes: 0 additions & 3 deletions pipeline/unified/build-unsigned-release-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ steps:

- script: yarn build:unified:all --unified-version=$(Build.BuildNumber) --unified-canary-instrumentation-key=$(UnifiedCanaryInstrumentationKey) --unified-insider-instrumentation-key=$(UnifiedInsiderInstrumentationKey) --unified-prod-instrumentation-key=$(UnifiedProdInstrumentationKey)
displayName: yarn build:unified:all
env:
ELECTRON_MIRROR: $(ELECTRON_822_MIRROR_VAR)
ELECTRON_CUSTOM_DIR: $(ELECTRON_822_CUSTOM_DIR_VAR)

- script: node ./pipeline/scripts/print-file-hash-info.js $(System.DefaultWorkingDirectory)/drop/electron/unified-canary/packed
displayName: print out canary file hashes
Expand Down
2 changes: 2 additions & 0 deletions src/electron/electron-builder/electron-builder.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ nsis:
include: src/electron/resources/installer.nsh
publish:
provider: generic

electronDist: node_modules/electron/dist
8 changes: 3 additions & 5 deletions src/tests/electron/common/create-application.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as Electron from 'electron';
import * as fs from 'fs';
import { Application } from 'spectron';

import {
Expand All @@ -15,14 +14,13 @@ export interface AppOptions {
}

export async function createApplication(options?: AppOptions): Promise<AppController> {
const electronPath = `${
const targetApp = `${
(global as any).rootDir
}/drop/electron/unified-dev/product/bundle/main.bundle.js`;
const electronLocal = `${(global as any).rootDir}/drop/electron-local/electron.exe`;

const app = new Application({
path: fs.existsSync(electronLocal) ? electronLocal : (Electron as any),
args: [electronPath],
path: Electron as any,
args: [targetApp],
connectionRetryCount: DEFAULT_APP_CONNECT_RETRIES,
connectionRetryTimeout: DEFAULT_APP_CONNECT_TIMEOUT_MS,
});
Expand Down
95 changes: 25 additions & 70 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,22 @@
global-agent "^2.0.2"
global-tunnel-ng "^2.7.1"

"@electron/get@^1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.10.0.tgz#258fdda22bbd5a247e0b663ba9c525dedc1bdfff"
integrity sha512-hlueNXU51c3CwQjBw/i5fwt+VfQgSQVUTdicpCHkhEjNZaa4CXJ5W1GaxSwtLE2dvRmAHjpIjUMHTqJ53uojfg==
dependencies:
debug "^4.1.1"
env-paths "^2.2.0"
fs-extra "^8.1.0"
got "^9.6.0"
progress "^2.0.3"
sanitize-filename "^1.6.2"
sumchecker "^3.0.1"
optionalDependencies:
global-agent "^2.0.2"
global-tunnel-ng "^2.7.1"

"@fluentui/react-focus@^7.1.0":
version "7.1.2"
resolved "https://registry.yarnpkg.com/@fluentui/react-focus/-/react-focus-7.1.2.tgz#f269235f9d5cbf649c4b148a4a772741c4cf57c8"
Expand Down Expand Up @@ -1766,11 +1782,6 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

big-integer@^1.6.17:
version "1.6.48"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e"
integrity sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w==

big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
Expand All @@ -1786,14 +1797,6 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c"
integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==

binary@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79"
integrity sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=
dependencies:
buffers "~0.1.1"
chainsaw "~0.1.0"

bl@^1.0.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c"
Expand Down Expand Up @@ -1830,11 +1833,6 @@ bluebird@^3.5.5:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.1.tgz#df70e302b471d7473489acf26a93d63b53f874de"
integrity sha512-DdmyoGCleJnkbp3nkbxTLJ18rjDsE4yCggEwKNXkeV123sPNfOCYeDoeuOY+F2FrSjO1YXcTU+dsy96KMy+gcg==

bluebird@~3.4.1:
version "3.4.7"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3"
integrity sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=

bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0:
version "4.11.8"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"
Expand Down Expand Up @@ -2057,11 +2055,6 @@ [email protected], buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==

buffer-indexof-polyfill@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.1.tgz#a9fb806ce8145d5428510ce72f278bb363a638bf"
integrity sha1-qfuAbOgUXVQoUQznLyeLs2OmOL8=

buffer-xor@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9"
Expand Down Expand Up @@ -2092,11 +2085,6 @@ buffer@^5.2.1, buffer@^5.5.0:
base64-js "^1.0.2"
ieee754 "^1.1.4"

buffers@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb"
integrity sha1-skV5w77U1tOWru5tmorn9Ugqt7s=

[email protected]:
version "8.7.0"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-8.7.0.tgz#e48ad004835c8284662e8eaf47a53468c66e8e8d"
Expand Down Expand Up @@ -2268,13 +2256,6 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=

chainsaw@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98"
integrity sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=
dependencies:
traverse ">=0.3.0 <0.4"

[email protected], chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2, chalk@~2.4.1:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
Expand Down Expand Up @@ -3264,13 +3245,6 @@ dotenv@^8.2.0:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==

duplexer2@~0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
integrity sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=
dependencies:
readable-stream "^2.0.2"

duplexer3@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
Expand Down Expand Up @@ -6237,11 +6211,6 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

listenercount@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937"
integrity sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc=

livereload-js@^2.3.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/livereload-js/-/livereload-js-2.4.0.tgz#447c31cf1ea9ab52fc20db615c5ddf678f78009c"
Expand Down Expand Up @@ -7855,7 +7824,7 @@ progress-stream@^1.1.0:
speedometer "~0.1.2"
through2 "~0.2.3"

progress@^2.0.1:
progress@^2.0.1, progress@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
Expand Down Expand Up @@ -8921,7 +8890,7 @@ set-value@^2.0.0, set-value@^2.0.1:
is-plain-object "^2.0.3"
split-string "^3.0.1"

setimmediate@^1.0.4, setimmediate@^1.0.5, setimmediate@~1.0.4:
setimmediate@^1.0.4, setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=
Expand Down Expand Up @@ -9484,6 +9453,13 @@ sumchecker@^3.0.0:
dependencies:
debug "^4.1.0"

sumchecker@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/sumchecker/-/sumchecker-3.0.1.tgz#6377e996795abb0b6d348e9b3e1dfb24345a8e42"
integrity sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==
dependencies:
debug "^4.1.0"

[email protected], supports-color@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3"
Expand Down Expand Up @@ -9856,11 +9832,6 @@ tr46@^1.0.1:
dependencies:
punycode "^2.1.0"

"traverse@>=0.3.0 <0.4":
version "0.3.9"
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"
integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=

trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
Expand Down Expand Up @@ -10158,22 +10129,6 @@ unzip-response@^2.0.1:
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97"
integrity sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=

unzipper@^0.10.11:
version "0.10.11"
resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e"
integrity sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw==
dependencies:
big-integer "^1.6.17"
binary "~0.3.0"
bluebird "~3.4.1"
buffer-indexof-polyfill "~1.0.0"
duplexer2 "~0.1.4"
fstream "^1.0.12"
graceful-fs "^4.2.2"
listenercount "~1.0.1"
readable-stream "~2.3.6"
setimmediate "~1.0.4"

upath@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894"
Expand Down