Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Node.js 16 to test matrix #340

Merged
merged 11 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,41 @@ shared: &shared
key: v3-shared-metrics-dependencies-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/shared-metrics/package-lock.json" }}

# Only run audit with the most recent Node.js version - one Node version is enough.
- run: '([[ $(node -v) =~ ^v14.*$ ]] && npm run audit) || [[ ! $(node -v) =~ ^v14.*$ ]]'
- run: '([[ $(node -v) =~ ^v16.*$ ]] && npm run audit) || [[ ! $(node -v) =~ ^v16.*$ ]]'

# Run linting first, we don't want to wait ages for the test suite to finish only to end the CI job with a linting
# error.
- run: npm run lint

# Only run tests for Node.js 8/Node.js 10 on every other build, alternating, to reduce the number of slots
# we are using. Explanation for the weird calculation: There apparently is no environment variable counting the
# number of times the whole pipeline has been triggered. The only number available is the individual build number,
# that is, the number for the Node 8 build, the Node 10 build, the Node 12 build etc. Since we trigger 5 builds each
# time, we first divide by 5 to get the pipeline number. Then we check if it is an even or odd pipeline number
# (with "% 2"), then turn it into either 8 or 10 by "* 2 + 8".
- run:
name: Determine for which EOL Node.js version (8 or 10) the tests are run.
command: |
echo "export RUN_TESTS_FOR_EOL_NODE_VERSION=$(( $(( $(( $CIRCLE_BUILD_NUM / 5 % 2 )) * 2 )) + 8 ))" >> $BASH_ENV

- run: |
if [[ $RUN_TESTS_FOR_EOL_NODE_VERSION = 10 && $(node -v) =~ ^v8.*$ ]]; then
echo "Skipping tests for EOL Node.js version 8, running tests for EOL version 10 in this build."
circleci-agent step halt
fi

- run: |
if [[ $RUN_TESTS_FOR_EOL_NODE_VERSION = 8 && $(node -v) =~ ^v10.*$ ]]; then
echo "Skipping tests for EOL Node.js version 10, running tests for EOL version 8 in this build."
circleci-agent step halt
fi

# Run the test suites.
# (Use ulimit to remove the file size limit on core dump files before running tests.)
- run: |
# tell the operating system to remove the file size limit on core dump files before running tests
ulimit -c unlimited
# run all tests
npm test

- store_test_results:
path: test-results
- run:
Expand Down Expand Up @@ -235,9 +260,9 @@ nats-streaming: &nats-streaming
- 8223:8223

jobs:
"node-14":
"node-16":
docker:
- image: circleci/node:14
- image: circleci/node:16
- <<: *zookeeper
- <<: *elasticsearch
- <<: *mongo
Expand All @@ -251,9 +276,9 @@ jobs:
- <<: *nats-streaming
<<: *shared

"node-12":
"node-14":
docker:
- image: circleci/node:12
- image: circleci/node:14
- <<: *zookeeper
- <<: *elasticsearch
- <<: *mongo
Expand All @@ -267,9 +292,9 @@ jobs:
- <<: *nats-streaming
<<: *shared

"node-10":
"node-12":
docker:
- image: circleci/node:10
- image: circleci/node:12
- <<: *zookeeper
- <<: *elasticsearch
- <<: *mongo
Expand All @@ -283,9 +308,9 @@ jobs:
- <<: *nats-streaming
<<: *shared

"node-8":
"node-10":
docker:
- image: circleci/node:8
- image: circleci/node:10
- <<: *zookeeper
- <<: *elasticsearch
- <<: *mongo
Expand All @@ -299,9 +324,9 @@ jobs:
- <<: *nats-streaming
<<: *shared

"node-6":
"node-8":
docker:
- image: circleci/node:6
- image: circleci/node:8
- <<: *zookeeper
- <<: *elasticsearch
- <<: *mongo
Expand All @@ -319,6 +344,7 @@ workflows:
version: 2
build:
jobs:
- "node-16"
- "node-14"
- "node-12"
- "node-10"
Expand Down
17 changes: 14 additions & 3 deletions native-dep-packs/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
WORKDIR /instana
RUN apk add --no-cache --virtual .gyp \
build-base \
python

# Beginning with the Node.js 16 Alpine Docker image (based on Alpine 3.13), we need to install the package python3
# instead of python.
RUN \
if grep "3.13" /etc/os-release; then \
apk add --no-cache --virtual .gyp \
build-base \
python3 ; \
else \
apk add --no-cache --virtual .gyp \
build-base \
python ; \
fi

RUN npm install @instana/collector@latest
23 changes: 10 additions & 13 deletions native-dep-packs/rebuild-precompiled-addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ set -eo pipefail

cd `dirname $BASH_SOURCE`

# Maintenance Note:
# This should be kept in sync with packages/autoprofile/precompile/build-all-addons.js-> ABI_VERSIONS.
declare -A ABI_VERSIONS=( \
["48"]="6.17.1" \
["57"]="8.17.0" \
["64"]="10.23.0" \
["72"]="12.20.0" \
["83"]="14.15.1" \
["88"]="15.3.0" \
["64"]="10.24.1" \
["72"]="12.22.1" \
["83"]="14.17.0" \
["88"]="15.14.0" \
["93"]="16.3.0" \
)
# Note: We do not provide for older non-LTS versions (Node.js 7, 9, 11, 13).
# Note: We do not provide for older non-LTS versions (Node.js 9, 11, 13).

LIBC_VARIANTS=( \
"glibc" \
Expand Down Expand Up @@ -44,8 +46,8 @@ fi
# MacOS #
#########

# Precompiled versions of the native addons are neither added to version control nor are they part of the published
# packages. They are only built locally for test purposes.
# Precompiled versions of the native addons for MacOS are neither added to version control nor are they part of the
# published packages. They are only built locally for test purposes.


if [[ ! -z "$BUILD_FOR_MACOS" ]]; then
Expand All @@ -64,11 +66,6 @@ if [[ ! -z "$BUILD_FOR_MACOS" ]]; then
rm -rf ../packages/shared-metrics/addons/darwin

for ABI_VERSION in ${!ABI_VERSIONS[@]}; do
if [[ $ABI_VERSION = 48 ]]; then
echo "Skipping ABI version 48 for Darwin."
continue
fi

NODEJS_VERSION=${ABI_VERSIONS[$ABI_VERSION]}
buildAndCopyModulesDarwin $ABI_VERSION $NODEJS_VERSION
done
Expand Down
1 change: 1 addition & 0 deletions packages/autoprofile/addons/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
darwin
Binary file modified packages/autoprofile/addons/darwin/x64/57/autoprofile.node
Binary file not shown.
Binary file modified packages/autoprofile/addons/darwin/x64/64/autoprofile.node
Binary file not shown.
Binary file modified packages/autoprofile/addons/darwin/x64/72/autoprofile.node
Binary file not shown.
Binary file modified packages/autoprofile/addons/darwin/x64/83/autoprofile.node
Binary file not shown.
Binary file modified packages/autoprofile/addons/darwin/x64/88/autoprofile.node
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions packages/autoprofile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
"async": "^3.2.0",
"eslint": "^7.27.0",
"mkdirp": "^1.0.4",
"mocha": "^7.2.0"
"mocha": "^7.2.0",
"semver": "^5.7.1"
},
"main": "index.js",
"files": [
"src",
"lib",
"addons",
"addons/linux",
"binding.gyp",
"index.js",
"node-gyp-fallback.js",
Expand Down
15 changes: 12 additions & 3 deletions packages/autoprofile/precompile/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ FROM ${BASE_IMAGE}

WORKDIR /opt/autoprofile

RUN apk add --no-cache --virtual .gyp \
build-base \
python
# Beginning with the Node.js 16 Alpine Docker image (based on Alpine 3.13), we need to install the package python3
# instead of python.
RUN \
if grep "3.13" /etc/os-release; then \
apk add --no-cache --virtual .gyp \
build-base \
python3 ; \
else \
apk add --no-cache --virtual .gyp \
build-base \
python ; \
fi

ENTRYPOINT ["node", "precompile/build-wrapper"]
20 changes: 11 additions & 9 deletions packages/autoprofile/precompile/build-all-addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
'use strict';

const os = require('os');
const path = require('path');
const { copyFileSync, existsSync, mkdirSync } = require('fs');
const { GLIBC, MUSL } = require('detect-libc');

const buildSingleAddOn = require('./build-single-addon');
const prepareDockerImages = require('./prepare-docker-images');
const buildOnDocker = require('./build-on-docker');

// Make packages/autoprofile the current working dir.
process.chdir(path.join(__dirname, '..'));

const PLATFORMS = ['linux'];

if (os.platform() === 'darwin') {
Expand All @@ -26,13 +30,15 @@ if (os.platform() === 'darwin') {

const LIBC_FAMILIES = [GLIBC, MUSL];

// Maintenance Note:
// This should be kept in sync with native-dep-packs/rebuild-precompiled-addons.sh -> ABI_VERSIONS.
const ABI_VERSIONS = {
48: '6.17.1',
57: '8.17.0',
64: '10.23.0',
72: '12.20.0',
83: '14.15.1',
88: '15.3.0'
64: '10.24.1',
72: '12.22.1',
83: '14.17.0',
88: '15.14.0',
93: '16.3.0'
};

function buildForPlatform(platform) {
Expand All @@ -54,10 +60,6 @@ function buildForAllAbis(platform, family) {

function buildOnHostOrDocker(platform, family, abi, version) {
if (platform === 'darwin') {
if (abi < 57) {
// Do not compile older versions for MacOS.
return;
}
buildSingleAddOn(abi, version);
} else if (platform === 'linux') {
buildOnDocker(platform, family, abi, version);
Expand Down
14 changes: 12 additions & 2 deletions packages/autoprofile/precompile/build-single-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { copyFileSync, existsSync } = require('fs');
const { sync: mkdirpSync } = require('mkdirp');
const path = require('path');
const os = require('os');
const semver = require('semver');

module.exports = exports = function buildSingleAddOn(abi, version) {
const platform = os.platform();
Expand All @@ -29,8 +30,17 @@ module.exports = exports = function buildSingleAddOn(abi, version) {
mkdirpSync(addonDir);
}

execSync(`node node_modules/node-gyp/bin/node-gyp.js rebuild --target=${version} --arch=x64`, {
cwd: path.join(__dirname, '..'),
let darwinNodeJs10Fix = '';
if (platform === 'darwin' && semver.gte(version, '10.0.0') && semver.lt(version, '12.0.0')) {
darwinNodeJs10Fix = '--build_v8_with_gn=false';
basti1302 marked this conversation as resolved.
Show resolved Hide resolved
}

const command = `node node_modules/node-gyp/bin/node-gyp.js rebuild --target=${version} ${darwinNodeJs10Fix} --arch=x64`;
const cwd = path.join(__dirname, '..');

console.log(`Running "${command}" in directory "${cwd}".`);
execSync(command, {
cwd,
stdio: 'inherit'
});
copyFileSync('build/Release/autoprofile-addon.node', addonPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ function registerTests(useHttps) {
span => expect(span.ec).to.equal(1),
span =>
expect(span.data.http.url).to.match(/ha-te-te-peh:\/\/999\.0\.0\.1(?:\/)?:not-a-port\/malformed-url/),
span => expect(span.data.http.error).to.match(/Protocol .* not supported./),
span => {
if (semver.gte(process.version, '16.0.0')) {
expect(span.data.http.error).to.match(/Invalid URL/);
} else {
expect(span.data.http.error).to.match(/Protocol .* not supported./);
}
},
span => expect(span.t).to.equal(entrySpan.t),
span => expect(span.p).to.equal(entrySpan.s)
]);
Expand Down
4 changes: 3 additions & 1 deletion packages/legacy-sensor/test/api/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ const expect = require('chai').expect;
const config = require('../../../core/test/config');
const testUtils = require('../../../core/test/test_util');
const ProcessControls = require('../../../collector/test/test_util/ProcessControls');
const AgentStubControls = require('../../../collector/test/apps/agentStubControls').AgentStubControls;

describe('legacy sensor/API', function () {
this.timeout(config.getTestTimeout());

const agentControls = require('../../../collector/test/apps/agentStubControls');
const agentControls = new AgentStubControls(5210);
agentControls.registerTestHooks();

const controls = new ProcessControls({
dirname: __dirname,
port: 5215,
agentControls
}).registerTestHooks();

Expand Down
4 changes: 3 additions & 1 deletion packages/legacy-sensor/test/metrics/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ const _ = require('lodash');
const config = require('../../../core/test/config');
const testUtils = require('../../../core/test/test_util');
const ProcessControls = require('../../../collector/test/test_util/ProcessControls');
const AgentStubControls = require('../../../collector/test/apps/agentStubControls').AgentStubControls;

describe('legacy sensor/metrics', function () {
this.timeout(config.getTestTimeout());

const agentControls = require('../../../collector/test/apps/agentStubControls');
const agentControls = new AgentStubControls(5210);
agentControls.registerTestHooks();

const controls = new ProcessControls({
dirname: __dirname,
port: 5215,
agentControls
}).registerTestHooks();

Expand Down
15 changes: 12 additions & 3 deletions packages/legacy-sensor/test/tracing/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ const ProcessControls = require('../../../collector/test/test_util/ProcessContro

const config = require('../../../core/test/config');
const testUtils = require('../../../core/test/test_util');
const AgentStubControls = require('../../../collector/test/apps/agentStubControls').AgentStubControls;

const serverPort = 3216;
const clientPort = 5215;
const serverPort = 5216;

let agentControls;

Expand All @@ -24,7 +26,7 @@ describe('legacy sensor/tracing', function () {
return;
}

agentControls = require('../../../collector/test/apps/agentStubControls');
agentControls = new AgentStubControls(5210);

this.timeout(config.getTestTimeout() * 2);

Expand All @@ -38,6 +40,7 @@ describe('legacy sensor/tracing', function () {

const clientControls = new ProcessControls({
appPath: path.join(__dirname, 'clientApp'),
port: clientPort,
agentControls,
env: {
SERVER_PORT: serverPort
Expand Down Expand Up @@ -145,7 +148,13 @@ describe('legacy sensor/tracing', function () {
span => expect(span.k).to.equal(constants.EXIT),
span => expect(span.ec).to.equal(1),
span => expect(span.data.http.url).to.match(/ha-te-te-peh/),
span => expect(span.data.http.error).to.match(/Protocol .* not supported./),
span => {
if (semver.gte(process.version, '16.0.0')) {
expect(span.data.http.error).to.match(/Invalid URL/);
} else {
expect(span.data.http.error).to.match(/Protocol .* not supported./);
}
},
span => expect(span.t).to.equal(entrySpan.t),
span => expect(span.p).to.equal(entrySpan.s)
]);
Expand Down
Loading