Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .github/workflows/nvm-install-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ jobs:
with:
fetch-depth: 0
- id: matrix
env:
EVENT_NAME: ${{ github.event_name }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github provides the event name, so there's no point in hardening its usage

INPUT_REF: ${{ github.event.inputs.ref }}
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.ref }}" ]; then
echo "matrix=\"[\"${{ github.event.inputs.ref }}\"]\"" >> $GITHUB_OUTPUT
if [ "$EVENT_NAME" == "workflow_dispatch" ] && [ -n "$INPUT_REF" ]; then
echo "matrix=\"[\"$INPUT_REF\"]\"" >> $GITHUB_OUTPUT
else
TAGS="$((echo "HEAD" && git tag --sort=-v:refname --merged HEAD --format='%(refname:strip=2) %(creatordate:short)' | grep '^v' | while read tag date; do
if [ "$(uname)" == "Darwin" ]; then
Expand Down Expand Up @@ -57,14 +60,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: resolve HEAD to sha
env:
MATRIX_REF: ${{ matrix.ref }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the fix on line 28 is applied, is this needed at all?

run: |
if [ '${{ matrix.ref }}' = 'HEAD' ]; then
if [ "$MATRIX_REF" = 'HEAD' ]; then
REF="$(git rev-parse HEAD)"
else
REF="${{ matrix.ref }}"
REF="$MATRIX_REF"
fi
echo "resolved ref: ${REF}"
echo "ref="$REF"" >> $GITHUB_ENV
echo "ref=$REF" >> $GITHUB_ENV
- run: echo $- # which options are set
- run: echo node > .nvmrc
if: ${{ matrix.has-nvmrc == 'nvmrc' }}
Expand All @@ -80,18 +85,22 @@ jobs:
. $NVM_DIR/nvm.sh && nvm --version
- name: nvm install in 1 shell level, ${{ matrix.has-nvmrc }}
if: ${{ matrix.shell-level == '1 shlvl' }}
env:
HAS_NVMRC: ${{ matrix.has-nvmrc }}
run: |
set -ex
. $NVM_DIR/nvm.sh
echo nvm.sh sourced
nvm --version
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
if [ "$HAS_NVMRC" == 'nvmrc' ]; then
nvm install
fi
- name: nvm install in 2 shell levels, ${{ matrix.has-nvmrc }}
if: ${{ matrix.shell-level == '2 shlvls' }}
env:
HAS_NVMRC: ${{ matrix.has-nvmrc }}
run: |
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
if [ "$HAS_NVMRC" == 'nvmrc' ]; then
Comment on lines +88 to +103
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these items are hardcoded in the matrix, so there's no need to make this change

bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version && nvm install"
else
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version"
Expand Down