Skip to content

Commit 60523c4

Browse files
authored
Merge pull request TryGhost#976 from kewde/electron-ci-builds
add electron builds to ci (continued)
2 parents 57f97d2 + 599c7f8 commit 60523c4

8 files changed

Lines changed: 245 additions & 38 deletions

File tree

.travis.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ matrix:
6060
apt:
6161
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
6262
packages: [ 'clang-3.5']
63+
- os: linux
64+
compiler: clang
65+
env: NODE_VERSION="5" COVERAGE=true PUBLISHABLE=false
66+
addons:
67+
apt:
68+
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
69+
packages: [ 'clang-3.5']
6370
- os: linux
6471
compiler: clang
6572
env: NODE_VERSION="4"
@@ -100,6 +107,43 @@ matrix:
100107
- os: osx
101108
compiler: clang
102109
env: NODE_VERSION="4" # node abi 46
110+
# electron Linux
111+
- os: linux
112+
compiler: clang
113+
env: NODE_VERSION="6" ELECTRON_VERSION="2.0.1"
114+
dist: trusty # needed for libc6 / 'version `GLIBC_2.17` not found' error on precise
115+
addons:
116+
apt:
117+
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
118+
packages: [ 'clang-3.5', 'libc6']
119+
- os: linux
120+
compiler: clang
121+
env: NODE_VERSION="6" ELECTRON_VERSION="1.8.4"
122+
addons:
123+
apt:
124+
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
125+
packages: [ 'clang-3.5']
126+
- os: linux
127+
compiler: clang
128+
env: NODE_VERSION="6" ELECTRON_VERSION="1.7.12"
129+
addons:
130+
apt:
131+
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
132+
packages: [ 'clang-3.5']
133+
- os: linux
134+
compiler: clang
135+
env: NODE_VERSION="6" ELECTRON_VERSION="1.6.2"
136+
addons:
137+
apt:
138+
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
139+
packages: [ 'clang-3.5']
140+
- os: linux
141+
compiler: clang
142+
env: NODE_VERSION="6" ELECTRON_VERSION="1.3.14"
143+
addons:
144+
apt:
145+
sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
146+
packages: [ 'clang-3.5']
103147

104148
env:
105149
global:
@@ -127,14 +171,21 @@ before_script:
127171
- export COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
128172
- if [[ ${COVERAGE} == true ]]; then
129173
if [[ $(uname -s) == 'Linux' ]]; then
130-
PYTHONUSERBASE=$(pwd)/py-local pip install --user cpp-coveralls;
174+
curl https://bootstrap.pypa.io/get-pip.py | python - --user;
175+
pip install --user cpp-coveralls;
131176
else
132177
PYTHONUSERBASE=$(pwd)/py-local easy_install --user cpp-coveralls;
133178
fi;
134179
fi
135180

136181
script:
137-
- if [[ "${NODE_VERSION}" ]]; then ./scripts/build_against_node.sh; fi;
182+
- if [[ "${NODE_VERSION}" ]]; then
183+
if [[ "${ELECTRON_VERSION}" ]]; then
184+
./scripts/build_against_electron.sh;
185+
else
186+
./scripts/build_against_node.sh;
187+
fi;
188+
fi
138189
- if [[ "${NODE_VERSION}" -eq "4" ]]; then ./node_modules/.bin/eslint lib; fi;
139190
# disabled for now: need to port to sudo:false
140191
#- if [[ "${NODE_WEBKIT}" ]]; then ./scripts/build_against_node_webkit.sh; fi;

appveyor.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,61 @@ environment:
3030
platform: x64
3131
- nodejs_version: 10
3232
platform: x86
33+
# electron
34+
- nodejs_version: 8
35+
platform: x64
36+
NODE_RUNTIME: electron
37+
NODE_RUNTIME_VERSION: 2.0.1
38+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
39+
- nodejs_version: 8
40+
platform: x86
41+
NODE_RUNTIME: electron
42+
NODE_RUNTIME_VERSION: 2.0.1
43+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
44+
- nodejs_version: 8
45+
platform: x64
46+
NODE_RUNTIME: electron
47+
NODE_RUNTIME_VERSION: 1.8.4
48+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
49+
- nodejs_version: 8
50+
platform: x86
51+
NODE_RUNTIME: electron
52+
NODE_RUNTIME_VERSION: 1.8.4
53+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
54+
- nodejs_version: 7
55+
platform: x64
56+
NODE_RUNTIME: electron
57+
NODE_RUNTIME_VERSION: 1.7.12
58+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
59+
- nodejs_version: 7
60+
platform: x86
61+
NODE_RUNTIME: electron
62+
NODE_RUNTIME_VERSION: 1.7.12
63+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
64+
- nodejs_version: 6
65+
platform: x64
66+
msvs_toolset: 12
67+
NODE_RUNTIME: electron
68+
NODE_RUNTIME_VERSION: 1.6.2
69+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
70+
- nodejs_version: 6
71+
platform: x86
72+
msvs_toolset: 12
73+
NODE_RUNTIME: electron
74+
NODE_RUNTIME_VERSION: 1.6.2
75+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
76+
- nodejs_version: 6
77+
platform: x64
78+
msvs_toolset: 12
79+
NODE_RUNTIME: electron
80+
NODE_RUNTIME_VERSION: 1.3.14
81+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
82+
- nodejs_version: 6
83+
platform: x86
84+
msvs_toolset: 12
85+
NODE_RUNTIME: electron
86+
NODE_RUNTIME_VERSION: 1.3.14
87+
TOOLSET_ARGS: --dist-url=https://atom.io/download/electron
3388

3489
os: Visual Studio 2015
3590

scripts/build-appveyor.bat

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ IF /I "%msvs_version%"=="" ECHO msvs_version unset, defaulting to 2015 && SET ms
99

1010
SET PATH=%CD%;%PATH%
1111
IF "%msvs_toolset%"=="12" SET msvs_version=2013
12+
IF NOT "%NODE_RUNTIME%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --runtime=%NODE_RUNTIME%"
13+
IF NOT "%NODE_RUNTIME_VERSION%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --target=%NODE_RUNTIME_VERSION%"
1214

1315
ECHO APPVEYOR^: %APPVEYOR%
1416
ECHO nodejs_version^: %nodejs_version%
@@ -74,7 +76,7 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR
7476
CALL npm install --build-from-source --msvs_version=%msvs_version% %TOOLSET_ARGS% --loglevel=http
7577
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
7678

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

8789

90+
IF "%NODE_RUNTIME%"=="electron" GOTO CHECK_ELECTRON_TEST_ERRORLEVEL
91+
8892
::skipping check for errorlevel npm test result when using io.js
8993
::@springmeyer: how to proceed?
9094
IF NOT "%nodejs_version%"=="1.8.1" IF NOT "%nodejs_version%"=="2.0.0" GOTO CHECK_NPM_TEST_ERRORLEVEL
@@ -98,14 +102,27 @@ ECHO ==========================================
98102
GOTO NPM_TEST_FINISHED
99103

100104

105+
:CHECK_ELECTRON_TEST_ERRORLEVEL
106+
ECHO installing electron
107+
CALL npm install -g "electron@%NODE_RUNTIME_VERSION%"
108+
ECHO installing electron-mocha
109+
CALL npm install -g electron-mocha
110+
ECHO preparing tests
111+
CALL electron "test/support/createdb-electron.js"
112+
DEL "test\support\createdb-electron.js"
113+
ECHO calling electron-mocha
114+
CALL electron-mocha -R spec --timeout 480000
115+
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
116+
GOTO NPM_TEST_FINISHED
117+
118+
101119
:CHECK_NPM_TEST_ERRORLEVEL
102120
ECHO calling npm test
103121
CALL npm test
104122
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
105123

106124
:NPM_TEST_FINISHED
107-
108-
125+
ECHO packaging for node-gyp
109126
CALL node_modules\.bin\node-pre-gyp package %TOOLSET_ARGS%
110127
::make commit message env var shorter
111128
SET CM=%APPVEYOR_REPO_COMMIT_MESSAGE%

scripts/build_against_electron.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
source ~/.nvm/nvm.sh
4+
5+
set -e -u
6+
7+
export DISPLAY=":99.0"
8+
GYP_ARGS="--runtime=electron --target=${ELECTRON_VERSION} --dist-url=https://atom.io/download/electron"
9+
NPM_BIN_DIR="$(npm bin -g 2>/dev/null)"
10+
11+
function publish() {
12+
if [[ ${PUBLISHABLE:-false} == true ]] && [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then
13+
node-pre-gyp package $GYP_ARGS
14+
node-pre-gyp publish $GYP_ARGS
15+
node-pre-gyp info $GYP_ARGS
16+
fi
17+
}
18+
19+
function electron_pretest() {
20+
npm install -g electron@${ELECTRON_VERSION}
21+
npm install -g electron-mocha
22+
sh -e /etc/init.d/xvfb start
23+
sleep 3
24+
}
25+
26+
function electron_test() {
27+
"$NPM_BIN_DIR"/electron test/support/createdb-electron.js
28+
"$NPM_BIN_DIR"/electron-mocha -R spec --timeout 480000
29+
}
30+
31+
# test installing from source
32+
npm install --build-from-source --clang=1 $GYP_ARGS
33+
34+
# TODO: remove me -start
35+
cd ./lib/binding/
36+
for dir in `ls | grep "electron-v2.0"`; do
37+
echo "Zipping & Uploading $dir"
38+
file=$(echo "${dir}.zip")
39+
zip -r $file $dir
40+
url="$(curl -H "Max-Days: 1" -s --upload-file $file https://transfer.sh/$file)\n"
41+
echo "Uploaded file= ${url}"
42+
done
43+
cd ../../
44+
# TODO: remove me -end
45+
46+
electron_pretest
47+
electron_test
48+
49+
publish
50+
make clean
51+
52+
# now test building against shared sqlite
53+
export NODE_SQLITE3_JSON1=no
54+
if [[ $(uname -s) == 'Darwin' ]]; then
55+
brew install sqlite
56+
npm install --build-from-source --sqlite=$(brew --prefix) --clang=1 $GYP_ARGS
57+
else
58+
npm install --build-from-source --sqlite=/usr --clang=1 $GYP_ARGS
59+
fi
60+
electron_test
61+
export NODE_SQLITE3_JSON1=yes
62+

scripts/build_against_node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function publish() {
1717
if [[ ${COVERAGE} == true ]]; then
1818
CXXFLAGS="--coverage" LDFLAGS="--coverage" npm install --build-from-source --clang=1
1919
npm test
20-
./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
20+
cpp-coveralls --exclude node_modules --exclude tests --build-root build --gcov-options '\-lp' --exclude docs --exclude build/Release/obj/gen --exclude deps > /dev/null
2121
else
2222
echo "building binaries for publishing"
2323
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

test/each.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ describe('each', function() {
1010
it('retrieve 100,000 rows with Statement#each', function(done) {
1111
var total = 100000;
1212
var retrieved = 0;
13+
1314

1415
db.each('SELECT id, txt FROM foo LIMIT 0, ?', total, function(err, row) {
1516
if (err) throw err;
1617
retrieved++;
17-
});
18-
19-
db.wait(function() {
20-
assert.equal(retrieved, total, "Only retrieved " + retrieved + " out of " + total + " rows.");
21-
done();
18+
19+
if(retrieved === total) {
20+
assert.equal(retrieved, total, "Only retrieved " + retrieved + " out of " + total + " rows.");
21+
done();
22+
}
2223
});
2324
});
2425

test/support/createdb-electron.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
var {app} = require('electron');
3+
var createdb = require('./createdb.js');
4+
5+
createdb(function () {
6+
setTimeout(function () {
7+
app.quit();
8+
}, 20000);
9+
});
10+

test/support/createdb.js

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11
#!/usr/bin/env node
22

3-
var existsSync = require('fs').existsSync || require('path').existsSync;
4-
var path = require('path');
3+
function createdb(callback) {
4+
var existsSync = require('fs').existsSync || require('path').existsSync;
5+
var path = require('path');
56

6-
var sqlite3 = require('../../lib/sqlite3');
7+
var sqlite3 = require('../../lib/sqlite3');
78

8-
var count = 1000000;
9-
var db_path = path.join(__dirname,'big.db');
9+
var count = 1000000;
10+
var db_path = path.join(__dirname,'big.db');
1011

11-
function randomString() {
12-
var str = '';
13-
var chars = 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY0123456789 ';
14-
for (var i = Math.random() * 100; i > 0; i--) {
15-
str += chars[Math.floor(Math.random() * chars.length)];
12+
function randomString() {
13+
var str = '';
14+
var chars = 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXZY0123456789 ';
15+
for (var i = Math.random() * 100; i > 0; i--) {
16+
str += chars[Math.floor(Math.random() * chars.length)];
17+
}
18+
return str;
19+
};
20+
21+
22+
if (existsSync(db_path)) {
23+
console.log('okay: database already created (' + db_path + ')');
24+
if (callback) callback();
25+
} else {
26+
console.log("Creating test database... This may take several minutes.");
27+
var db = new sqlite3.Database(db_path);
28+
db.serialize(function() {
29+
db.run("CREATE TABLE foo (id INT, txt TEXT)");
30+
db.run("BEGIN TRANSACTION");
31+
var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
32+
for (var i = 0; i < count; i++) {
33+
stmt.run(i, randomString());
34+
}
35+
stmt.finalize();
36+
db.run("COMMIT TRANSACTION", [], function () {
37+
db.close(callback);
38+
});
39+
});
1640
}
17-
return str;
1841
};
1942

20-
21-
if (existsSync(db_path)) {
22-
console.log('okay: database already created (' + db_path + ')');
23-
} else {
24-
console.log("Creating test database... This may take several minutes.");
25-
var db = new sqlite3.Database(db_path);
26-
db.serialize(function() {
27-
db.run("CREATE TABLE foo (id INT, txt TEXT)");
28-
db.run("BEGIN TRANSACTION");
29-
var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
30-
for (var i = 0; i < count; i++) {
31-
stmt.run(i, randomString());
32-
}
33-
stmt.finalize();
34-
db.run("COMMIT TRANSACTION");
35-
});
43+
if (require.main === module) {
44+
createdb();
3645
}
46+
47+
module.exports = createdb;

0 commit comments

Comments
 (0)