diff --git a/.circleci/config.yml b/.circleci/config.yml index 724a57d1cf8..d7e9125a168 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -486,7 +486,7 @@ jobs: prebuild-linux-x64: docker: - - image: node:10 + - image: node:8 working_directory: ~/dd-trace-js resource_class: small environment: @@ -510,7 +510,7 @@ jobs: prebuild-linux-x32: docker: - - image: node:10 + - image: node:8 working_directory: ~/dd-trace-js resource_class: small environment: @@ -611,7 +611,7 @@ jobs: alpine-prebuilt: docker: - - image: node:10-alpine + - image: node:alpine working_directory: ~/dd-trace-js resource_class: small steps: @@ -629,6 +629,23 @@ jobs: name: Unit tests command: yarn test:core + slim-prebuilt: + docker: + - image: node:slim + working_directory: ~/dd-trace-js + resource_class: small + steps: + - checkout + - *yarn-versions + - *restore-yarn-cache + - *yarn-install + - *save-yarn-cache + - restore_cache: + key: prebuild-linux-x64-{{ .Environment.CIRCLE_WORKFLOW_ID }} + - run: + name: Unit tests + command: yarn test:core + browser: docker: - image: circleci/node:10-browsers @@ -751,6 +768,9 @@ workflows: - alpine-prebuilt: requires: - prebuild-linux-x64 + - slim-prebuilt: + requires: + - prebuild-linux-x64 nightly: triggers: - schedule: diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 3fa206d560e..243ef772698 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -47,9 +47,7 @@ dev,karma-mocha,MIT,Copyright 2011-2013 Google, Inc. dev,karma-webpack,MIT,Copyright JS Foundation and other contributors dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foundation dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors -dev,node-abi,MIT,Copyright 2016 Lukas Geiger dev,nyc,ISC,Copyright 2015 Contributors -dev,prebuildify,MIT,Copyright 2017 Mathias Buus dev,proxyquire,MIT,Copyright 2013 Thorsten Lorenz dev,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer dev,semver,ISC,Copyright Isaac Z. Schlueter and Contributors diff --git a/package.json b/package.json index da4de089181..15f6120a4b1 100644 --- a/package.json +++ b/package.json @@ -97,9 +97,7 @@ "karma-webpack": "^4.0.2", "mocha": "^5.2.0", "nock": "^11.3.3", - "node-abi": "^2.8.0", "nyc": "^14.1.1", - "prebuildify": "^2.11.0", "proxyquire": "^1.8.0", "retry": "^0.10.1", "sinon": "^4.2.1", diff --git a/scripts/prebuild.js b/scripts/prebuild.js index 70edce3fd0e..5f9dc7ce12e 100644 --- a/scripts/prebuild.js +++ b/scripts/prebuild.js @@ -1,21 +1,61 @@ 'use strict' -const prebuildify = require('prebuildify') -const abi = require('node-abi') const path = require('path') const os = require('os') const tar = require('tar') -const semver = require('semver') const fs = require('fs') +const execSync = require('child_process').execSync -const name = `${os.platform()}-${process.env.ARCH || os.arch()}` -const targets = abi.allTargets - .filter(target => target.runtime === 'node') - .filter(target => semver.satisfies(target.target, '>=8.0.0')) +const platform = os.platform() +const arch = process.env.ARCH || os.arch() +const name = `${platform}-${arch}` -const cb = err => { - if (err) throw err +// https://nodejs.org/en/download/releases/ +const targets = [ + { version: '8.0.0', abi: '57' }, + { version: '9.0.0', abi: '59' }, + { version: '10.0.0', abi: '64' }, + { version: '11.0.0', abi: '67' }, + { version: '12.0.0', abi: '72' }, + { version: '13.0.0', abi: '79' } +] +prebuildify() +pack() + +function retry (cmd) { + try { + execSync(cmd, { stdio: [0, 1, 2] }) + } catch (e) { + retry(cmd) + } +} + +function prebuildify () { + const cache = path.join(os.tmpdir(), 'prebuilds') + + mkdirSafe(cache) + mkdirSafe('prebuilds') + mkdirSafe(`prebuilds/${platform}-${arch}`) + + targets.forEach(target => { + const cmd = [ + 'node-gyp rebuild', + `--target=${target.version}`, + `--target_arch=${arch}`, + `--devdir=${cache}`, + '--release', + '--build_v8_with_gn=false', + '--enable_lto=false' + ].join(' ') + + retry(cmd) + + fs.copyFileSync('build/Release/metrics.node', `prebuilds/${platform}-${arch}/node-${target.abi}.node`) + }) +} + +function pack () { fs.copyFileSync( path.join(__dirname, '..', 'packages', 'dd-trace', 'src', 'native', 'tdigest', 'NOTICES'), path.join(__dirname, '..', 'prebuilds', 'NOTICES') @@ -32,10 +72,15 @@ const cb = err => { portable: true, file: `addons-${name}.tgz`, cwd: path.join(__dirname, '..') - }, ['prebuilds']) + }, [ + `prebuilds/${platform}-${arch}`, + 'prebuilds/NOTICES', + 'prebuilds/LICENSE-2.0.txt' + ]) } -prebuildify({ - targets, - strip: false -}, cb) +function mkdirSafe (filename) { + if (!fs.existsSync(filename)) { + fs.mkdirSync(filename) + } +}