3232 - name : ' Test: which'
3333 run : which pnpm; which pnpx
3434
35- - name : ' Test: install'
36- run : pnpm install
35+ - name : ' Test: version'
36+ run : |
37+ actual="$(pnpm --version)"
38+ echo "pnpm version: ${actual}"
39+ if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
40+ echo "ERROR: pnpm --version did not produce valid output"
41+ exit 1
42+ fi
43+ shell : bash
44+
45+ - name : ' Test: install in a fresh project'
46+ run : |
47+ mkdir /tmp/test-project
48+ cd /tmp/test-project
49+ pnpm init
50+ pnpm add is-odd
51+ shell : bash
3752
3853 test_dest :
3954 name : Test with dest
6277 - name : ' Test: which'
6378 run : which pnpm && which pnpx
6479
65- - name : ' Test: install'
66- run : pnpm install
80+ - name : ' Test: version'
81+ run : |
82+ actual="$(pnpm --version)"
83+ echo "pnpm version: ${actual}"
84+ if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
85+ echo "ERROR: pnpm --version did not produce valid output"
86+ exit 1
87+ fi
88+ shell : bash
6789
6890 test_standalone :
6991 name : Test with standalone
@@ -74,51 +96,88 @@ jobs:
7496 fail-fast : false
7597 matrix :
7698 os :
77- # macos is excluded from this test because node 12 is no longer available on this platform
7899 - ubuntu-latest
79100 - windows-latest
80101
81- standalone :
82- - true
83- - false
84-
85102 steps :
86103 - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
87104
88105 - name : Run the action
89106 uses : ./
90107 with :
91108 version : 9.15.0
92- standalone : ${{ matrix.standalone }}
93-
94- - name : install Node.js
95- uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
96- with :
97- # pnpm@7.0.0 is not compatible with Node.js 12
98- node-version : 12.22.12
109+ standalone : true
99110
100- - name : ' Test: which (pnpm) '
111+ - name : ' Test: which'
101112 run : which pnpm
102113
103- - name : ' Test: which (pnpx)'
104- if : matrix.standalone == false
105- run : which pnpx
114+ - name : ' Test: version'
115+ run : |
116+ actual="$(pnpm --version)"
117+ echo "pnpm version: ${actual}"
118+ if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
119+ echo "ERROR: pnpm --version did not produce valid output"
120+ exit 1
121+ fi
122+ shell : bash
123+
124+ - name : ' Test: install in a fresh project'
125+ run : |
126+ mkdir /tmp/test-standalone
127+ cd /tmp/test-standalone
128+ pnpm init
129+ pnpm add is-odd
130+ shell : bash
131+
132+ test_dev_engines :
133+ name : Test with devEngines.packageManager
134+
135+ runs-on : ${{ matrix.os }}
136+
137+ strategy :
138+ fail-fast : false
139+ matrix :
140+ os :
141+ - ubuntu-latest
142+ - macos-latest
143+ - windows-latest
144+ version :
145+ - ' 9.15.5'
146+ - ' >=9.15.0'
106147
107- - name : ' Test: install when standalone is true'
108- if : matrix.standalone
109- run : pnpm install
148+ steps :
149+ - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
110150
111- - name : ' Test: install when standalone is false'
112- if : matrix.standalone == false
113- # Since the default shell on windows runner is pwsh, we specify bash explicitly
151+ - name : Set up package.json with devEngines.packageManager
152+ run : echo '{"devEngines":{"packageManager":{"name":"pnpm","version":"${{ matrix.version }}","onFail":"download"}}}' > package.json
114153 shell : bash
154+
155+ - name : Run the action
156+ uses : ./
157+
158+ - name : ' Test: which'
159+ run : which pnpm; which pnpx
160+
161+ - name : ' Test: version'
115162 run : |
116- if pnpm install; then
117- echo "pnpm install should fail"
118- exit 1
163+ set -e
164+ required='${{ matrix.version }}'
165+ actual="$(pnpm --version)"
166+ echo "pnpm version: ${actual}"
167+
168+ if [ "${required}" = ">=9.15.0" ]; then
169+ min="9.15.0"
170+ if [ "$(printf '%s\n' "${min}" "${actual}" | sort -V | head -n1)" != "${min}" ]; then
171+ echo "Expected pnpm version >= ${min}, but got ${actual}"
172+ exit 1
173+ fi
119174 else
120- echo "pnpm install failed as expected"
175+ if [ "${actual}" != "${required}" ]; then
176+ echo "Expected pnpm version ${required}, but got ${actual}"
177+ exit 1
178+ fi
121179 fi
180+ shell : bash
122181
123182 test_run_install :
124183 name : ' Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
@@ -137,27 +196,13 @@ jobs:
137196 run_install :
138197 - name : ' null'
139198 value : ' null'
140- - name : ' empty object'
141- value : ' {}'
142- - name : ' recursive'
143- value : |
144- recursive: true
145199 - name : ' global'
146200 value : |
147201 args:
148202 - --global
149203 - --global-dir=./pnpm-global
150204 - npm
151205 - yarn
152- - name : ' array'
153- value : |
154- - {}
155- - recursive: true
156- - args:
157- - --global
158- - --global-dir=./pnpm-global
159- - npm
160- - yarn
161206
162207 steps :
163208 - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
@@ -171,5 +216,12 @@ jobs:
171216 - name : ' Test: which'
172217 run : which pnpm; which pnpx
173218
174- - name : ' Test: install'
175- run : pnpm install
219+ - name : ' Test: version'
220+ run : |
221+ actual="$(pnpm --version)"
222+ echo "pnpm version: ${actual}"
223+ if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
224+ echo "ERROR: pnpm --version did not produce valid output"
225+ exit 1
226+ fi
227+ shell : bash
0 commit comments