Skip to content

Commit

Permalink
agd enforce Node.js version (#9623)
Browse files Browse the repository at this point in the history
refs: #9622

## Description
Enforce the Node.js version in agd builder. Reverts #9619

This enforces LTS range, aka `^18.12` or `^20.9` through a regexp similar to the golang version check.

### Security Considerations
None

### Scaling Considerations
None

### Documentation Considerations
We'll need to update release notes for validators to use `agd build` instead of the former `yarn install` and `yarn build` as that may still fail. If they still chose to go that route, they're on their own.

### Testing Considerations
CI covers `agd build`

### Upgrade Considerations
Smooth the transition away from previously supported Node v16 in upgrade-15
  • Loading branch information
mergify[bot] authored and mhofman committed Jul 1, 2024
2 parents abb89ce + e3de799 commit b0f1f66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion repoconfig.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# shellcheck disable=SC2034
NODEJS_VERSION=v16
NODEJS_VERSION=v20
GOLANG_VERSION=1.20.3
GOLANG_DIR=golang/cosmos
GOLANG_DAEMON=$GOLANG_DIR/build/agd
Expand All @@ -15,3 +15,13 @@ golang_version_check() {
echo 1>&2 "need go version 1.20.2+, 1.21+, or 2+"
return 1
}

# Args are major, minor and patch version numbers
nodejs_version_check() {
{
[ "$1" -eq 18 ] && [ "$2" -ge 12 ] && return 0
[ "$1" -ge 20 ] && [ "$2" -ge 9 ] && return 0
} 2> /dev/null
echo 1>&2 "need Node.js LTS version ^18.12 or ^20.9, found $1.$2.$3"
return 1
}
10 changes: 9 additions & 1 deletion scripts/agd-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ if $need_nodejs; then
} 1>&2
;;
esac

if nodeversion=$(node --version 2> /dev/null); then
noderegexp='v([0-9]+)\.([0-9]+)\.([0-9]+)'
[[ "$nodeversion" =~ $noderegexp ]] || fatal "illegible node version '$nodeversion'"
nodejs_version_check "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" || exit 1
fi
fi

$do_not_build || (
Expand Down Expand Up @@ -194,7 +200,9 @@ $do_not_build || (
test -z "$src" || {
echo "At least $src is newer than node_modules"
rm -f "$STAMPS/yarn-built"
lazy_yarn install
# Ignore engines since we already checked officially supported versions above
# UNTIL https://github.com/Agoric/agoric-sdk/issues/9622
lazy_yarn install --ignore-engines
}

stamp=$STAMPS/yarn-built
Expand Down

0 comments on commit b0f1f66

Please sign in to comment.