From e442963e32c9b4b7b499594193354fdadf9b1068 Mon Sep 17 00:00:00 2001 From: Michael Orenstein Date: Fri, 18 Nov 2016 20:54:15 +1000 Subject: [PATCH] Added electron builds to travis and appveyor. --- .travis.yml | 45 ++++++++++++++++++++++++++++++++++++-- appveyor.yml | 39 +++++++++++++++++++++++++++++---- test/electron/main.js | 13 +++++++++++ test/electron/package.json | 5 +++++ 4 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 test/electron/main.js create mode 100644 test/electron/package.json diff --git a/.travis.yml b/.travis.yml index fd55dd3..c966005 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,17 @@ addons: - g++-4.8 - g++-4.8-multilib - gcc-multilib + - libgtk2.0-0 + - libxtst6 + - libnotify4 + - libgconf2-4 + - libgtk2.0-0:i386 + - libxtst6:i386 + - libnotify4:i386 + - libgconf2-4:i386 + - libnss3:i386 + - libasound2:i386 + - libxss1:i386 # Build matrix os: @@ -18,6 +29,8 @@ env: global: - secure: "qEdwCY/ilHkqWkqasN5MgWCnzzop4lEYkbpxEiVMTZBY12p4uV6ysPQ+ZLZcx10Cg90RIQlsPeEANIhCzkWfnQi+ySmeiKY9JR2eSnb69wM7dBQ/uxv04eVChAlZSsDHwmTIIzIzZFsrWrcwwJaENGCJYKqZ9LKOiGFGQ8Is09A=" matrix: + - TRAVIS_NODE_VERSION="5" + - TRAVIS_NODE_VERSION="5" ARCH="x86" - TRAVIS_NODE_VERSION="0.10" - TRAVIS_NODE_VERSION="0.10" ARCH="x86" - TRAVIS_NODE_VERSION="0.12" @@ -28,6 +41,8 @@ env: - TRAVIS_NODE_VERSION="6" ARCH="x86" - TRAVIS_NODE_VERSION="7" - TRAVIS_NODE_VERSION="7" ARCH="x86" + - TRAVIS_ELECTRON_VERSION="1.4.6" ARCH="x64" TRAVIS_NODE_VERSION="5" + - TRAVIS_ELECTRON_VERSION="1.4.6" ARCH="ia32" TRAVIS_NODE_VERSION="5" matrix: exclude: - os: osx @@ -40,6 +55,8 @@ matrix: env: TRAVIS_NODE_VERSION="6" ARCH="x86" - os: osx env: TRAVIS_NODE_VERSION="7" ARCH="x86" + - os: osx + env: TRAVIS_ELECTRON_VERSION="1.4.6" ARCH="ia32" TRAVIS_NODE_VERSION="5" before_install: # reinstall latest nvm @@ -75,16 +92,40 @@ before_install: - npm config set progress false - npm config set spin false +- > + if [[ ! -z $TRAVIS_ELECTRON_VERSION ]]; then + if [[ $TRAVIS_OS_NAME == "linux" ]]; then + export DISPLAY=:99.0 + sh -e /etc/init.d/xvfb start + fi + + export npm_config_target=$TRAVIS_ELECTRON_VERSION + export npm_config_arch=$ARCH + export npm_config_disturl=https://atom.io/download/atom-shell + export npm_config_runtime=electron + + npm install --arch=$ARCH electron@$TRAVIS_ELECTRON_VERSION + npm install electron-mocha + + echo "installed Electron $TRAVIS_ELECTRON_VERSION" + fi + install: # ensure source install works - npm install --build-from-source + script: # linting no longer works on node 0.10 - node bin/lower-than-node-4.0.js || npm run lint - npm run docs:diff -- node ./ -- npm test +- > + if [[ -z $TRAVIS_ELECTRON_VERSION ]]; then + node ./ + npm test + else + electron test/electron + fi # if publishing, do it - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package; fi; diff --git a/appveyor.yml b/appveyor.yml index f0d9946..9f3b33c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,10 @@ environment: - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "6" + - nodejs_version: "5" - nodejs_version: "7" + - electron_version: "1.4.6" + nodejs_version: "5" platform: - x86 @@ -29,6 +32,7 @@ install: "APPVEYOR_REPO_COMMIT_MESSAGE" = $env:APPVEYOR_REPO_COMMIT_MESSAGE "git latest tag" = "$(git describe --tags --always HEAD)" "appveyor_repo_tag" = $env:appveyor_repo_tag + "electron_version" = $env:electron_version } | Out-String | Write-Host; # work around bug in npm 2.15.1 where checksums were coming back bad (node 0.12) @@ -56,9 +60,9 @@ install: - ps: > if ($env:publish_binary -eq 1) { - "We're publising a binary!" | Write-Host + "We're publishing a binary!" | Write-Host } else { - "We're not publising a binary" | Write-Host + "We're not publishing a binary" | Write-Host } true; @@ -70,6 +74,27 @@ install: # We don't currently have a port to test on windows # - ps: $env:TEST_PORT = "COM1"; + # Setup Electron variables + - ps: > + if ($env:electron_version) { + "We're an electron build, setup variables" | Write-Host + $env:npm_config_target = $env:electron_version + $env:npm_config_disturl = "https://atom.io/download/atom-shell" + $env:npm_config_runtime = "electron" + + if ($env:plaftorm -eq "x86") { + $env:npm_config_arch = "ia32" + } else { + $env:npm_config_arch = "x64" + } + + "Install electron and electron-mocha" | Write-Host + + npm install -g electron@$env:electron_version + npm install electron-mocha + } + true; + build_script: - npm install --build-from-source --msvs_version=2013 @@ -81,8 +106,14 @@ test_script: "Not linting because the linter doesn't run on this version of node" | Write-Host true; } - - node ./ - - npm test + + # If we run npm test in powershell it'll have the wrong encoding + # so we have to do it like this + + - IF DEFINED electron_version (electron test/electron) + - IF NOT DEFINED electron_version (node ./) + - IF NOT DEFINED electron_version (npm test) + - IF %PUBLISH_BINARY% == 1 (node-pre-gyp package 2>&1) - IF %PUBLISH_BINARY% == 1 (node-pre-gyp-github publish --release 2>&1) - IF %PUBLISH_BINARY% == 1 (node-pre-gyp clean) diff --git a/test/electron/main.js b/test/electron/main.js new file mode 100644 index 0000000..6865e54 --- /dev/null +++ b/test/electron/main.js @@ -0,0 +1,13 @@ +'use strict'; + +var app = require('electron').app; + +try { + var serialport = require('../..'); // eslint-disable-line no-unused-vars +} catch (e) { + console.error('Error loading serialport'); + console.error(e); + app.exit(-1); +} + +app.quit(); \ No newline at end of file diff --git a/test/electron/package.json b/test/electron/package.json new file mode 100644 index 0000000..a95cce4 --- /dev/null +++ b/test/electron/package.json @@ -0,0 +1,5 @@ +{ + "name" : "your-app", + "version" : "0.1.0", + "main" : "main.js" +} \ No newline at end of file