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

fix: enable updates on mac for the unified client #2153

Merged
merged 49 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f8250d7
try removing pkg file
karanbirsingh Feb 7, 2020
890ff15
restrict to mac
karanbirsingh Feb 7, 2020
ff2138e
move to parameter
karanbirsingh Feb 8, 2020
2a946bf
use mac variable
karanbirsingh Feb 8, 2020
7845353
try os agent
karanbirsingh Feb 8, 2020
ff2312b
install 7z explicitly
karanbirsingh Feb 8, 2020
1d82bd5
try script
karanbirsingh Feb 8, 2020
9b7ad6c
wrong script was invoked
karanbirsingh Feb 8, 2020
f262a92
just mac pipeline for testing
karanbirsingh Feb 8, 2020
50758d2
change worknig directory before executing 7z
karanbirsingh Feb 10, 2020
cf5707b
create zip ourselves
karanbirsingh Feb 10, 2020
cbed681
remove zip from electron builder targets
karanbirsingh Feb 10, 2020
d52e404
update path to script and remove e2e tests
karanbirsingh Feb 10, 2020
3fed660
fix typo
karanbirsingh Feb 10, 2020
ec4f8f1
only zip mac folder
karanbirsingh Feb 10, 2020
a355e4a
change back to exe
karanbirsingh Feb 10, 2020
e05d4c5
pull from mac branch artifacts
karanbirsingh Feb 10, 2020
8f39f78
target zip agian
karanbirsingh Feb 10, 2020
11396be
remove optional size and blockmapsize properties
karanbirsingh Feb 10, 2020
b47b2c5
update 7z scripts to remove wrapper dependency, move zipping into grunt
karanbirsingh Feb 11, 2020
f0b6e3e
update latest file based on platform
karanbirsingh Feb 11, 2020
3ea624f
rename update checksum to update yaml
karanbirsingh Feb 11, 2020
fb5e7e1
rename update checksum to update yaml
karanbirsingh Feb 11, 2020
7a2ddbf
rename update checksum to update yaml
karanbirsingh Feb 11, 2020
3716873
restore e2e test
karanbirsingh Feb 11, 2020
91e3f18
restore multiple platforms
karanbirsingh Feb 11, 2020
5d7908f
add missing import
karanbirsingh Feb 11, 2020
55cae8e
redirect stdio
karanbirsingh Feb 11, 2020
fc9e5e3
try cwd instead of cd
karanbirsingh Feb 11, 2020
430be35
quotes so spaces work in command line
karanbirsingh Feb 11, 2020
b18bdb6
add cwd
karanbirsingh Feb 11, 2020
fde684a
w recursive param
karanbirsingh Feb 11, 2020
91f4784
npm workaround
karanbirsingh Feb 11, 2020
b848da6
yarnrc as well
karanbirsingh Feb 11, 2020
7ad4108
try npx instead of yarn
karanbirsingh Feb 11, 2020
ac40199
Revert zipping to use wrapper library (worked in prior build)to help …
karanbirsingh Feb 12, 2020
6c46f95
fix size reference and add better error handling
karanbirsingh Feb 12, 2020
711dfcb
add parentDir to resolve request
karanbirsingh Feb 12, 2020
4665f1b
add process.exit
karanbirsingh Feb 12, 2020
d6d395f
Revert "Revert zipping to use wrapper library (worked in prior build)…
karanbirsingh Feb 12, 2020
3ee299d
Remove workaround for npm package outage
karanbirsingh Feb 12, 2020
382b654
use master as trigger
karanbirsingh Feb 12, 2020
be7508e
add comments and remove unnecessary complexity (direct node instead o…
karanbirsingh Feb 12, 2020
fd73914
switch missed instance of yarn script to direct node call
karanbirsingh Feb 12, 2020
e0c1cd7
Temporarily build from mac branch instead of master
karanbirsingh Feb 12, 2020
d89d927
use parameter instead of agent OS to make build more platform agnostic
karanbirsingh Feb 12, 2020
6f8ed7f
removing pkg file since signing service no longer seems to modify dow…
karanbirsingh Feb 12, 2020
6bdb6ad
Merge branch 'mac' of https://github.com/microsoft/accessibility-insi…
karanbirsingh Feb 12, 2020
8f4d9f3
revert canary signing pipeline resource change
karanbirsingh Feb 12, 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
41 changes: 41 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ module.exports = function(grunt) {
// empty on purpose
},
},
'zip-mac-folder': {
[targetName]: {
dropPath: dropPath,
},
},
});
});

Expand Down Expand Up @@ -437,10 +442,46 @@ module.exports = function(grunt) {
);
});

grunt.registerMultiTask('zip-mac-folder', function() {
grunt.task.requires('drop:' + this.target);
grunt.task.requires('configure-electron-builder:' + this.target);
grunt.task.requires('electron-builder-pack:' + this.target);

// We found that the mac update fails unless we produce the
// zip file ourselves; electron-builder requires a zip file, but
// the zip file it produces leads to 'couldn't find pkzip signatures'
// during the eventual update.

if (process.platform !== 'darwin') {
grunt.log.writeln(`task not required for this platform (${process.platform})`);
return true;
}

const { dropPath } = this.data;
const packedPath = `${dropPath}/packed`;

const taskDoneCallback = this.async();

grunt.util.spawn(
{
cmd: 'node',
args: ['pipeline/scripts/zip-mac-folder.js', packedPath],
},
(error, result, code) => {
if (error) {
grunt.fail.fatal(`zipping mac folder exited with error code ${code}:\n\n${result.stdout}`, code);
}

taskDoneCallback();
},
);
});

grunt.registerMultiTask('unified-release-drop', function() {
grunt.task.run(`drop:${this.target}`);
grunt.task.run(`configure-electron-builder:${this.target}`);
grunt.task.run(`electron-builder-pack:${this.target}`);
grunt.task.run(`zip-mac-folder:${this.target}`);
});

grunt.registerTask('package-report', function() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"test:e2e:docker:run": "docker run -t accessibility-insights-web-e2e",
"test:e2e:docker": "npm-run-all --serial test:e2e:docker:build \"test:e2e:docker:run {@}\" --",
"test:unified": "cross-env --max-old-space-size=16384 jest --projects src/tests/electron --runInBand",
"update:electron-checksum": "node ./pipeline/scripts/update-electron-checksum.js",
"watch": "npm-run-all --parallel --race --print-label watch:scss watch:grunt watch:test watch:webpack-dev-browser watch:webpack-unified",
"watch:build:all": "npm-run-all --parallel --race --print-label watch:scss watch:grunt watch:webpack-dev-browser watch:webpack-unified",
"watch:build:web": "npm-run-all --parallel --race --print-label watch:scss watch:grunt watch:webpack-dev-browser",
Expand Down Expand Up @@ -127,6 +126,7 @@
"webpack-node-externals": "^1.7.2"
},
"dependencies": {
"7zip-bin": "^5.0.3",
"applicationinsights-js": "^1.0.21",
"axe-core": "3.3.2",
"axios": "^0.19.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const YAML = require('js-yaml');
const path = require('path');

const parentDir = process.argv[2];
const platform = process.argv[3]; // should be 'mac', 'linux', or 'windows'

const getLatestYAMLPath = parentDir => {
const platformModifier = process.platform == 'darwin' ? '-mac' : process.platform == 'linux' ? '-linux' : '';
const platformModifier = platform === 'windows' ? '' : `-${platform}`;
const latestPath = path.join(parentDir, `latest${platformModifier}.yml`);
return latestPath;
};
Expand Down Expand Up @@ -42,11 +43,29 @@ const writeLatestYAML = (latestPath, latestContent) => {
fs.writeFileSync(latestPath, rawLatestContent);
};

const updateElectronChecksum = async () => {
// On mac we add the zip file ourselves & thus need
// to update the latest-mac.yml files entry
const updateFileList = latestContent => {
if (platform === 'mac') {
const files = fs.readdirSync(parentDir);
const zipFile = files.find(f => path.extname(f) === '.zip');
latestContent.files.push({
url: path.basename(zipFile),
sha512: 'WILL BE OVERWRITTEN',
size: fs.statSync(path.resolve(parentDir, zipFile)).size,
});
}
};

const updateLatestYaml = async () => {
const latestPath = getLatestYAMLPath(parentDir);
const latestContent = readLatestYAML(latestPath);
updateFileList(latestContent);
await updateAllSha512s(latestContent);
writeLatestYAML(latestPath, latestContent);
};

updateElectronChecksum();
updateLatestYaml().catch(err => {
console.error(err);
process.exit(1);
});
28 changes: 28 additions & 0 deletions pipeline/scripts/zip-mac-folder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/*
The macOS electron-builder update process requires a zip file
(electron-builder #4230), but the zip file produced by
electron-builder is corrupted (electron-builder #3534).
We use 7z to create the zip file ourselves.
*/

const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const sevenBin = require('7zip-bin');

const parentDir = process.argv[2];
const files = fs.readdirSync(parentDir);
const existingDmg = files.find(f => path.extname(f) === '.dmg');
const appName = path.basename(existingDmg, path.extname(existingDmg));

console.log(`existingDmg: ${existingDmg}`);
console.log(`appName: ${appName}`);
console.log(`path to 7z: ${sevenBin.path7za}`);

child_process.execSync(`${sevenBin.path7za} a "${appName}.zip" -r mac`, {
cwd: parentDir,
stdio: 'inherit',
});
4 changes: 2 additions & 2 deletions pipeline/unified/channel/sign-release-package-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ jobs:
Accessibility_Insights_for_Android*.*
TargetFolder: '$(System.DefaultWorkingDirectory)/signing-in-progress/${{ parameters.signedArtifactName }}'

- script: yarn update:electron-checksum signing-in-progress/${{ parameters.signedArtifactName }}
displayName: update electron checksum after signing
- script: node ./pipeline/scripts/update-latest-yml.js signing-in-progress/${{ parameters.signedArtifactName }} linux
displayName: update electron-builder latest yaml after signing

- template: ../publish-packed-build-output.yaml
parameters:
Expand Down
1 change: 1 addition & 0 deletions pipeline/unified/channel/sign-release-package-mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
signedArtifactName: ${{ parameters.signedArtifactName }}
vmImage: macOS-10.14
filePattern: '*.dmg, *.zip'
platform: mac
inlineSignParams: |
[
{
Expand Down
1 change: 1 addition & 0 deletions pipeline/unified/channel/sign-release-package-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
signedArtifactName: ${{ parameters.signedArtifactName }}
vmImage: windows-latest
filePattern: '*.exe, *.dll'
platform: windows
inlineSignParams: |
[
{
Expand Down
5 changes: 3 additions & 2 deletions pipeline/unified/channel/sign-release-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ parameters:
unsignedPipelineResource: null
unsignedArtifactName: null
signedArtifactName: null
platform: null

jobs:
- job: ${{ parameters.signedArtifactName }}
Expand Down Expand Up @@ -34,8 +35,8 @@ jobs:
signConfigType: inlineSignParams
inlineOperation: ${{ parameters.inlineSignParams }}

- script: yarn update:electron-checksum signing-in-progress/${{ parameters.signedArtifactName }}
displayName: update electron checksum after signing
- script: node ./pipeline/scripts/update-latest-yml.js signing-in-progress/${{ parameters.signedArtifactName }} ${{ parameters.platform }}
displayName: update electron-builder latest.yml after signing

- template: ../publish-packed-build-output.yaml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ linux:
mac:
artifactName: ${productName}.${ext}
icon: TARGET_SPECIFIC
target: [dmg, zip] # zip is required because of electron-userland/electron-builder#2199
target: dmg # we also need zip (electron-userland/electron-builder#2199) & add it in grunt
identity: null

win:
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yarn lockfile v1


"7zip-bin@~5.0.3":
"7zip-bin@^5.0.3", "7zip-bin@~5.0.3":
version "5.0.3"
resolved "https://registry.yarnpkg.com/7zip-bin/-/7zip-bin-5.0.3.tgz#bc5b5532ecafd923a61f2fb097e3b108c0106a3f"
integrity sha512-GLyWIFBbGvpKPGo55JyRZAo4lVbnBiD52cKlw/0Vt+wnmKvWJkpZvsjVoaIolyBXDeAQKSicRtqFNPem9w0WYA==
Expand Down