mirror of
https://github.com/pnpm/action-setup.git
synced 2026-05-08 01:48:28 +00:00
* fix: bin_dest output points to self-updated pnpm, not bootstrap (#247) `pnpm self-update <version>` writes the target binary to `${PNPM_HOME}/bin/`, leaving the bootstrap symlink at `${PNPM_HOME}/pnpm` untouched. The `bin_dest` output was set to `${PNPM_HOME}`, so consumers invoking `${{ steps.pnpm.outputs.bin_dest }}/pnpm` got the bootstrap version (currently 11.0.4) instead of the version they requested. PATH lookup hid the bug: `${PNPM_HOME}/bin` was prepended ahead of `${PNPM_HOME}`, so `pnpm` resolved from PATH was the right one. Existing version-respect tests only checked `pnpm --version`, not `bin_dest`. Resolve `binDest` inside `runSelfInstaller` (target lives in `${PNPM_HOME}/bin` after self-update, otherwise stays at `${PNPM_HOME}`) and plumb it through to `setOutputs`. Add a regression test that invokes `${bin_dest}/pnpm --version` directly across Linux/macOS/Windows. * test(ci): pass bin_dest via env to survive Windows backslashes Direct GitHub-expression interpolation of `${{ steps.pnpm.outputs.bin_dest }}` into the bash script let bash eat the backslashes in the Windows path (`C:Usersrunneradminsetup-pnpmnode_modules.binbin/pnpm`), failing with "No such file or directory". Forward the value via env so the path reaches bash unmangled. * build: rebuild dist with clean lockfile-matched deps
347 lines
9.0 KiB
YAML
347 lines
9.0 KiB
YAML
name: Test Action
|
|
|
|
on:
|
|
- push
|
|
- pull_request
|
|
- workflow_dispatch
|
|
|
|
jobs:
|
|
test_default_inputs:
|
|
name: Test with default inputs
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
pnpm:
|
|
- 9.15.5
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
with:
|
|
version: 9.15.5
|
|
|
|
- name: 'Test: which'
|
|
run: which pnpm; which pnpx
|
|
|
|
- name: 'Test: version'
|
|
run: |
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
echo "ERROR: pnpm --version did not produce valid output"
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
- name: 'Test: install in a fresh project'
|
|
run: |
|
|
mkdir /tmp/test-project
|
|
cd /tmp/test-project
|
|
pnpm init
|
|
pnpm add is-odd
|
|
shell: bash
|
|
|
|
test_dest:
|
|
name: Test with dest
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
pnpm:
|
|
- 9.15.5
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
with:
|
|
version: 9.15.5
|
|
dest: ~/test/pnpm
|
|
|
|
- name: 'Test: which'
|
|
run: which pnpm && which pnpx
|
|
|
|
- name: 'Test: version'
|
|
run: |
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
echo "ERROR: pnpm --version did not produce valid output"
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
test_standalone:
|
|
name: Test with standalone
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- windows-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
with:
|
|
version: 9.15.0
|
|
standalone: true
|
|
|
|
- name: 'Test: which'
|
|
run: which pnpm
|
|
|
|
- name: 'Test: version'
|
|
run: |
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
echo "ERROR: pnpm --version did not produce valid output"
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
- name: 'Test: install in a fresh project'
|
|
run: |
|
|
mkdir /tmp/test-standalone
|
|
cd /tmp/test-standalone
|
|
pnpm init
|
|
pnpm add is-odd
|
|
shell: bash
|
|
|
|
test_version_respects_request:
|
|
name: 'Test version input is actually installed (${{ matrix.version }}, ${{ matrix.os }})'
|
|
# Regression test for #225 / #230: the bootstrap pnpm on PATH was shadowing the self-updated binary,
|
|
# so a user requesting e.g. `version: 9.15.5` would silently get the bootstrap version.
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
version:
|
|
- '9.15.5'
|
|
- '10.33.0'
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
with:
|
|
version: ${{ matrix.version }}
|
|
|
|
- name: 'Test: exact version installed'
|
|
run: |
|
|
required='${{ matrix.version }}'
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
if [ "${actual}" != "${required}" ]; then
|
|
echo "Expected pnpm version ${required}, but got ${actual}"
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
test_bin_dest_output:
|
|
name: 'Test bin_dest output points to requested version (${{ matrix.version }}, ${{ matrix.os }})'
|
|
# Regression test for #247: invoking pnpm via the `bin_dest` output returned the
|
|
# bootstrap version because self-update writes the target to `${bin_dest}/bin/`,
|
|
# not directly into `${bin_dest}/`.
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
version:
|
|
- '9.15.5'
|
|
- '10.33.2'
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- id: pnpm
|
|
name: Run the action
|
|
uses: ./
|
|
with:
|
|
version: ${{ matrix.version }}
|
|
|
|
- name: 'Test: bin_dest/pnpm reports requested version'
|
|
# Pass paths via env, not template interpolation, so Windows
|
|
# backslashes in `bin_dest` aren't eaten by bash's escape handling.
|
|
env:
|
|
BIN_DEST: ${{ steps.pnpm.outputs.bin_dest }}
|
|
REQUIRED: ${{ matrix.version }}
|
|
run: |
|
|
actual="$("$BIN_DEST/pnpm" --version)"
|
|
echo "pnpm version via bin_dest: ${actual}"
|
|
if [ "${actual}" != "${REQUIRED}" ]; then
|
|
echo "Expected pnpm version ${REQUIRED}, but got ${actual}"
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
test_package_manager_field:
|
|
name: 'Test packageManager field is respected (${{ matrix.version }}, ${{ matrix.os }})'
|
|
# Reproduces #227: when `packageManager` is set in package.json and no `version:` input is given,
|
|
# the action should install the version specified there.
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
version:
|
|
- '9.15.5'
|
|
- '10.33.0'
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Set up package.json with packageManager field
|
|
run: echo '{"packageManager":"pnpm@${{ matrix.version }}"}' > package.json
|
|
shell: bash
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
|
|
- name: 'Test: exact version installed'
|
|
run: |
|
|
required='${{ matrix.version }}'
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
if [ "${actual}" != "${required}" ]; then
|
|
echo "Expected pnpm version ${required}, but got ${actual}"
|
|
exit 1
|
|
fi
|
|
shell: bash
|
|
|
|
test_dev_engines:
|
|
name: Test with devEngines.packageManager
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
version:
|
|
- '9.15.5'
|
|
- '>=9.15.0'
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Set up package.json with devEngines.packageManager
|
|
run: echo '{"devEngines":{"packageManager":{"name":"pnpm","version":"${{ matrix.version }}","onFail":"download"}}}' > package.json
|
|
shell: bash
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
|
|
- name: 'Test: which'
|
|
run: which pnpm; which pnpx
|
|
|
|
- name: 'Test: version'
|
|
run: |
|
|
set -e
|
|
required='${{ matrix.version }}'
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
|
|
if [ "${required}" = ">=9.15.0" ]; then
|
|
min="9.15.0"
|
|
if [ "$(printf '%s\n' "${min}" "${actual}" | sort -V | head -n1)" != "${min}" ]; then
|
|
echo "Expected pnpm version >= ${min}, but got ${actual}"
|
|
exit 1
|
|
fi
|
|
else
|
|
if [ "${actual}" != "${required}" ]; then
|
|
echo "Expected pnpm version ${required}, but got ${actual}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
shell: bash
|
|
|
|
test_run_install:
|
|
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
pnpm:
|
|
- 9.15.5
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
run_install:
|
|
- name: 'null'
|
|
value: 'null'
|
|
- name: 'global'
|
|
value: |
|
|
args:
|
|
- --global
|
|
- --global-dir=./pnpm-global
|
|
- npm
|
|
- yarn
|
|
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
|
|
- name: Run the action
|
|
uses: ./
|
|
with:
|
|
version: 9.15.5
|
|
run_install: ${{ matrix.run_install.value }}
|
|
|
|
- name: 'Test: which'
|
|
run: which pnpm; which pnpx
|
|
|
|
- name: 'Test: version'
|
|
run: |
|
|
actual="$(pnpm --version)"
|
|
echo "pnpm version: ${actual}"
|
|
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
echo "ERROR: pnpm --version did not produce valid output"
|
|
exit 1
|
|
fi
|
|
shell: bash
|