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

New: Adding NodeJS version check to Release script #834

Merged

Conversation

JustinHoldstock
Copy link
Contributor

No description provided.

@boxcla
Copy link

boxcla commented Aug 23, 2018

Verified that @JustinHoldstock has signed the CLA. Thanks for the pull request!

build/release.sh Outdated
@@ -236,6 +253,8 @@ while getopts "mnp" opt; do
esac
done

# Before running release, make sure using correct version of NodeJS
validate_node_version;
Copy link
Contributor

Choose a reason for hiding this comment

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

this might make more sense added to the push_new_release function like we do with other checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

}
}

https.get(NODE_JS_VERSION_LIST_URL, response => {
Copy link
Contributor

Choose a reason for hiding this comment

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

No harm in bringing in axios as a dev dependency to accomplish this (IMO).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Really good idea, thank you

body += data;
});

response.on('end', validateNodeVersion);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this data get used? ValidateNodeVersion doesn't take in any parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See use of body.

const SUPPORTED_LTS = "Carbon";
const VERSION = process.versions.node;
const NODE_JS_VERSION_LIST_URL="https://nodejs.org/dist/index.json"
const MIN_MAJOR_SUPPORT = 8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we still relying solely off the information from nodejs.org? In that case why are these constants needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still want to enforce our minimum requirement before doing a compare against the NodeJS listings. I'm actually going to do that check first, so we don't have to make the network request UNLESS we've determined it's >= than our required version

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


function fail() {
body = '';
console.log(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to throw an error at some point to get the release script to break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

console.log() is picked up by the bash script that invokes this. Do you think we also need to throw an error if the parent bash script is halting all execution after receiving a false signal from this?

Copy link
Contributor

Choose a reason for hiding this comment

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

can we do this with just return values and not console.log()?

*/
function compareVersion(major, minor, patch) {
// If major version is greater, it's valid
if (major > MIN_MAJOR_SUPPORT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a problem, lets say someone is using node 10? There could be breaking changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

compareVersion() only compares against our minimum requirements of node 8.9.4. After this is executed, we do a check against LTS versions of node, which are supported (at least) by conventional-github-releaser.

const MIN_MINOR_SUPPORT = 9;
const MIN_PATCH_SUPPORT = 4;

function fail() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe drop a doc string on these explaining what the process.exit does?



/**
* Exit with code 1 so that calling script can see that current node version was NOT valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm

@JustinHoldstock JustinHoldstock merged commit f28558c into box:master Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants