mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-26 04:10:36 +08:00 
			
		
		
		
	[Tests] move sourcing suite to GHA
This commit is contained in:
		
							
								
								
									
										30
									
								
								.github/workflows/tests.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								.github/workflows/tests.yml
									
									
									
									
										vendored
									
									
								
							| @@ -19,13 +19,24 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         include: |         exclude: | ||||||
|           - shell: bash |           - shell: sh | ||||||
|             suite: install_script |             suite: install_script | ||||||
|       #   shell: |           - shell: dash | ||||||
|       #     - bash |             suite: install_script | ||||||
|       #   suite: |           - shell: zsh | ||||||
|       #     - install_script |             suite: install_script | ||||||
|  |           - shell: ksh | ||||||
|  |             suite: install_script | ||||||
|  |         suite: | ||||||
|  |           - install_script | ||||||
|  |           - sourcing | ||||||
|  |         shell: | ||||||
|  |           - sh | ||||||
|  |           - bash | ||||||
|  |           - dash | ||||||
|  |           - zsh | ||||||
|  |           # - ksh | ||||||
|  |  | ||||||
|     steps: |     steps: | ||||||
|       - name: Harden Runner |       - name: Harden Runner | ||||||
| @@ -37,7 +48,13 @@ jobs: | |||||||
|             raw.githubusercontent.com:443 |             raw.githubusercontent.com:443 | ||||||
|             nodejs.org:443 |             nodejs.org:443 | ||||||
|             iojs.org:443 |             iojs.org:443 | ||||||
|  |             azure.archive.ubuntu.com:80 | ||||||
|  |             packages.microsoft.com:443 | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|  |       - run: sudo apt-get update; sudo apt-get install ${{ matrix.shell }} | ||||||
|  |         if: matrix.shell == 'zsh' || matrix.shell == 'ksh' | ||||||
|  |         # zsh (https://github.com/actions/runner-images/issues/264) and ksh are not in the ubuntu image | ||||||
|  |         shell: bash | ||||||
|       - run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }} |       - run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }} | ||||||
|       - run: curl --version |       - run: curl --version | ||||||
|       - run: wget --version |       - run: wget --version | ||||||
| @@ -48,6 +65,7 @@ jobs: | |||||||
|           skip-ls-check: true |           skip-ls-check: true | ||||||
|           shell-command: echo installed |           shell-command: echo installed | ||||||
|       - run: npm ls urchin |       - run: npm ls urchin | ||||||
|  |       - run: npx which urchin | ||||||
|       - run: env |       - run: env | ||||||
|       - run: make TERM=xterm-256color TEST_SUITE="${{ matrix.suite }}" SHELL="${{ matrix.shell }}" URCHIN="$(npx which urchin)" test-${{ matrix.shell }} |       - run: make TERM=xterm-256color TEST_SUITE="${{ matrix.suite }}" SHELL="${{ matrix.shell }}" URCHIN="$(npx which urchin)" test-${{ matrix.shell }} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -87,11 +87,6 @@ env: | |||||||
|     - SHELL=bash TEST_SUITE=fast |     - SHELL=bash TEST_SUITE=fast | ||||||
|     - SHELL=zsh TEST_SUITE=fast |     - SHELL=zsh TEST_SUITE=fast | ||||||
|     #  - SHELL=ksh TEST_SUITE=fast |     #  - SHELL=ksh TEST_SUITE=fast | ||||||
|     - SHELL=sh TEST_SUITE=sourcing |  | ||||||
|     - SHELL=dash TEST_SUITE=sourcing |  | ||||||
|     - SHELL=bash TEST_SUITE=sourcing |  | ||||||
|     - SHELL=zsh TEST_SUITE=sourcing |  | ||||||
|     #  - SHELL=ksh TEST_SUITE=sourcing |  | ||||||
|     - SHELL=sh TEST_SUITE=slow |     - SHELL=sh TEST_SUITE=slow | ||||||
|     - SHELL=dash TEST_SUITE=slow |     - SHELL=dash TEST_SUITE=slow | ||||||
|     - SHELL=bash TEST_SUITE=slow |     - SHELL=bash TEST_SUITE=slow | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -43,7 +43,7 @@ $(SHELL_TARGETS): | |||||||
| 	@shell='$@'; shell=$${shell##*-}; \ | 	@shell='$@'; shell=$${shell##*-}; \ | ||||||
| 	which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \ | 	which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \ | ||||||
| 	printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \ | 	printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \ | ||||||
| 	[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \ | 	[ -z "$$TRAVIS_BUILD_DIR" ] && [ -z "$$GITHUB_ACTIONS" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \ | ||||||
| 	for suite in $(TEST_SUITE); do \ | 	for suite in $(TEST_SUITE); do \ | ||||||
| 		echo "Running test suite: $$suite"; \ | 		echo "Running test suite: $$suite"; \ | ||||||
| 		$(URCHIN) -f -s $$shell test/$$suite || exit; \ | 		$(URCHIN) -f -s $$shell test/$$suite || exit; \ | ||||||
|   | |||||||
| @@ -27,15 +27,15 @@ setup () { | |||||||
|   mkdir -p "$npm_config_prefix/lib" |   mkdir -p "$npm_config_prefix/lib" | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| setup | setup | ||||||
|  |  | ||||||
| npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package' | npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package' | ||||||
| message=$(nvm_check_global_modules) | message=$(nvm_check_global_modules) | ||||||
| [ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed; got:\n${message}" | [ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed; got:\n${message}" | ||||||
|  |  | ||||||
| if [ -n "${ORIGINAL_NVM_DIR}" ]; then | if [ -n "${ORIGINAL_NVM_DIR}" ] && [ -z "${GITHUB_ACTIONS}" ]; then | ||||||
|   # Admit we're using NVM, just for this one test |   # Admit we're using NVM, just for this one test | ||||||
|  |   # TODO: fix this for GHA | ||||||
|   message=$(NVM_DIR="${ORIGINAL_NVM_DIR}" nvm_check_global_modules) |   message=$(NVM_DIR="${ORIGINAL_NVM_DIR}" nvm_check_global_modules) | ||||||
|   [ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm; got:\n${message}" |   [ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm; got:\n${message}" | ||||||
| fi | fi | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
|  |  | ||||||
| die () { echo "$@" ; exit 1; } | die () { echo "$*" ; echo "|${NVM_DIR}|"; exit 1; } | ||||||
|  |  | ||||||
| echo '0.10.1' > ../../alias/default || die "couldn't create default alias" | echo '0.10.1' > ../../alias/default || die "couldn't create default alias" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,9 +12,7 @@ NVM_DIR_CACHED="${NVM_DIR}" | |||||||
| nvm unload || die 'unloading returned nonzero exit code' | nvm unload || die 'unloading returned nonzero exit code' | ||||||
| NVM_DIR="${NVM_DIR_CACHED}" | NVM_DIR="${NVM_DIR_CACHED}" | ||||||
|  |  | ||||||
| echo '0.10.1' > ../../alias/default || die 'creation of default alias failed' | echo '0.10.1' > "${NVM_DIR}/alias/default" || die 'creation of default alias failed' | ||||||
|  |  | ||||||
| which node && die 'node was found in PATH after unloading nvm' |  | ||||||
|  |  | ||||||
| # Now to begin the real test | # Now to begin the real test | ||||||
| \. ../../nvm.sh || die 'sourcing returned nonzero exit code' | \. ../../nvm.sh || die 'sourcing returned nonzero exit code' | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
|  |  | ||||||
| die () { echo "$@" ; exit 1; } | die () { echo "$*" ; echo "|${NVM_DIR}|"; exit 1; } | ||||||
|  |  | ||||||
| supports_source_options () { | supports_source_options () { | ||||||
|   [ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ] |   [ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ] | ||||||
| } | } | ||||||
| @@ -10,18 +11,23 @@ if ! supports_source_options; then | |||||||
|   exit 0; |   exit 0; | ||||||
| fi | fi | ||||||
|  |  | ||||||
| echo '0.10.2' > ../../.nvmrc || die 'creation of .nvmrc failed' | echo '0.10.2' > .nvmrc || die 'creation of .nvmrc failed' | ||||||
|  |  | ||||||
|  | export NVM_DIR="${PWD}/../.." | ||||||
|  | rm ../../alias/default | ||||||
|  |  | ||||||
| \. ../../nvm.sh --install | \. ../../nvm.sh --install | ||||||
| EXIT_CODE="$?" | EXIT_CODE="$?" | ||||||
|  |  | ||||||
| echo 'sourcing complete.' | echo 'sourcing complete.' | ||||||
|  |  | ||||||
| nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: \n$(nvm_ls)" |  | ||||||
|  |  | ||||||
| [ "_$(nvm_rc_version | \grep -o -e 'with version .*$')" = "_with version <0.10.2>" ] || die "nvm_rc_version $(nvm_rc_version)" | [ "_$(nvm_rc_version | \grep -o -e 'with version .*$')" = "_with version <0.10.2>" ] || die "nvm_rc_version $(nvm_rc_version)" | ||||||
|  |  | ||||||
|  | nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: \n$(nvm_ls)" | ||||||
|  |  | ||||||
| [ "_${EXIT_CODE}" = '_0' ] || die "sourcing returned nonzero exit code: ${EXIT_CODE}" | [ "_${EXIT_CODE}" = '_0' ] || die "sourcing returned nonzero exit code: ${EXIT_CODE}" | ||||||
|  |  | ||||||
| NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.2)" | NVM_LS_CURRENT="$(nvm ls current | \grep -o v0.10.2)" | ||||||
| [ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got >${NVM_LS_CURRENT}<\n$(nvm_ls)" | [ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got >${NVM_LS_CURRENT}<\n$(nvm_ls)" | ||||||
|  |  | ||||||
|  | rm .nvmrc | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
| \. ../common.sh | \. ../common.sh | ||||||
|  |  | ||||||
| die () { echo "$@" ; exit 1; } | die () { echo "$@" ; exit 1; } | ||||||
|  |  | ||||||
| supports_source_options () { | supports_source_options () { | ||||||
|   [ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ] |   [ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ] | ||||||
| } | } | ||||||
| @@ -11,6 +12,8 @@ if ! supports_source_options; then | |||||||
|   exit 0; |   exit 0; | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | rm .nvmrc | ||||||
|  | export NVM_DIR="${PWD}/../.." | ||||||
| echo '0.10.2' > ../../alias/default || die 'creation of default alias failed' | echo '0.10.2' > ../../alias/default || die 'creation of default alias failed' | ||||||
|  |  | ||||||
| echo 'sourcing nvm with --install...' | echo 'sourcing nvm with --install...' | ||||||
| @@ -20,6 +23,8 @@ EXIT_CODE="$?" | |||||||
|  |  | ||||||
| echo 'sourcing complete.' | echo 'sourcing complete.' | ||||||
|  |  | ||||||
|  | [ "$(nvm_alias default)" = '0.10.2' ] || die "nvm_alias default did not return '0.10.2', got >$(nvm_alias default)<" | ||||||
|  |  | ||||||
| nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: \n$(nvm_ls)" | nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: \n$(nvm_ls)" | ||||||
|  |  | ||||||
| [ "_$EXIT_CODE" = '_0' ] || die "sourcing returned nonzero exit code: ${EXIT_CODE}" | [ "_$EXIT_CODE" = '_0' ] || die "sourcing returned nonzero exit code: ${EXIT_CODE}" | ||||||
|   | |||||||
| @@ -4,4 +4,5 @@ rm -rf ../../alias | |||||||
| rm -rf ../../v0.10.1 | rm -rf ../../v0.10.1 | ||||||
| rm -rf ../../v0.10.2 | rm -rf ../../v0.10.2 | ||||||
| rm -rf ../../v0.10.3 | rm -rf ../../v0.10.3 | ||||||
|  | rm -rf ../../versions/node/v4.1.0 | ||||||
| rm -f ../../.nvmrc | rm -f ../../.nvmrc | ||||||
		Reference in New Issue
	
	Block a user