Unverified Commit 01b46faa authored by Josh Spicer's avatar Josh Spicer Committed by GitHub

smart auto-install multiple versions for `node` (#56)

* node

* fix comment (no-ci)

* Apply suggestions from code review
Co-authored-by: 's avatarSamruddhi Khandale <skhandale@microsoft.com>

* update test scenario

* remove minor for node 18

* update scenarios to object notation

* add shabang

* only set default node once
Co-authored-by: 's avatarSamruddhi Khandale <skhandale@microsoft.com>
parent 7f551f8c
name: "test"
on:
pull_request:
paths-ignore:
- ./**/oryx/**
- ./**/java/**
- ./**/dotnet/**
- ./**/php/**
- ./**/node/**
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required ; Temporary tweak for merging the PRs until branch protection rules are updated"'
......@@ -39,7 +39,7 @@ jobs:
terraform: ./**/terraform/**
test:
needs: detect-changes
needs: [detect-changes]
runs-on: ubuntu-latest
continue-on-error: true
strategy:
......
......@@ -34,9 +34,5 @@
"NVM_DIR": "/usr/local/share/nvm",
"NVM_SYMLINK_CURRENT": "true",
"PATH": "${NVM_DIR}/current/bin:${PATH}"
},
"install": {
"app": "",
"file": "install.sh"
}
}
\ No newline at end of file
}
......@@ -11,6 +11,10 @@ export NODE_VERSION=${VERSION:-"lts"}
export NVM_DIR=${NVM_INSTALL_PATH:-"/usr/local/share/nvm"}
INSTALL_TOOLS_FOR_NODE_GYP="${INSTALL_TOOLS_FOR_NODE_GYP:-true}"
# Comma-separated list of node versions to be installed (with nvm)
# alongside NODE_VERSION, but not set as default.
ADDITIONAL_VERSIONS=${ADDITIONAL_VERSIONS:-""}
USERNAME=${USERNAME:-"automatic"}
UPDATE_RC=${UPDATE_RC:-"true"}
......@@ -133,7 +137,7 @@ su ${USERNAME} -c "$(cat << EOF
if [ "${NODE_VERSION}" != "" ]; then
nvm alias default ${NODE_VERSION}
fi
nvm clear-cache
nvm clear-cache
EOF
)" 2>&1
# Update rc files
......@@ -146,6 +150,25 @@ EOF
)"
fi
# Additional node versions to be installed but not be set as default.
if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
OLDIFS=$IFS
IFS=","
read -a additional_versions <<< "$ADDITIONAL_VERSIONS"
for ver in "${additional_versions[@]}"; do
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${ver}"
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm clear-cache"
# Reset the NODE_VERSION as the default version on the path.
done
# Ensure $NODE_VERSION is on the $PATH
if [ "${NODE_VERSION}" != "" ]; then
su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm use default"
fi
IFS=$OLDIFS
fi
# If enabled, verify "python3", "make", "gcc", "g++" commands are available so node-gyp works - https://github.com/nodejs/node-gyp
if [ "${INSTALL_TOOLS_FOR_NODE_GYP}" = "true" ]; then
echo "Verifying node-gyp OS requirements..."
......
#!/bin/bash
set -e
# Optional: Import test library
source dev-container-features-test-lib
# 'latest' is some version of node 18 for a while.
check "version_on_path" node -v | grep 18
check "v18_installed" ls -1 /usr/local/share/nvm/versions/node | grep 18
check "v14_installed" ls -1 /usr/local/share/nvm/versions/node | grep 14.19.3
check "v17_installed" ls -1 /usr/local/share/nvm/versions/node | grep 17.9.1
# Report result
reportResults
......@@ -12,6 +12,15 @@
}
}
},
"install_additional_node": {
"image": "debian:11",
"features": {
"node": {
"version": "latest",
"additional_versions": "v17.9.1,v14.19.3"
}
}
},
"install_additional_python": {
"image": "ubuntu:focal",
"features": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment