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

Update Inventory for heroku/nodejs engine (heroku#1144) #93

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@

## main

## v226 (2023-10-19)

- Added Node.js version 21.0.0.
- Add metrics and tests for Node.js 21. ([#1161](https://github.com/heroku/heroku-buildpack-nodejs/pull/1161))

## v225 (2023-10-17)

- Added Node.js version 20.8.1.
- Added Node.js version 18.18.2.

## v224 (2023-10-11)

- Added Node.js version 18.18.1.
- Report errors when checking `npm` and `yarn` output ([#1147](https://github.com/heroku/heroku-buildpack-nodejs/pull/1147))

## v223 (2023-10-04)

- Added Node.js version 20.8.0.
- Added Yarn version 3.6.4.
- Added Yarn version 4.0.0-rc.52.
- Added Yarn version 4.0.0-rc.53.

## v222 (2023-09-25)

- Fixed issue where npm versions `>=10` were being downgraded to version `5.x` ([#1141](https://github.com/heroku/heroku-buildpack-nodejs/pull/1141))
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ GEM
rrrretry (1.0.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.12.0)
rspec-support (3.12.1)
sem_version (2.0.1)
thor (1.2.1)
threaded (0.0.4)
Expand Down
35 changes: 35 additions & 0 deletions inventory/node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5404,6 +5404,20 @@ arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v18.18.0-linux-x64.tar.gz"
etag = "6786cf20445987a3db61fe4d032d1f56-6"

[[releases]]
version = "18.18.1"
channel = "release"
arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v18.18.1-linux-x64.tar.gz"
etag = "42f1a933e23073a3c891a724e131436c-6"

[[releases]]
version = "18.18.2"
channel = "release"
arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v18.18.2-linux-x64.tar.gz"
etag = "840d418911ebab9041cc40478e88481a-6"

[[releases]]
version = "18.2.0"
channel = "release"
Expand Down Expand Up @@ -5635,6 +5649,27 @@ arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v20.7.0-linux-x64.tar.gz"
etag = "e0f1b651dcf0db279846ccfab09321dc-6"

[[releases]]
version = "20.8.0"
channel = "release"
arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v20.8.0-linux-x64.tar.gz"
etag = "537d2c2b3f13e969b67e61e4f8ed8a0f-6"

[[releases]]
version = "20.8.1"
channel = "release"
arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v20.8.1-linux-x64.tar.gz"
etag = "641b5ed8d951cf81f68a150402e2493c-6"

[[releases]]
version = "21.0.0"
channel = "release"
arch = "linux-x64"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/node/release/linux-x64/node-v21.0.0-linux-x64.tar.gz"
etag = "d87d4baf7c3cbc4289065f7ff6667820-6"

[[releases]]
version = "4.0.0"
channel = "release"
Expand Down
19 changes: 19 additions & 0 deletions inventory/yarn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,12 @@ channel = "release"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/yarn/release/yarn-v3.6.3.tar.gz"
etag = "cd87545d08991cb3089d89bfb60716f0"

[[releases]]
version = "3.6.4"
channel = "release"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/yarn/release/yarn-v3.6.4.tar.gz"
etag = "c39c39f159d1c5170ef1d38a41e80aaf"

[[releases]]
version = "4.0.0-rc.35"
channel = "release"
Expand Down Expand Up @@ -941,3 +947,16 @@ version = "4.0.0-rc.51"
channel = "release"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/yarn/release/yarn-v4.0.0-rc.51.tar.gz"
etag = "b23bee873d416ec64cf88b80de604327"

[[releases]]
version = "4.0.0-rc.52"
channel = "release"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/yarn/release/yarn-v4.0.0-rc.52.tar.gz"
etag = "453dcad2d81a1d26c17ea665ced5543e"

[[releases]]
version = "4.0.0-rc.53"
channel = "release"
url = "https://heroku-nodebin.s3.us-east-1.amazonaws.com/yarn/release/yarn-v4.0.0-rc.53.tar.gz"
etag = "c0d6abdde92df88fc17e0bf8ef57b9a3"

19 changes: 16 additions & 3 deletions lib/binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ install_yarn() {
chmod +x "$dir"/bin/*

# Verify yarn works before capturing and ensure its stderr is inspectable later
yarn --version 2>&1 1>/dev/null
suppress_output yarn --version
if $YARN_2; then
echo "Using yarn $(yarn --version)"
else
Expand Down Expand Up @@ -113,7 +113,7 @@ install_npm() {
local dir="$2"
local npm_lock="$3"
# Verify npm works before capturing and ensure its stderr is inspectable later
npm --version 2>&1 1>/dev/null
suppress_output npm --version
npm_version="$(npm --version)"

# If the user has not specified a version of npm, but has an npm lockfile
Expand All @@ -135,7 +135,20 @@ install_npm() {
"Is npm $version compatible with this Node.js version?" && false
fi
# Verify npm works before capturing and ensure its stderr is inspectable later
npm --version 2>&1 1>/dev/null
suppress_output npm --version
echo "npm $(npm --version) installed"
fi
}

suppress_output() {
local TMP_COMMAND_OUTPUT
TMP_COMMAND_OUTPUT=$(mktemp)
trap "rm -rf '$TMP_COMMAND_OUTPUT' >/dev/null" RETURN

"$@" >"$TMP_COMMAND_OUTPUT" 2>&1 || {
local exit_code="$?"
cat "$TMP_COMMAND_OUTPUT"
return "$exit_code"
}
return 0
}
1 change: 1 addition & 0 deletions plugin/heroku-nodejs-plugin-node-21.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
107fa5474f01fce59c2b7e9d17411f161feddd1a0537ac85798ae8804d66ebe17285d66062adfe75472b64006951b81dcc322e4918e2ee5c6f3fae96c24dd1e6 heroku-nodejs-plugin-node-21-v13.tar.gz
Copy link
Author

Choose a reason for hiding this comment

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

Not sure about these files in the plugin directory, they need to be removed probably

Binary file added plugin/heroku-nodejs-plugin-node-21.tar.gz
Binary file not shown.
25 changes: 25 additions & 0 deletions spec/ci/node_21_metrics_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative '../spec_helper'

describe "Node Metrics for v21.x" do
context "test metrics for Node v21x app" do
let(:app) {
Hatchet::Runner.new(
"spec/fixtures/repos/node-21-metrics",
config: {
"HEROKU_METRICS_URL" => "http://localhost:3000",
"METRICS_INTERVAL_OVERRIDE" => "10000"
}
)
}

it "should deploy" do
app.deploy do |app|
data = successful_json_body(app)
expect(data["gauges"]["node.eventloop.delay.ms.max"]).to be >= 2000
expect(data["counters"]["node.gc.collections"]).to be >= 0
expect(data["counters"]["node.gc.young.collections"]).to be >= 0
expect(data["counters"]["node.gc.old.collections"]).to be >= 0
end
end
end
end
15 changes: 15 additions & 0 deletions spec/ci/node_21_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require_relative '../spec_helper'

describe "Hello World for Node v21.x" do
context "a single-process Node v21.x app" do
let(:app) {
Hatchet::Runner.new("spec/fixtures/repos/node-21")
}

it "should deploy successfully" do
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello, world!")
end
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/repos/node-21-metrics/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
72 changes: 72 additions & 0 deletions spec/fixtures/repos/node-21-metrics/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env node

const http = require('http');
const EventEmitter = require('events');

const PORT = process.env.PORT || 5000;
const Events = new EventEmitter();

// This will block the event loop for ~lengths of time
function blockCpuFor(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`blocking the event loop for ${ms}ms`);
let now = new Date().getTime();
let result = 0
while(true) {
result += Math.random() * Math.random();
if (new Date().getTime() > now + ms)
break;
}
resolve();
}, 100);
});
}

function getNextMetricsEvent() {
return new Promise((resolve, reject) => Events.once('metrics', resolve));
}

const server = http.createServer((req, res) => {
// wait for the next metrics event
getNextMetricsEvent()
.then(blockCpuFor(2000))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
.then(blockCpuFor(100))
// gather the next metrics data which should include these pauses
.then(getNextMetricsEvent())
.then(data => {
res.setHeader('Content-Type', 'application/json');
res.end(data);
})
.catch(() => {
res.statusCode = 500;
res.end("Something went wrong");
});
});

server.listen(PORT, () => console.log(`Listening on ${PORT}`));

// Create a second server that intercepts the HTTP requests
// sent by the metrics plugin
const metricsListener = http.createServer((req, res) => {
if (req.method == 'POST') {
let body = '';
req.on('data', (data) => body += data);
req.on('end', () => {
res.statusCode = 200;
res.end();
Events.emit('metrics', body)
});
}
});

metricsListener.listen(3000, () => console.log('Listening for metrics on 3000'));
11 changes: 11 additions & 0 deletions spec/fixtures/repos/node-21-metrics/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "node-metrics-test-app",
"version": "1.0.0",
"engines": {
"node": "21.x"
},
"main": "index.js",
"license": "MIT",
"devDependencies": {},
"dependencies": {}
}
1 change: 1 addition & 0 deletions spec/fixtures/repos/node-21/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
3 changes: 3 additions & 0 deletions spec/fixtures/repos/node-21/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "hello-world"
}
13 changes: 13 additions & 0 deletions spec/fixtures/repos/node-21/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env node

const http = require('http');

const PORT = process.env.PORT || 5000;

const server = http.createServer((_req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end("Hello, world!");
})

server.listen(PORT, () => console.log(`Listening on ${PORT}`));
21 changes: 21 additions & 0 deletions spec/fixtures/repos/node-21/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "hello-world",
"version": "1.0.0",
"engines": {
"node": "21.x"
},
"scripts": {
"prettify": "prettier --single-quote --trailing-comma all --write 'bin/*' 'src/**/*.js'",
"test": "jest --silent",
"dev": "nodemon --watch . --watch src/* src/index.js",
"build": "echo NODE_OPTIONS: $NODE_OPTIONS"
},
"main": "index.js",
"license": "MIT",
"devDependencies": {
"jest": "^19.0.2",
"nodemon": "^1.19.4",
"prettier": "^0.22.0"
},
"dependencies": {}
}
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def resolve_all_supported_node_versions(options = {})
end

def version_supports_metrics(version)
SemVersion.new(version).satisfies?('>= 10.0.0') && SemVersion.new(version).satisfies?('< 21.0.0')
SemVersion.new(version).satisfies?('>= 10.0.0') && SemVersion.new(version).satisfies?('< 22.0.0')
end

def get_test_versions
Expand All @@ -87,7 +87,7 @@ def get_test_versions
elsif ENV['TEST_ALL_NODE_VERSIONS'] == 'true'
versions = resolve_all_supported_node_versions()
else
versions = resolve_node_version(['14.x', '16.x', '18.x', '19.x', '20.x'])
versions = resolve_node_version(['18.x', '19.x', '20.x', '21.x'])
end
puts("Running tests for Node versions: #{versions.join(', ')}")
versions
Expand Down
Loading