Skip to content

Commit c320937

Browse files
committed
Merge branch 'master' into fix/skip-install-if-existing
2 parents 29985b1 + 6b87c46 commit c320937

File tree

17 files changed

+1134
-237569
lines changed

17 files changed

+1134
-237569
lines changed

.github/workflows/pr-check.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: pr-check
2+
3+
on: [ pull_request ]
4+
5+
permissions:
6+
contents: read
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
check-dist:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
20+
with:
21+
run_install: true
22+
version: 9
23+
24+
- name: Update dist/index.js
25+
run: pnpm run build
26+
27+
- name: Check for uncommitted changes in dist
28+
run: git diff --exit-code dist/index.js

.github/workflows/test.yaml

Lines changed: 98 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,23 @@ jobs:
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
@@ -62,8 +77,15 @@ jobs:
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

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ node_modules
22
*.log
33
/dist/*
44
!/dist/index.js
5-
!/dist/pnpm.cjs
6-
!/dist/worker.js
75
tmp
86
temp
97
*.tmp

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
runs-on: ubuntu-latest
8787

8888
steps:
89-
- uses: pnpm/action-setup@v4
89+
- uses: pnpm/action-setup@v5
9090
with:
9191
version: 10
9292
```
@@ -105,7 +105,7 @@ jobs:
105105
runs-on: ubuntu-latest
106106
107107
steps:
108-
- uses: pnpm/action-setup@v4
108+
- uses: pnpm/action-setup@v5
109109
```
110110

111111
### Install pnpm and a few npm packages
@@ -122,7 +122,7 @@ jobs:
122122
steps:
123123
- uses: actions/checkout@v4
124124
125-
- uses: pnpm/action-setup@v4
125+
- uses: pnpm/action-setup@v5
126126
with:
127127
version: 10
128128
run_install: |
@@ -146,7 +146,7 @@ jobs:
146146
- name: Checkout
147147
uses: actions/checkout@v4
148148
149-
- uses: pnpm/action-setup@v4
149+
- uses: pnpm/action-setup@v5
150150
name: Install pnpm
151151
with:
152152
version: 10

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ outputs:
3737
bin_dest:
3838
description: Location of `pnpm` and `pnpx` command
3939
runs:
40-
using: node20
40+
using: node24
4141
main: dist/index.js
4242
post: dist/index.js

dist/index.js

Lines changed: 289 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)