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

Add support for node 14 and 16, mark older versions legacy #66

Merged
merged 14 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion .github/workflows/pr-node-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
node-version:
- '14'
leia-tests:
- node-10-example
Copy link
Member

Choose a reason for hiding this comment

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

Spoke with Pirog and he wants us to keep all the legacy version options available/tested. Let's keep the node-10-example tests @badrange

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, makes sense! I pushed an update, let's hope the CI/CD pipeline works.

- node-12-example
steps:

Expand Down
2 changes: 1 addition & 1 deletion .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ excludes:
- node_modules
services:
cli:
type: node:12
type: node:14
build:
- yarn install
scanner: false
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 12.16.1
nodejs 14.18.1
2 changes: 1 addition & 1 deletion examples/landofile-custom/.solo.dist.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: solo-base
services:
node:
type: node:12
type: node:14
tooling:
node:
service: node
3 changes: 3 additions & 0 deletions examples/node14/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*.log
package-lock.json
40 changes: 40 additions & 0 deletions examples/node14/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: lando-node-14
services:
defaults:
type: node:14
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-http.js --watch src --ignore *.test.js
cli:
type: node
compass:
type: node:14
globals:
grunt-cli: latest
build_as_root:
- apt-get update -y
- apt-get install ruby-full -y
- gem install compass
custom:
type: node:16
ssl: true
globals:
gulp-cli: latest
port: 3000
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-https.js --watch src --ignore *.test.js
custom2:
type: node:14.18
ssl: 4444
port: 3000
build:
- yarn
command: /app/node_modules/.bin/nodemon src/app-custom.js --watch src --ignore *.test.js
patch:
type: node:14.18.3
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this actually exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ouch, you're quite right about that, should be fixed now.

tooling:
ruby:
service: compass
compass:
service: compass
91 changes: 91 additions & 0 deletions examples/node14/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Node 14 Example
===============

This example exists primarily to test the following documentation:

* [Node 14-16 Service](https://docs.devwithlando.io/tutorials/node.html)
* [Installing compass in your node service](https://docs.lando.dev/guides/using-compass-on-a-lando-node-service.html)

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should start up successfully
lando poweroff
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should use 14.x as the default version
lando ssh -s defaults -c "env | grep NODE_VERSION=14."

# Should use a user specified version if given
lando ssh -s custom -c "env | grep NODE_VERSION=16."

# Should use a user specified patch version if given
lando ssh -s patch -c "env | grep NODE_VERSION=14.18.3"

# Should serve over port 80 by default
lando ssh -s defaults -c "curl http://localhost | grep tune"

# Should set NODE_EXTRA_CA_CERTS with lando domain CA
lando ssh -s defaults -c \'env | grep NODE_EXTRA_CA_CERTS | grep "$LANDO_CA_CERT"\'

# Should only serve over http by default
lando ssh -s defaults -c "curl https://localhost" || echo $? | grep 1

# Should serve over specified ports if given
lando ssh -s custom -c "curl http://localhost:3000 | grep tune"

# Should serve over https is ssl is set by user
lando ssh -s custom -c "curl https://localhost | grep tune"

# Should servce over a custom https port if ssl is set to a specific port
lando ssh -s custom2 -c "curl https://localhost:4444 | grep DANCING"

# Should run as root if it needs to
lando ssh -s defaults -c "ps -a -u root" | grep "node" | wc -l | grep 2
lando ssh -s defaults -c "ls -lsa /certs" | grep "root root" | wc -l | grep 10
lando ssh -s custom -c "ps -a -u root" | grep "node" | wc -l | grep 2
lando ssh -s custom -c "ls -lsa /certs" | grep "root root" | wc -l | grep 10

# Should run as node if it can
lando ssh -s custom2 -c "ps -a -u node" | grep "node" | wc -l | grep 2
lando ssh -s custom2 -c "ls -lsa /certs" | grep "node" | wc -l | grep 8

# Should install global dependencies if specified by user and have them available in PATH
lando ssh -s custom -c "gulp -v"
lando ssh -s custom -c "which gulp | grep /var/www/.npm-global"

# Should PATH prefer node dependency binaries installed in /app/node_modules over global ones
lando ssh -s custom -c "npm install gulp-cli --no-save"
lando ssh -s custom -c "gulp -v"
lando ssh -s custom -c "which gulp | grep /app/node_modules/.bin"
lando ssh -s custom -c "npm uninstall gulp-cli"
lando ssh -s custom -c "which gulp | grep /var/www/.npm-global"

# Should not serve port for cli
lando ssh -s cli -c "curl http://localhost" || echo $? | grep 1

# Should install ruby and compass on the compass service
lando ruby -v
lando compass -v
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
lando destroy -y
lando poweroff
```
27 changes: 27 additions & 0 deletions examples/node14/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "node-lando",
"version": "1.0.0",
"description": "Node example for Lando",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/lando/lando/tree/master/examples/node"
},
"keywords": [
"node",
"docker",
"localdev"
],
"author": "Mike Pirog",
"license": "MIT",
"dependencies": {
"express": "^4.15.3"
},
"devDependencies": {
"grunt-contrib-compass": "^1.1.1",
"nodemon": "^1.17.2"
}
}
28 changes: 28 additions & 0 deletions examples/node14/src/app-custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Lando node express example
*
* @name taylorswift
*/

'use strict';

// Load modules
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();

// Create our HTTPS server options
const key = fs.readFileSync('/certs/cert.key');
const cert = fs.readFileSync('/certs/cert.crt');

// Create our servers
https.createServer({key, cert}, app).listen(4444);
http.createServer(app).listen(3000);

// Basic HTTP response
app.get('/', (req, res) => {
res.header('Content-type', 'text/html');
return res.end('<h1>DANCING DANCING STARLIGHT</h1>');
});
21 changes: 21 additions & 0 deletions examples/node14/src/app-http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Lando node express example
*
* @name taylorswift
*/

'use strict';

// Load modules
const http = require('http');
const express = require('express');
const app = express();

// Create our server
http.createServer(app).listen(80);

// Basic HTTP response
app.get('/', (req, res) => {
res.header('Content-type', 'text/html');
return res.end('<h1>I said "Oh my!" What a marvelous tune!!!</h1>');
});
28 changes: 28 additions & 0 deletions examples/node14/src/app-https.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Lando node express example
*
* @name taylorswift
*/

'use strict';

// Load modules
const fs = require('fs');
const http = require('http');
const https = require('https');
const express = require('express');
const app = express();

// Create our HTTPS server options
const key = fs.readFileSync('/certs/cert.key');
const cert = fs.readFileSync('/certs/cert.crt');

// Create our servers
https.createServer({key, cert}, app).listen(443);
http.createServer(app).listen(3000);

// Basic HTTP response
app.get('/', (req, res) => {
res.header('Content-type', 'text/html');
return res.end('<h1>I said "Oh my!" What a marvelous tune!!!</h1>');
});
Loading