Skip to content

Commit

Permalink
Prebuild and publish binaries (#63)
Browse files Browse the repository at this point in the history
* ci: add recent Node.js versions to CI

* Update to NYC 15 to fix Node 10/12 windows CI failures

* Drop testing for node 6

* Set up prebuild releases

* Start testing with OSX in CI

* Move from prebuild to prebuildify

Preferably because it:
- Simplifies and (probably) speeds up user installs
- Doesn't require reinstalls when switching targets
- Drops the install-time dependency on GitHub
- Includes the built binaries in the npm package checksum

* Bundle prebuilds into the npm package

* Drop unnecessary bindings dev dependency
  • Loading branch information
pimterry committed Apr 22, 2020
1 parent 12c8c13 commit d2ae190
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -24,3 +24,5 @@ deps/libffi/include/ffi.h
deps/libffi/include/ffitarget.h
deps/libffi/local.exp
vgcore.*

prebuilds/
24 changes: 24 additions & 0 deletions .npmignore
@@ -0,0 +1,24 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz

pids
logs
results

.nyc_output/
coverage
build
node-addon-api

core
deps/libffi/fficonfig.h
deps/libffi/include/ffi.h
deps/libffi/include/ffitarget.h
deps/libffi/local.exp
vgcore.*
39 changes: 37 additions & 2 deletions .travis.yml
Expand Up @@ -2,6 +2,8 @@ sudo: false

env:
- CXX=g++-4.9
- CXX=clang++

addons:
apt:
sources:
Expand All @@ -11,12 +13,45 @@ addons:

language: node_js

os:
- linux
- osx

osx_image: xcode10

node_js:
- "4"
- "6"
- "8"
- "9"
- "10"
- "12"

jobs:
exclude:
- os: osx
env: CXX=g++-4.9
- os: linux
env: CXX=clang++

install:
- npm install --build-from-source

after_success:
- npm install coveralls
- nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls

before_deploy:
- ARCHIVE_NAME="${TRAVIS_TAG:-latest}-$TRAVIS_OS_NAME-`uname -m`.tar"
- npm run prebuild
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ARCH=ia32 npm run prebuild; fi
- tar --create --verbose --file="$ARCHIVE_NAME" --directory "$TRAVIS_BUILD_DIR/prebuilds" .

deploy:
provider: releases
draft: false
prerelease: true
file: "$ARCHIVE_NAME"
skip_cleanup: true
on:
tags: true
node: 12
api_key: $PREBUILD_GITHUB_TOKEN
23 changes: 21 additions & 2 deletions appveyor.yml
Expand Up @@ -5,9 +5,10 @@ environment:
# Test against these versions of Node.js and io.js
matrix:
# node.js
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"
- nodejs_version: "12"

platform:
- x86
Expand All @@ -20,7 +21,7 @@ install:
- ps: Install-Product node $env:nodejs_version $env:platform
- node -p process.arch
- node -p process.version
- npm install
- npm install --build-from-source

# Post-install test scripts.
test_script:
Expand All @@ -30,8 +31,26 @@ test_script:
# run tests
- npm test

after_test:
- ps: If ($env:nodejs_version -eq "12") { npm run prebuild }

# Don't actually build.
build: off

# Set build version format here instead of in the admin panel.
version: "{build}"

artifacts:
- path: prebuilds
name: $(APPVEYOR_REPO_TAG_NAME)-win-$(PLATFORM)
type: zip

deploy:
- provider: GitHub
artifact: /.*\.zip/
draft: false
prerelease: true
auth_token: $(PREBUILD_GITHUB_TOKEN)
on:
appveyor_repo_tag: true
nodejs_version: "12"
3 changes: 2 additions & 1 deletion lib/bindings.js
@@ -1,2 +1,3 @@
'use strict';
module.exports = require('bindings')('ffi_bindings.node');
var path = require('path');
module.exports = require('node-gyp-build')(path.join(__dirname, '..'));
9 changes: 7 additions & 2 deletions package.json
Expand Up @@ -26,20 +26,25 @@
},
"main": "./lib/ffi",
"dependencies": {
"bindings": "^1.3.0",
"debug": "^3.1.0",
"get-uv-event-loop-napi-h": "^1.0.5",
"node-addon-api": "1.6.1",
"node-gyp-build": "^4.2.1",
"ref-napi": "^1.4.0",
"ref-struct-di": "^1.1.0"
},
"devDependencies": {
"fs-extra": "^5.0.0",
"mocha": "^5.0.0",
"nyc": "^12.0.1",
"nyc": "^15.0.0",
"prebuildify": "^3.0.4",
"prebuildify-ci": "^1.0.5",
"ref-array-di": "^1.2.1"
},
"scripts": {
"install": "node-gyp-build",
"prebuild": "prebuildify --napi",
"prepack": "prebuildify-ci download && ([ $(ls prebuilds | wc -l) = '4' ] || (echo 'Some prebuilds are missing'; exit 1))",
"test": "node-gyp rebuild --directory test && nyc mocha -gc --reporter spec"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion test/callback.js
Expand Up @@ -3,7 +3,7 @@ const assert = require('assert');
const ref = require('ref-napi');
const ffi = require('../');
const int = ref.types.int;
const bindings = require('bindings')({ module_root: __dirname, bindings: 'ffi_tests' });
const bindings = require('node-gyp-build')(__dirname);

describe('Callback', function () {
afterEach(global.gc);
Expand Down
2 changes: 1 addition & 1 deletion test/foreign_function.js
Expand Up @@ -4,7 +4,7 @@ const ref = require('ref-napi');
const Array = require('ref-array-di')(ref);
const Struct = require('ref-struct-di')(ref);
const ffi = require('../');
const bindings = require('bindings')({ module_root: __dirname, bindings: 'ffi_tests' });
const bindings = require('node-gyp-build')(__dirname);

describe('ForeignFunction', function () {
afterEach(global.gc);
Expand Down
2 changes: 1 addition & 1 deletion test/function.js
Expand Up @@ -2,7 +2,7 @@
const assert = require('assert');
const ref = require('ref-napi');
const ffi = require('../');
const bindings = require('bindings')({ module_root: __dirname, bindings: 'ffi_tests' });
const bindings = require('node-gyp-build')(__dirname);

describe('Function "type"', function () {
afterEach(global.gc);
Expand Down
2 changes: 1 addition & 1 deletion test/variadic.js
Expand Up @@ -2,7 +2,7 @@
const assert = require('assert');
const ref = require('ref-napi');
const ffi = require('../');
const bindings = require('bindings')({ module_root: __dirname, bindings: 'ffi_tests' });
const bindings = require('node-gyp-build')(__dirname);
const sprintfPtr = bindings.sprintf;

describe('variadic arguments', function () {
Expand Down

0 comments on commit d2ae190

Please sign in to comment.