-
Notifications
You must be signed in to change notification settings - Fork 116
ci: move CI to GitHub actions and get prebuilds working again #152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MadLittleMods this is ready for your review. I'm going to keep it listed as a draft while there are still TODO items to address:
- Is switching to GitHub Actions actually a path you would like to take with this repository?
- Should this PR bump minimum required Node version to
12
? - Should this PR enable auto-publishing to npm?
.github/workflows/ci.yml
Outdated
# - name: 'Publish to npm' | ||
# run: npm publish | ||
# env: | ||
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By uncommenting this and adding an NPM_TOKEN
secret to the repository, the CI would automatically publish tagged builds to npm if and only if all builds and prebuilds succeed
# - name: 'Publish to npm' | |
# run: npm publish | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: 'Publish to npm' | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should CI be configured to publish tags to npm?
- I think this is a good idea given the single multi-OS build pipeline
- I couldn't tell how usb-detection is currently published, so I'm guess the answer is "manually"
Added secret to the repo ✅ Seems good to me 👍
@MadLittleMods gentle ping on this one again. Is GitHub Actions a path you'd be willing to take on this repository? |
@@ -41,18 +42,18 @@ | |||
"node": ">=4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the
engines.node
field inpackage.json
be bumped from4
to12
?
- All Node.js versions prior to 12 are EOL'd
- At least one dependeny requires Node >= 6, so spec'ing >=4 is already inaccurate
- This would be a breaking change, but I think it's a good idea to ease potential maintenance burden
Sounds good to update this but we can do this in another PR 👍
@@ -0,0 +1,112 @@ | |||
name: 'ci' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is switching to GitHub Actions a good idea for this repository?
@mcous and I discussed this a bit at https://gitter.im/MadLittleMods/node-usb-detection?at=6165a80e29ddcd02931b22cc
Some pain points with GitHub actions but probably a good way forward for this project ⏩
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: 'Upload prebuilt artifacts to GitHub release' | ||
run: npm run prebuild-upload -- ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcous Thanks for this great migration and moving this project in the new up-to-date and more sane direction instead of fiddling with the old stuff! ♥
Sorry for the delay to get some eyes on this 🙇
- name: 'Publish to npm' | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also to note the sanity check, I see it running on your fork ✅
- https://github.com/mcous/node-usb-detection/actions/runs/1338151169
- https://github.com/mcous/node-usb-detection/actions/runs/1275586665
(also linked in issue description)
Woot woot! https://github.com/MadLittleMods/node-usb-detection/releases/tag/v4.13.0 with a multitude of prebuilds and available on npm https://www.npmjs.com/package/usb-detection/v/4.13.0 🚀 Thanks again @mcous 🥰 |
Overview
(Diff ignoring lockfile:
141 insertions(+), 203 deletions(-)
)As noted in #134, #140, #151, the existing CI setup has started to have issues, resulting in prebuilds not being correctly published to GitHub Releases.
From what I can tell, the problem may be that CI setup is configured somewhat redundantly. The prebuild utility is able to generate prebuilds for all available ABI versions while running on a single version of Node. However, CI is configured to run a matrix of different Node.js versions, too many of which are configured to run
prebuild --all
. Prebuilds only need to be generated once per OS/arch combination, and the compilation works most smoothly on later versions of Node.Additionally, there's a few other snags and updates since these problems started appearing:
v12
Rather than try to work around Travis'
.org
shutdown and figure out the.com
migration, I decided to see what this CI would look like on GitHub Actions. Over at Opentrons/opentrons, where we useusb-detection
, we switched from a Travis/AppVeyor combo to GH Actions, and it's gone pretty well. If the switch to GH Actions isn't too presumptuous, I think this is a good change!Relevant outputs from my fork running this CI:
Heavy caveat: I don't write native Node.js modules. This is not my area of expertise, though I'm pretty handy with a CI config. I haven't actually tested any these prebuilds; the only thing I know about these builds right now is that they are compiling without errors.
Open questions / TODO
engines.node
field inpackage.json
be bumped from4
to12
?Change log
npm
to v7, resulting in some serious lockfile churn; sorry about this diff'MACOSX_DEPLOYMENT_TARGET': '10.9'
in node-gyp confignode-gyp
now only supports Python 3 and Python 2 has been EOL'dnode-gyp
documentationHow does this CI pipeline work?
The CI pipeline starts by kicking off several jobs in parallel:
npm ci --build-from-source
on all the OS's and architectures we wantprebuild --all
and upload prebuilds to GH Actions artifact storageIf all those jobs complete and the CI run was triggered by a tag, then a publish job will run, which will: