Skip to content
Myr

nvm-install-test.yml

This file

Path

.github/workflows/nvm-install-test.yml

135 lines · 4.9 KiB · YAML

Last changed by

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

History of this file

Take it

The walk stopped after 200 commits: lines older than 5c12680 point at it.

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 1–12why, one step back
1name: 'Tests: nvm install with set -e'
23on:4 pull_request:5 push:6 workflow_dispatch:7 inputs:8 ref:9 description: 'git ref to use'10 required: false11 default: 'HEAD'12

[actions] add permissions to GHA workflowJordan Harbandbefore adoption242d997

lines 13–15why, one step back
13permissions:
14 contents: read15

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 16–17why, one step back
16jobs:
17 matrix:

[actions] set per-job permissions in the `nvm install` workflowJordan Harbandbefore adoption16f6ddc

lines 18–19why, one step back
18 permissions:
19 contents: read

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 20–23why, one step back
20 runs-on: ubuntu-latest
21 outputs:22 matrix: ${{ steps.matrix.outputs.matrix }}23 steps:

[actions] update outdated GitHub Actions versionsPadraic Slatterybefore adoption34d6d5d

line 24why, one step back
24 - uses: actions/checkout@v6

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 25–47why, one step back
25 with:
26 fetch-depth: 027 - id: matrix28 run: |29 if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.ref }}" ]; then30 echo "matrix=\"[\"${{ github.event.inputs.ref }}\"]\"" >> $GITHUB_OUTPUT31 else32 TAGS="$((echo "HEAD" && git tag --sort=-v:refname --merged HEAD --format='%(refname:strip=2) %(creatordate:short)' | grep '^v' | while read tag date; do33 if [ "$(uname)" == "Darwin" ]; then34 timestamp=$(date -j -f "%Y-%m-%d" "$date" +%s)35 threshold=$(date -j -v-4y +%s)36 else37 timestamp=$(date -d "$date" +%s)38 threshold=$(date -d "4 years ago" +%s)39 fi40 if [ $timestamp -ge $threshold ]; then echo "$tag"; fi41 done) | xargs)"42 echo $TAGS43 TAGS_JSON=$(printf "%s\n" $TAGS | jq -R . | jq -sc .)44 echo "matrix=${TAGS_JSON}" >> $GITHUB_OUTPUT45 fi4647 test:

[actions] set per-job permissions in the `nvm install` workflowJordan Harbandbefore adoption16f6ddc

lines 48–49why, one step back
48 permissions:
49 contents: read

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 50–63why, one step back
50 needs: [matrix]
51 runs-on: ubuntu-latest52 strategy:53 fail-fast: false54 matrix:55 ref: ${{ fromJson(needs.matrix.outputs.matrix) }}56 has-nvmrc:57 - 'no nvmrc'58 - 'nvmrc'59 shell-level:60 - 1 shlvl61 - 2 shlvls6263 steps:

[actions] update outdated GitHub Actions versionsPadraic Slatterybefore adoption34d6d5d

line 64why, one step back
64 - uses: actions/checkout@v6

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 65–82why, one step back
65 - name: resolve HEAD to sha
66 run: |67 if [ '${{ matrix.ref }}' = 'HEAD' ]; then68 REF="$(git rev-parse HEAD)"69 else70 REF="${{ matrix.ref }}"71 fi72 echo "resolved ref: ${REF}"73 echo "ref="$REF"" >> $GITHUB_ENV74 - run: echo $- # which options are set75 - run: echo node > .nvmrc76 if: ${{ matrix.has-nvmrc == 'nvmrc' }}77 - run: curl -I --compressed -v https://nodejs.org/dist/78 - name: 'install nvm'79 run: |80 set -e81 export NVM_INSTALL_VERSION="${ref}"82 curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${ref}/install.sh" | bash

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

lines 83–85why, one step back
83 # v0.40.0 with an .nvmrc present is expected to fail (https://github.com/nvm-sh/nvm/issues/3405):
84 # the steps below tolerate failure for that combination, and the final step85 # turns the job red only if the expected failure did NOT happen.

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

line 86why, one step back
86 - name: nvm --version

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

lines 87–88why, one step back
87 id: nvm-version
88 continue-on-error: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 89–92why, one step back
89 run: |
90 set +e91 . $NVM_DIR/nvm.sh && nvm --version92 - name: nvm install in 1 shell level, ${{ matrix.has-nvmrc }}

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

line 93why, one step back
93 id: install-1

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

line 94why, one step back
94 if: ${{ matrix.shell-level == '1 shlvl' }}

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

line 95why, one step back
95 continue-on-error: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 96–104why, one step back
96 run: |
97 set -ex98 . $NVM_DIR/nvm.sh99 echo nvm.sh sourced100 nvm --version101 if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then102 nvm install103 fi104 - name: nvm install in 2 shell levels, ${{ matrix.has-nvmrc }}

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

line 105why, one step back
105 id: install-2

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

line 106why, one step back
106 if: ${{ matrix.shell-level == '2 shlvls' }}

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

line 107why, one step back
107 continue-on-error: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 108–112why, one step back
108 run: |
109 if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then110 bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version && nvm install"111 else112 bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version"

[actions] `nvm-install-test`: turn the expected v0.40.0 failures greenJordan Harbandbefore adoption59cf9a4

lines 113–126why, one step back
113 fi
114 - name: 'confirm the expected failure happened (v0.40.0 + nvmrc)'115 if: ${{ matrix.ref == 'v0.40.0' && matrix.has-nvmrc == 'nvmrc' }}116 env:117 SOURCE_OUTCOME: ${{ steps.nvm-version.outcome }}118 INSTALL_1_OUTCOME: ${{ steps.install-1.outcome }}119 INSTALL_2_OUTCOME: ${{ steps.install-2.outcome }}120 run: |121 echo "nvm --version: ${SOURCE_OUTCOME}; install (1 shlvl): ${INSTALL_1_OUTCOME}; install (2 shlvls): ${INSTALL_2_OUTCOME}"122 if [ "${SOURCE_OUTCOME}" = 'failure' ] || [ "${INSTALL_1_OUTCOME}" = 'failure' ] || [ "${INSTALL_2_OUTCOME}" = 'failure' ]; then123 echo 'v0.40.0 failed as expected: https://github.com/nvm-sh/nvm/issues/3405'124 else125 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.'126 exit 1

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 127–129why, one step back
127 fi
128129 finisher:

[actions] set per-job permissions in the `nvm install` workflowJordan Harbandbefore adoption16f6ddc

lines 130–131why, one step back
130 permissions:
131 contents: none

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 132–135why, one step back
132 runs-on: ubuntu-latest
133 needs: [test]134 steps:135 - run: true