From b254a92fc41dff4cd39e44b6dda2c6e5c1ad1d6a Mon Sep 17 00:00:00 2001 From: Ev Date: Wed, 30 May 2018 22:59:18 -0300 Subject: [PATCH] Enabling linux .deb builds (#3914) * Temporarily disabling tests, so we skip to the build process * Enabling .deb builds * Adding gulp verify-artifacts * Add gulp task to pipeline * Re-enabling tests on Travis * unzip package naming * Removing node-unzip-2 from package.json (already included in subdependency) * Using ethereum-client-binaries from npm instead of github --- .travis.yml | 12 ++++--- gulpTasks/building.js | 2 +- gulpTasks/testing.js | 83 +++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +-- yarn.lock | 14 +++++--- 5 files changed, 103 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff1dabf34..64fe4c200 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,15 +83,19 @@ script: # build mist - if [[ $GULP_PLATFORM == "mac" ]]; then travis_wait 60 gulp --$GULP_PLATFORM; fi # increase timeout for slower mac builds - if [[ $GULP_PLATFORM != "mac" ]]; then gulp --$GULP_PLATFORM; fi + + # assert creation of Mist artifacts + - gulp verify-artifacts --mist --$GULP_PLATFORM - # build wallet if on master branch + # build wallet if on master branch - if [[ $TRAVIS_BRANCH == "master" ]]; then travis_wait 60 gulp --wallet --$GULP_PLATFORM; fi - - # debug purposes - see what builds were successfully created - - ls -la ~/build/ethereum/mist/dist_mist/dist + + # assert creation of Wallet artifacts + - if [[ $TRAVIS_BRANCH == "master" ]]; then gulp verify-artifacts --wallet --$GULP_PLATFORM; fi # prepare integration tests - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start; sleep 3; fi + # currently, tests should run in linux and mac - if [[ $GULP_PLATFORM != "win" ]]; then gulp test; fi diff --git a/gulpTasks/building.js b/gulpTasks/building.js index 212030a82..f9a795a9f 100644 --- a/gulpTasks/building.js +++ b/gulpTasks/building.js @@ -139,7 +139,7 @@ gulp.task('build-dist', cb => { linux: { category: 'WebBrowser', icon: `./app/${type}/icons`, - target: ['zip'] + target: ['zip', 'deb'] }, win: { target: ['zip'] diff --git a/gulpTasks/testing.js b/gulpTasks/testing.js index 0e90de99f..21f587fc5 100644 --- a/gulpTasks/testing.js +++ b/gulpTasks/testing.js @@ -1,6 +1,9 @@ const gulp = require('gulp'); const mocha = require('gulp-spawn-mocha'); const options = require('../gulpfile.js').options; +const { version } = require('../package.json'); +const fs = require('fs'); +const colors = require('colors/safe'); gulp.task('test', () => { return gulp.src([`./tests/${options.type}/${options.test}.test.js`]).pipe( @@ -12,3 +15,83 @@ gulp.task('test', () => { }) ); }); + +gulp.task('verify-artifacts', done => { + // I don't like having a non-pure function here + const fileExists = path => { + const fileExist = fs.existsSync(path); + if (fileExist) console.log(colors.green('\t✔︎', path)); + else console.error(colors.red('\t✕', path)); + + return fileExist; + }; + + const makePath = productName => `./dist_${productName}/release/`; + + const dashedVersion = versionString => versionString.replace(/\./g, '-'); + + const makeFilename = productName => version => kind => extension => + `${makePath(productName)}${[ + productNamePrefix(productName), + kind, + dashedVersion(version) + ].join('-')}.${extension}`; + + // need to run .map().every() to display all files status, regardless of optimizations + const allFilesExists = files => files.map(fileExists).every(f => f); + + // should be 'mist' or 'wallet' + const productNamePrefix = productName => + productName == 'mist' ? 'Mist' : 'Ethereum-Wallet'; + + const checkArtifactsLinux = filenameFragment => + allFilesExists([ + filenameFragment('linux32')('zip'), + filenameFragment('linux64')('zip'), + filenameFragment('linux32')('deb'), + filenameFragment('linux64')('deb') + ]); + + const checkArtifactsWindows = filenameFragment => + allFilesExists([ + filenameFragment('win32')('zip'), + filenameFragment('win64')('zip'), + filenameFragment('installer')('exe') + ]); + + const checkArtifactsMac = filenameFragment => + allFilesExists([filenameFragment('macosx')('dmg')]); + + const checkArtifacts = platform => productName => version => { + const filenameFragment = makeFilename(productName)(version); + switch (platform) { + case 'linux': + return checkArtifactsLinux(filenameFragment); + case 'win': + return checkArtifactsWindows(filenameFragment); + case 'mac': + return checkArtifactsMac(filenameFragment); + default: + return false; + } + }; + + // mist, wallet + const product = options.type; + + // win, mac, linux + const platforms = options.activePlatforms; + + console.log(colors.yellow('Checking for generated artifacts...')); + const artifactsAssertion = platforms.map(platform => + checkArtifacts(platform)(product)(version) + ); + + if (artifactsAssertion.every(a => a)) { + done(); + } else { + done( + 'One or all artifacts does not exist or does not have a proper file name.' + ); + } +}); diff --git a/package.json b/package.json index fa27d2883..4faaec717 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "chai-string": "^1.3.0", "electron-redux": "^1.3.1", "electron-window-state": "^4.0.1", - "ethereum-client-binaries": "ethereum/ethereum-client-binaries", + "ethereum-client-binaries": "^1.6.4", "ethereum-keyfile-recognizer": "^1.0.2", "ethereumjs-abi": "^0.6.3", "ethereumjs-tx": "^1.3.3", @@ -64,6 +64,7 @@ "devDependencies": { "chai": "^4.1.1", "co-mocha": "^1.2.0", + "colors": "^1.3.0", "del": "^3.0.0", "ecstatic": "^2.1.0", "electron": "1.8.4", @@ -85,7 +86,6 @@ "json-structure-diff": "^0.0.2", "minimist": "^1.2.0", "mocha": "^3.2.0", - "node-unzip-2": "^0.2.7", "prettier": "1.13.2", "pretty-quick": "^1.4.1", "redux-mock-store": "^1.3.0", diff --git a/yarn.lock b/yarn.lock index 69c065545..255932629 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1522,6 +1522,10 @@ colors@^1.1.2: version "1.2.1" resolved "https://registry.yarnpkg.com/colors/-/colors-1.2.1.tgz#f4a3d302976aaf042356ba1ade3b1a2c62d9d794" +colors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.0.tgz#5f20c9fef6945cb1134260aab33bfbdc8295e04e" + combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" @@ -2610,9 +2614,9 @@ eth-lib@0.2.7: elliptic "^6.4.0" xhr-request-promise "^0.1.2" -ethereum-client-binaries@ethereum/ethereum-client-binaries: +ethereum-client-binaries@^1.6.4: version "1.6.4" - resolved "https://codeload.github.com/ethereum/ethereum-client-binaries/tar.gz/cf435cab290d7b737ca368db7eb9b89d63c41e82" + resolved "https://registry.yarnpkg.com/ethereum-client-binaries/-/ethereum-client-binaries-1.6.4.tgz#c4fcf97e873d6c66f7f33cb501b4059868baaee5" dependencies: buffered-spawn "^3.3.2" got "^6.5.0" @@ -2620,7 +2624,7 @@ ethereum-client-binaries@ethereum/ethereum-client-binaries: lodash.isempty "^4.4.0" lodash.values "^4.3.0" mkdirp "^0.5.1" - node-unzip-2 "github:glebdmitriew/node-unzip-2" + node-unzip-2 "^0.2.7" tmp "0.0.29" ethereum-common@^0.0.18: @@ -5050,9 +5054,9 @@ node-pre-gyp@^0.6.39: tar "^2.2.1" tar-pack "^3.4.0" -node-unzip-2@^0.2.7, "node-unzip-2@github:glebdmitriew/node-unzip-2": +node-unzip-2@^0.2.7: version "0.2.7" - resolved "https://codeload.github.com/glebdmitriew/node-unzip-2/tar.gz/3702bce9596496bf45442e156541c68eb965b9f9" + resolved "https://registry.yarnpkg.com/node-unzip-2/-/node-unzip-2-0.2.7.tgz#33433d018ded3ca9219e757990cc0b990e4fa51b" dependencies: binary "~0.3.0" fstream "~1.0.10"