[actions] migrate Travis CI tests to GitHub Actions

Add new workflow for tests that were only running on Travis CI:
- fast test suite (sh, bash, dash, zsh)
- installation_iojs without curl (sh, bash, dash, zsh)
- installation_node with and without curl (sh, bash, dash, zsh)
- xenial test suite (sh, bash, dash, zsh)

The installation_node and xenial tests run on ubuntu-20.04 to match
the Travis xenial environment as closely as possible.
This commit is contained in:
Jordan Harband
2026-01-20 20:17:42 -08:00
parent ec8906b284
commit d0bf268db2
7 changed files with 419 additions and 112 deletions

View File

@@ -2,6 +2,10 @@
die () { echo "$@" ; cleanup ; exit 1; }
strip_colors() {
command sed $'s/\x1b\\[[0-9;]*m//g'
}
cleanup() {
unset -f nvm_download nvm_ls_remote nvm_ls_remote_iojs
if [ -n "${TEMP_NVM_COLORS-}" ]; then
@@ -45,22 +49,22 @@ nvm_download() {
}
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
OUTPUT="$(nvm ls-remote --lts | sed 's/[ \t]*$//')"
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"
OUTPUT="$(nvm ls-remote --lts | strip_colors | sed 's/[ \t]*$//')"
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | strip_colors | sed 's/[ \t]*$//' )"
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote --lts did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"
OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')"
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"
OUTPUT="$(nvm ls-remote "lts/*" | strip_colors | sed 's/[ \t]*$//')"
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | strip_colors | sed 's/[ \t]*$//' )"
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"
INDEX=1
printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do
ACTUAL="$(nvm ls-remote "lts/-${INDEX}" | sed 's/[ \t]*$//')"
ACTUAL="$(nvm ls-remote "lts/-${INDEX}" | strip_colors | sed 's/[ \t]*$//')"
MESSAGE="for lts/-${INDEX} (${LTS})"
EXPECTED="$(nvm ls-remote "lts/${LTS}" | sed 's/[ \t]*$//')"
EXPECTED="$(nvm ls-remote "lts/${LTS}" | strip_colors | sed 's/[ \t]*$//')"
[ "${ACTUAL}" = "${EXPECTED}" ] || die "${MESSAGE}: expected >${EXPECTED}<, got >${ACTUAL}<"
INDEX=$(($INDEX + 1))
@@ -69,6 +73,7 @@ done
OUTPUT="$(nvm ls-remote lts/ARGON 2>&1)"
EXIT_CODE=$?
[ $EXIT_CODE -eq 3 ] || die "nvm ls-remote lts/ARGON did not exit 3, got '${EXIT_CODE}'"
OUTPUT="$(echo "${OUTPUT}" | strip_colors)"
EXPECTED_OUTPUT="LTS names must be lowercase
N/A"
@@ -84,8 +89,8 @@ nvm_ls_remote_iojs() {
}
EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"
OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"
OUTPUT="$(nvm ls-remote | strip_colors | sed 's/[ \t]*$//')"
EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | strip_colors | sed 's/[ \t]*$//' )"
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "bare nvm ls-remote did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"
cleanup