mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-07-18 12:58:21 +08:00
[actions] nvm-install-test: turn the expected v0.40.0 failures green
The two `v0.40.0` + `nvmrc` jobs fail by design (https://github.com/nvm-sh/nvm/issues/3405), but job-level `continue-on-error` still displays them as failures on every run, which reads like the contributor broke something. Tolerate failure only in the steps that exercise the bug, scoped to that matrix combination, and add a final step that fails the job when the expected failure did not happen - so those jobs are green exactly when v0.40.0 misbehaves as documented, and turn red as a signal to remove this handling if v0.40.0 ever starts passing. This also restores strict failure semantics to the passing `v0.40.0` + `no nvmrc` jobs, which the job-level `continue-on-error` was needlessly masking.
This commit is contained in:
@@ -49,7 +49,6 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
needs: [matrix]
|
needs: [matrix]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
continue-on-error: ${{ matrix.ref == 'v0.40.0' }} # https://github.com/nvm-sh/nvm/issues/3405
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -81,12 +80,19 @@ jobs:
|
|||||||
set -e
|
set -e
|
||||||
export NVM_INSTALL_VERSION="${ref}"
|
export NVM_INSTALL_VERSION="${ref}"
|
||||||
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${ref}/install.sh" | bash
|
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${ref}/install.sh" | bash
|
||||||
|
# v0.40.0 with an .nvmrc present is expected to fail (https://github.com/nvm-sh/nvm/issues/3405):
|
||||||
|
# the steps below tolerate failure for that combination, and the final step
|
||||||
|
# turns the job red only if the expected failure did NOT happen.
|
||||||
- name: nvm --version
|
- name: nvm --version
|
||||||
|
id: nvm-version
|
||||||
|
continue-on-error: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}
|
||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
. $NVM_DIR/nvm.sh && nvm --version
|
. $NVM_DIR/nvm.sh && nvm --version
|
||||||
- name: nvm install in 1 shell level, ${{ matrix.has-nvmrc }}
|
- name: nvm install in 1 shell level, ${{ matrix.has-nvmrc }}
|
||||||
|
id: install-1
|
||||||
if: ${{ matrix.shell-level == '1 shlvl' }}
|
if: ${{ matrix.shell-level == '1 shlvl' }}
|
||||||
|
continue-on-error: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}
|
||||||
run: |
|
run: |
|
||||||
set -ex
|
set -ex
|
||||||
. $NVM_DIR/nvm.sh
|
. $NVM_DIR/nvm.sh
|
||||||
@@ -96,13 +102,29 @@ jobs:
|
|||||||
nvm install
|
nvm install
|
||||||
fi
|
fi
|
||||||
- name: nvm install in 2 shell levels, ${{ matrix.has-nvmrc }}
|
- name: nvm install in 2 shell levels, ${{ matrix.has-nvmrc }}
|
||||||
|
id: install-2
|
||||||
if: ${{ matrix.shell-level == '2 shlvls' }}
|
if: ${{ matrix.shell-level == '2 shlvls' }}
|
||||||
|
continue-on-error: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}
|
||||||
run: |
|
run: |
|
||||||
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
|
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
|
||||||
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version && nvm install"
|
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version && nvm install"
|
||||||
else
|
else
|
||||||
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version"
|
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version"
|
||||||
fi
|
fi
|
||||||
|
- name: 'confirm the expected failure happened (v0.40.0 + nvmrc)'
|
||||||
|
if: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}
|
||||||
|
env:
|
||||||
|
SOURCE_OUTCOME: ${{ steps.nvm-version.outcome }}
|
||||||
|
INSTALL_1_OUTCOME: ${{ steps.install-1.outcome }}
|
||||||
|
INSTALL_2_OUTCOME: ${{ steps.install-2.outcome }}
|
||||||
|
run: |
|
||||||
|
echo "nvm --version: ${SOURCE_OUTCOME}; install (1 shlvl): ${INSTALL_1_OUTCOME}; install (2 shlvls): ${INSTALL_2_OUTCOME}"
|
||||||
|
if [ "${SOURCE_OUTCOME}" = 'failure' ] || [ "${INSTALL_1_OUTCOME}" = 'failure' ] || [ "${INSTALL_2_OUTCOME}" = 'failure' ]; then
|
||||||
|
echo 'v0.40.0 failed as expected: https://github.com/nvm-sh/nvm/issues/3405'
|
||||||
|
else
|
||||||
|
echo '::error::v0.40.0 with an .nvmrc was expected to fail (https://github.com/nvm-sh/nvm/issues/3405), but every step succeeded. If v0.40.0 somehow works now, remove the expected-failure handling from this workflow.'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
finisher:
|
finisher:
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
Reference in New Issue
Block a user