Skip to content

Commit 1bf765e

Browse files
committed
Merge pull request nodegit#287 from nodegit/better-install-process
[WIP] Better installation flow
2 parents fd14c4e + c4aa958 commit 1bf765e

File tree

11 files changed

+87
-56
lines changed

11 files changed

+87
-56
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
/vendor/libssh2/
44
/vendor/http_parser/
55
/build/
6-
/coverage/
6+
/test/coverage/
77
/test/repos/
8+
/test/test/repos/
89
/src/
910
/include/
1011
/lib/enums.js

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ before_install:
1414
export CXX='g++-4.8';
1515
fi
1616
- "export JOBS=4"
17-
- npm install
17+
- BUILD_ONLY=true npm install
1818
# This is a random private key used purely for testing.
1919
before_script:
2020
- echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
@@ -31,7 +31,7 @@ branches:
3131
os:
3232
- linux
3333
- osx
34-
script: npm --expose-gc test
34+
script: npm test
3535
notifications:
3636
slack:
3737
secure: KglNSqZiid9YudCwkPFDh+sZfW5BwFlM70y67E4peHwwlbbV1sSBPHcs74ZHP/lqgEZ4hMv4N2NI58oYFD5/1a+tKIQP1TkdIMuq4j2LXheuirA2HDcydOVrsC8kRx5XFGKdVRg/uyX2dlRHcOWFhxrS6yc6IxtxYWlRTD2SmEc=

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ install:
2727
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
2828
- cmd: SET PATH=c:\python27;%PATH%
2929
- cmd: SET JOBS=4
30+
- cmd: SET BUILD_ONLY=true
3031
- cmd: SET GIT_SSH=c:\projects\nodegit\vendor\plink.exe
3132
- ps: Start-Process c:\projects\nodegit\vendor\pageant.exe c:\projects\nodegit\vendor\private.ppk
3233
- cmd: npm install -g node-gyp

generate/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
100100
}
101101
}
102102
catch (e) {
103-
console.log(e);
103+
if (process.env.BUILD_ONLY) {
104+
console.log(e);
105+
}
104106
}
105107
});
106108

generate/setup.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ libgit2.types.forEach(function(current) {
5858
var previous = "";
5959
enums = _(enums).sortBy("name").reduce(function(enumMemo, enumerable) {
6060
if (previous == enumerable.typeName) {
61-
console.log('WARNING: duplicate definition for enum ' + enumerable.typeName +
62-
". skipped.");
61+
if (process.env.BUILD_ONLY) {
62+
console.warn('Duplicate definition for enum ' + enumerable.typeName +
63+
". skipped.");
64+
}
6365
}
6466
else if (!enumerable.fields) {
65-
console.log('WARNING: incomplete definition for enum ' + enumerable.typeName +
66-
". skipped.");
67+
if (process.env.BUILD_ONLY) {
68+
console.warn('Incomplete definition for enum ' + enumerable.typeName +
69+
". skipped.");
70+
}
6771
}
6872
else {
6973
enumMemo[enumerable.typeName] = {

generate/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ var Utils = {
136136
_.merge(field, callbackDefs[field.type]);
137137
}
138138
else {
139-
console.log("WARNING: Couldn't find callback definition for " + field.type);
139+
if (process.env.BUILD_ONLY) {
140+
console.warn("Couldn't find callback definition for " + field.type);
141+
}
140142
}
141143
},
142144

install.js

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ var which = require("which");
1010
var rimraf = require("rimraf");
1111
var NODE_VERSION = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
1212

13+
// If the build only flag is set.
14+
var buildOnly = process.env.BUILD_ONLY;
15+
1316
// This will take in an object and find any matching keys in the environment
1417
// to use as overrides.
1518
//
@@ -63,13 +66,34 @@ if (NODE_VERSION === 0.1) {
6366
pkg.http_parser = pkg.http_parser["0.10"];
6467
}
6568

66-
// Ensure all dependencies are available.
67-
var dependencies = Q.allSettled([
68-
// This will prioritize `python2` over `python`, because we always want to
69-
// work with Python 2.* if it"s available.
70-
Q.nfcall(which, "python2"),
71-
Q.nfcall(which, "python")
72-
])
69+
// Attempt to fallback on a prebuilt binary.
70+
function fetchPrebuilt() {
71+
if (!buildOnly) {
72+
console.info("[nodegit] Fetching binary from S3.");
73+
74+
// Using the node-pre-gyp module, attempt to fetch a compatible build.
75+
return Q.nfcall(exec, "node-pre-gyp install");
76+
}
77+
78+
throw new Error("Build only");
79+
}
80+
81+
// Attempt to fetch prebuilt binary.
82+
Q.ninvoke(fs, "mkdir", paths.release).then(fetchPrebuilt, fetchPrebuilt)
83+
84+
.fail(function() {
85+
if (!buildOnly) {
86+
console.info("[nodegit] Failed to install prebuilt, attempting compile.");
87+
}
88+
89+
// Ensure all dependencies are available.
90+
return Q.allSettled([
91+
// This will prioritize `python2` over `python`, because we always want to
92+
// work with Python 2.* if it"s available.
93+
Q.nfcall(which, "python2"),
94+
Q.nfcall(which, "python")
95+
])
96+
})
7397

7498
// Determine if all the dependency requirements are met.
7599
.then(function(results) {
@@ -218,25 +242,6 @@ var dependencies = Q.allSettled([
218242
});
219243
})
220244

221-
// Attempt to fallback on a prebuilt binary.
222-
.fail(function(message) {
223-
console.info("[nodegit] Failed to build nodegit.");
224-
console.info("[nodegit] Attempting to fallback on a prebuilt binary.");
225-
226-
console.log(message.stack);
227-
228-
function fetchPrebuilt() {
229-
console.info("[nodegit] Fetching binary from S3.");
230-
231-
// Using the node-pre-gyp module, attempt to fetch a compatible build.
232-
return Q.nfcall(exec, "node-pre-gyp install");
233-
}
234-
235-
// Attempt to fetch prebuilt binary.
236-
return Q.ninvoke(fs, "mkdir", paths.release)
237-
.then(fetchPrebuilt, fetchPrebuilt);
238-
})
239-
240245
// Display a warning message about failing to build native node module.
241246
.fail(function(message) {
242247
console.info("[nodegit] Failed to build and install nodegit.");

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@
8989
},
9090
"scripts": {
9191
"lint": "jshint lib test/tests",
92-
"cov": "istanbul cover node_modules/mocha/bin/_mocha -- test/runner test/tests --report=lcov",
92+
"cov": "node test",
9393
"mocha": "mocha test/runner test/tests",
9494
"test": "npm run lint && npm run cov",
9595
"missing-tests": "node generate/missing-tests",
9696
"publish": "node-pre-gyp package && node-pre-gyp publish",
9797
"generate": "node generate/setup && node generate",
9898
"install": "npm run generate && node install",
99-
"rebuild": "npm run generate && node-gyp configure build"
99+
"rebuild": "BUILD_ONLY=true npm run generate && node-gyp configure build"
100100
}
101101
}

test/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var args = [
2+
"cover",
3+
process.platform != "win32" ? "_mocha" : "../node_modules/mocha/bin/_mocha",
4+
"--",
5+
"runner",
6+
"tests",
7+
"--report=lcov",
8+
"--expose-gc"
9+
];
10+
11+
require("child_process").fork("../node_modules/istanbul/lib/cli.js", args, {
12+
cwd: __dirname
13+
});

test/runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var exec = promisify(function(command, opts, callback) {
77
});
88

99
before(function(done) {
10-
this.timeout(150000);
10+
this.timeout(350000);
1111

1212
var url = "https://github.com/nodegit/test";
1313
var done = done.bind(null, null);

0 commit comments

Comments
 (0)