Skip to content

Commit

Permalink
Merge pull request #976 from kewde/electron-ci-builds
Browse files Browse the repository at this point in the history
add electron builds to ci (continued)
  • Loading branch information
springmeyer authored Jun 23, 2018
2 parents 57f97d2 + 599c7f8 commit 60523c4
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 38 deletions.
55 changes: 53 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ matrix:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5']
- os: linux
compiler: clang
env: NODE_VERSION="5" COVERAGE=true PUBLISHABLE=false
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5']
- os: linux
compiler: clang
env: NODE_VERSION="4"
Expand Down Expand Up @@ -100,6 +107,43 @@ matrix:
- os: osx
compiler: clang
env: NODE_VERSION="4" # node abi 46
# electron Linux
- os: linux
compiler: clang
env: NODE_VERSION="6" ELECTRON_VERSION="2.0.1"
dist: trusty # needed for libc6 / 'version `GLIBC_2.17` not found' error on precise
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5', 'libc6']
- os: linux
compiler: clang
env: NODE_VERSION="6" ELECTRON_VERSION="1.8.4"
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5']
- os: linux
compiler: clang
env: NODE_VERSION="6" ELECTRON_VERSION="1.7.12"
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5']
- os: linux
compiler: clang
env: NODE_VERSION="6" ELECTRON_VERSION="1.6.2"
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5']
- os: linux
compiler: clang
env: NODE_VERSION="6" ELECTRON_VERSION="1.3.14"
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
packages: [ 'clang-3.5']

env:
global:
Expand Down Expand Up @@ -127,14 +171,21 @@ before_script:
- export COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
- if [[ ${COVERAGE} == true ]]; then
if [[ $(uname -s) == 'Linux' ]]; then
PYTHONUSERBASE=$(pwd)/py-local pip install --user cpp-coveralls;
curl https://bootstrap.pypa.io/get-pip.py | python - --user;
pip install --user cpp-coveralls;
else
PYTHONUSERBASE=$(pwd)/py-local easy_install --user cpp-coveralls;
fi;
fi

script:
- if [[ "${NODE_VERSION}" ]]; then ./scripts/build_against_node.sh; fi;
- if [[ "${NODE_VERSION}" ]]; then
if [[ "${ELECTRON_VERSION}" ]]; then
./scripts/build_against_electron.sh;
else
./scripts/build_against_node.sh;
fi;
fi
- if [[ "${NODE_VERSION}" -eq "4" ]]; then ./node_modules/.bin/eslint lib; fi;
# disabled for now: need to port to sudo:false
#- if [[ "${NODE_WEBKIT}" ]]; then ./scripts/build_against_node_webkit.sh; fi;
55 changes: 55 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,61 @@ environment:
platform: x64
- nodejs_version: 10
platform: x86
# electron
- nodejs_version: 8
platform: x64
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 2.0.1
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 8
platform: x86
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 2.0.1
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 8
platform: x64
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.8.4
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 8
platform: x86
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.8.4
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 7
platform: x64
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.7.12
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 7
platform: x86
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.7.12
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 6
platform: x64
msvs_toolset: 12
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.6.2
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 6
platform: x86
msvs_toolset: 12
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.6.2
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 6
platform: x64
msvs_toolset: 12
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.3.14
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
- nodejs_version: 6
platform: x86
msvs_toolset: 12
NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 1.3.14
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron

os: Visual Studio 2015

Expand Down
23 changes: 20 additions & 3 deletions scripts/build-appveyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ IF /I "%msvs_version%"=="" ECHO msvs_version unset, defaulting to 2015 && SET ms

SET PATH=%CD%;%PATH%
IF "%msvs_toolset%"=="12" SET msvs_version=2013
IF NOT "%NODE_RUNTIME%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --runtime=%NODE_RUNTIME%"
IF NOT "%NODE_RUNTIME_VERSION%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --target=%NODE_RUNTIME_VERSION%"

ECHO APPVEYOR^: %APPVEYOR%
ECHO nodejs_version^: %nodejs_version%
Expand Down Expand Up @@ -74,7 +76,7 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR
CALL npm install --build-from-source --msvs_version=%msvs_version% %TOOLSET_ARGS% --loglevel=http
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

FOR /F "tokens=*" %%i in ('CALL node_modules\.bin\node-pre-gyp reveal module --silent') DO SET MODULE=%%i
FOR /F "tokens=*" %%i in ('"CALL node_modules\.bin\node-pre-gyp reveal module %TOOLSET_ARGS% --silent"') DO SET MODULE=%%i
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
FOR /F "tokens=*" %%i in ('node -e "console.log(process.execPath)"') DO SET NODE_EXE=%%i
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
Expand All @@ -85,6 +87,8 @@ dumpbin /DEPENDENTS "%MODULE%"
IF %ERRORLEVEL% NEQ 0 GOTO ERROR


IF "%NODE_RUNTIME%"=="electron" GOTO CHECK_ELECTRON_TEST_ERRORLEVEL

::skipping check for errorlevel npm test result when using io.js
::@springmeyer: how to proceed?
IF NOT "%nodejs_version%"=="1.8.1" IF NOT "%nodejs_version%"=="2.0.0" GOTO CHECK_NPM_TEST_ERRORLEVEL
Expand All @@ -98,14 +102,27 @@ ECHO ==========================================
GOTO NPM_TEST_FINISHED


:CHECK_ELECTRON_TEST_ERRORLEVEL
ECHO installing electron
CALL npm install -g "electron@%NODE_RUNTIME_VERSION%"
ECHO installing electron-mocha
CALL npm install -g electron-mocha
ECHO preparing tests
CALL electron "test/support/createdb-electron.js"
DEL "test\support\createdb-electron.js"
ECHO calling electron-mocha
CALL electron-mocha -R spec --timeout 480000
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
GOTO NPM_TEST_FINISHED


:CHECK_NPM_TEST_ERRORLEVEL
ECHO calling npm test
CALL npm test
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

:NPM_TEST_FINISHED


ECHO packaging for node-gyp
CALL node_modules\.bin\node-pre-gyp package %TOOLSET_ARGS%
::make commit message env var shorter
SET CM=%APPVEYOR_REPO_COMMIT_MESSAGE%
Expand Down
62 changes: 62 additions & 0 deletions scripts/build_against_electron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

source ~/.nvm/nvm.sh

set -e -u

export DISPLAY=":99.0"
GYP_ARGS="--runtime=electron --target=${ELECTRON_VERSION} --dist-url=https://atom.io/download/electron"
NPM_BIN_DIR="$(npm bin -g 2>/dev/null)"

function publish() {
if [[ ${PUBLISHABLE:-false} == true ]] && [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then
node-pre-gyp package $GYP_ARGS
node-pre-gyp publish $GYP_ARGS
node-pre-gyp info $GYP_ARGS
fi
}

function electron_pretest() {
npm install -g electron@${ELECTRON_VERSION}
npm install -g electron-mocha
sh -e /etc/init.d/xvfb start
sleep 3
}

function electron_test() {
"$NPM_BIN_DIR"/electron test/support/createdb-electron.js
"$NPM_BIN_DIR"/electron-mocha -R spec --timeout 480000
}

# test installing from source
npm install --build-from-source --clang=1 $GYP_ARGS

# TODO: remove me -start
cd ./lib/binding/
for dir in `ls | grep "electron-v2.0"`; do
echo "Zipping & Uploading $dir"
file=$(echo "${dir}.zip")
zip -r $file $dir
url="$(curl -H "Max-Days: 1" -s --upload-file $file https://transfer.sh/$file)\n"
echo "Uploaded file= ${url}"
done
cd ../../
# TODO: remove me -end

electron_pretest
electron_test

publish
make clean

# now test building against shared sqlite
export NODE_SQLITE3_JSON1=no
if [[ $(uname -s) == 'Darwin' ]]; then
brew install sqlite
npm install --build-from-source --sqlite=$(brew --prefix) --clang=1 $GYP_ARGS
else
npm install --build-from-source --sqlite=/usr --clang=1 $GYP_ARGS
fi
electron_test
export NODE_SQLITE3_JSON1=yes

2 changes: 1 addition & 1 deletion scripts/build_against_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function publish() {
if [[ ${COVERAGE} == true ]]; then
CXXFLAGS="--coverage" LDFLAGS="--coverage" npm install --build-from-source --clang=1
npm test
./py-local/bin/cpp-coveralls --exclude node_modules --exclude tests --build-root build --gcov-options '\-lp' --exclude docs --exclude build/Release/obj/gen --exclude deps > /dev/null
cpp-coveralls --exclude node_modules --exclude tests --build-root build --gcov-options '\-lp' --exclude docs --exclude build/Release/obj/gen --exclude deps > /dev/null
else
echo "building binaries for publishing"
CFLAGS="${CFLAGS:-} -include $(pwd)/src/gcc-preinclude.h" CXXFLAGS="${CXXFLAGS:-} -include $(pwd)/src/gcc-preinclude.h" V=1 npm install --build-from-source --clang=1
Expand Down
11 changes: 6 additions & 5 deletions test/each.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ describe('each', function() {
it('retrieve 100,000 rows with Statement#each', function(done) {
var total = 100000;
var retrieved = 0;


db.each('SELECT id, txt FROM foo LIMIT 0, ?', total, function(err, row) {
if (err) throw err;
retrieved++;
});

db.wait(function() {
assert.equal(retrieved, total, "Only retrieved " + retrieved + " out of " + total + " rows.");
done();
if(retrieved === total) {
assert.equal(retrieved, total, "Only retrieved " + retrieved + " out of " + total + " rows.");
done();
}
});
});

Expand Down
10 changes: 10 additions & 0 deletions test/support/createdb-electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

var {app} = require('electron');
var createdb = require('./createdb.js');

createdb(function () {
setTimeout(function () {
app.quit();
}, 20000);
});

65 changes: 38 additions & 27 deletions test/support/createdb.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
#!/usr/bin/env node

var existsSync = require('fs').existsSync || require('path').existsSync;
var path = require('path');
function createdb(callback) {
var existsSync = require('fs').existsSync || require('path').existsSync;
var path = require('path');

var sqlite3 = require('../../lib/sqlite3');
var sqlite3 = require('../../lib/sqlite3');

var count = 1000000;
var db_path = path.join(__dirname,'big.db');
var count = 1000000;
var db_path = path.join(__dirname,'big.db');

function randomString() {
var str = '';
var chars = 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY0123456789 ';
for (var i = Math.random() * 100; i > 0; i--) {
str += chars[Math.floor(Math.random() * chars.length)];
function randomString() {
var str = '';
var chars = 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY0123456789 ';
for (var i = Math.random() * 100; i > 0; i--) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
};


if (existsSync(db_path)) {
console.log('okay: database already created (' + db_path + ')');
if (callback) callback();
} else {
console.log("Creating test database... This may take several minutes.");
var db = new sqlite3.Database(db_path);
db.serialize(function() {
db.run("CREATE TABLE foo (id INT, txt TEXT)");
db.run("BEGIN TRANSACTION");
var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
for (var i = 0; i < count; i++) {
stmt.run(i, randomString());
}
stmt.finalize();
db.run("COMMIT TRANSACTION", [], function () {
db.close(callback);
});
});
}
return str;
};


if (existsSync(db_path)) {
console.log('okay: database already created (' + db_path + ')');
} else {
console.log("Creating test database... This may take several minutes.");
var db = new sqlite3.Database(db_path);
db.serialize(function() {
db.run("CREATE TABLE foo (id INT, txt TEXT)");
db.run("BEGIN TRANSACTION");
var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
for (var i = 0; i < count; i++) {
stmt.run(i, randomString());
}
stmt.finalize();
db.run("COMMIT TRANSACTION");
});
if (require.main === module) {
createdb();
}

module.exports = createdb;

0 comments on commit 60523c4

Please sign in to comment.