Skip to content

add CI and fix current build issue#104

Merged
gengjiawen merged 9 commits intonodejs:masterfrom
gengjiawen:ci
Aug 24, 2019
Merged

add CI and fix current build issue#104
gengjiawen merged 9 commits intonodejs:masterfrom
gengjiawen:ci

Conversation

@gengjiawen
Copy link
Copy Markdown
Member

@gengjiawen gengjiawen commented Aug 6, 2019

Update:
https://travis-ci.org/gengjiawen/node-addon-examples

Now all test pass Node.js 8, 10.

@gengjiawen gengjiawen marked this pull request as ready for review August 6, 2019 13:33
@gengjiawen gengjiawen requested a review from mhdawson August 6, 2019 13:34
@gengjiawen
Copy link
Copy Markdown
Member Author

@targos Can you enable travis for this repo too ? Thanks.

@gengjiawen gengjiawen changed the title add CI add CI and fix current build issue Aug 6, 2019
@gengjiawen
Copy link
Copy Markdown
Member Author

on node-addon-examples/async_work_thread_safe_function/node-api looks like the api is introduced by on v10.6.0

https://nodejs.org/dist/latest-v12.x/docs/api/n-api.html#n_api_napi_threadsafe_function

Copy link
Copy Markdown
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely have a CI on this repo, but ideally the trigger would be changes to Node.js, not changes to this repo.

@gengjiawen
Copy link
Copy Markdown
Member Author

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 ?

@gabrielschulhof
Copy link
Copy Markdown
Contributor

@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.

@gengjiawen
Copy link
Copy Markdown
Member Author

gengjiawen commented Aug 10, 2019

@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.

@gengjiawen gengjiawen requested a review from NickNaso August 10, 2019 10:26
Copy link
Copy Markdown
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM I left two comments.

Comment thread .gitignore
Comment thread 6_object_wrap/nan/package.json
Comment thread async_work_thread_safe_function/node-api/package.json
"dependencies": {
"bindings": "~1.2.1"
},
"engines": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like no macro NAPI_MODULE_INIT on 8.x https://github.com/nodejs/node/blob/v8.x/src/node_api.h

Copy link
Copy Markdown
Member Author

@gengjiawen gengjiawen Aug 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor Module Initialization to NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) works on 8.x.

Should we do it ? cc @gabrielschulhof

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAPI_MODULE now works on all platform, #ifdef may not be necessary.

NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)

Copy link
Copy Markdown
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a comment

Copy link
Copy Markdown
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gengjiawen
Copy link
Copy Markdown
Member Author

LGTM

Do you have permission to enable travis for this repo ? We need to enable it before this got merged.

@mhdawson
Copy link
Copy Markdown
Member

@gengjiawen I've never done that before. What needs to be done?

@gengjiawen
Copy link
Copy Markdown
Member Author

@gengjiawen I've never done that before. What needs to be done?

Need someone with admin to nodejs to enable it in travis-ci.

@mhdawson
Copy link
Copy Markdown
Member

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.

@gengjiawen
Copy link
Copy Markdown
Member Author

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 Node.js, you should find the repo and enable it.

@mhdawson
Copy link
Copy Markdown
Member

@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.

@mhdawson
Copy link
Copy Markdown
Member

Found the config within the Node.js org, have enabled it for this repo now.

@gengjiawen
Copy link
Copy Markdown
Member Author

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) ?

@mhdawson
Copy link
Copy Markdown
Member

@gengjiawen

Can we merge this and open an issue for #104 (comment) ?

Sounds good to me.

@gengjiawen gengjiawen mentioned this pull request Aug 24, 2019
@gengjiawen
Copy link
Copy Markdown
Member Author

@gengjiawen

Can we merge this and open an issue for #104 (comment) ?

Sounds good to me.

#108

@gengjiawen gengjiawen merged commit 0f3ea58 into nodejs:master Aug 24, 2019
@gengjiawen gengjiawen deleted the ci branch August 24, 2019 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants