add CI and fix current build issue#104
Conversation
|
@targos Can you enable travis for this repo too ? Thanks. |
|
on https://nodejs.org/dist/latest-v12.x/docs/api/n-api.html#n_api_napi_threadsafe_function |
gabrielschulhof
left a comment
There was a problem hiding this comment.
We should definitely have a CI on this repo, but ideally the trigger would be changes to Node.js, not changes to this repo.
Do you mean test against Node.js nightly ? |
|
@gengjiawen against nightly would be great, but also against the latest LTS versions when they are released. I'm not sure if we can trigger Travis like that though. |
Maybe related to nodejs/Release#422. But I think current solution will works and prevent regression. |
| "dependencies": { | ||
| "bindings": "~1.2.1" | ||
| }, | ||
| "engines": { |
There was a problem hiding this comment.
Same comment as before, the real dependency is N-API version 4 which is supported by some version of 8.X as well. In any case this is still a good step.
There was a problem hiding this comment.
@mhdawson you're right and my recent experience push me to say that the most useful value to check if a feature is supported or not is the N-API version.
The problem is that it's not possible to check if a Node.js version is greater than XXX because for example the 8.16.0 has napi_thread_safe_function instead the 10.0.0 not.
There was a problem hiding this comment.
I was wondering if we could specify multiple ranges maybe
">= 8.16.0 < 9.0.0 || >=10.6.0"
but not sure if that is allowed by the syntax.
There was a problem hiding this comment.
Yes it's possible to specify multiple ranges. What is specified on the engines field has effect only if the engine-strict config flag is set.
npm --engine-strict install
There was a problem hiding this comment.
The example failed on macOs Node.js 8.16.0, can you run it in other OS ?
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/binding/binding.o
../binding.c:185:16: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
/*napi_value*/ NAPI_MODULE_INIT(/*napi_env env, napi_value exports*/) {
^
../binding.c:204:33: error: use of undeclared identifier 'env'
assert(napi_define_properties(env, exports, 1, &start_work) == napi_ok);
^
../binding.c:204:38: error: use of undeclared identifier 'exports'
assert(napi_define_properties(env, exports, 1, &start_work) == napi_ok);
^
../binding.c:208:20: error: use of undeclared identifier 'env'
assert(napi_wrap(env,
^
../binding.c:209:20: error: use of undeclared identifier 'exports'
exports,
^
../binding.c:216:10: error: use of undeclared identifier 'exports'
return exports;
^
1 warning and 5 errors generated.
There was a problem hiding this comment.
Looks like no macro NAPI_MODULE_INIT on 8.x https://github.com/nodejs/node/blob/v8.x/src/node_api.h
There was a problem hiding this comment.
Refactor Module Initialization to NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) works on 8.x.
Should we do it ? cc @gabrielschulhof
There was a problem hiding this comment.
NAPI_MODULE_INIT being missing on v8.x may be an oversight as we expect same code to work across all the LTS versions subject to the NAPI_VERSION supported. Having said that,. not sure we'll be able to get that into the last v8.x release. Also need @gabrielschulhof to comment on whether than even makes sense. For now if we can refactor, maybe with an #ifdef so the example still shows the way we would want people to do it post 8.x ?
There was a problem hiding this comment.
NAPI_MODULE now works on all platform, #ifdef may not be necessary.
Do you have permission to enable travis for this repo ? We need to enable it before this got merged. |
|
@gengjiawen I've never done that before. What needs to be done? |
Need someone with admin to |
|
I have the admin rights I just don't know where in the github ui to enable. I'm sure I can figure it out but if you already know and can tell me that will save me some time. |
https://travis-ci.org/account/repositories, on left side menu, there should be ORGANIZATIONS, in there click |
|
@gengjiawen sorry that I don't have enough context/background but I'm confused. We already use travis for some builds (for example: https://github.com/nodejs/node/pull/29263/checks?check_run_id=200242495) so I was not expecting we needed to enable anything on the travis side, instead some configuration on the node-addon-examples repo instead. |
|
Found the config within the Node.js org, have enabled it for this repo now. |
Can we merge this and open an issue for #104 (comment) ? |
Sounds good to me. |
|
Update:
https://travis-ci.org/gengjiawen/node-addon-examples
Now all test pass Node.js 8, 10.