Compare commits

...
Author SHA1 Message Date
Zoltan Kochan fffe7742ec fix: preserve Windows Node shim detection 2026-11-03 15:09:03 +01:00
Zoltan Kochan a5f174cfd1 ci: limit test workflow token to read-only access 2026-11-03 15:00:54 +01:00
Zoltan Kochan 23c64316d8 test: invoke the resolved Windows executable extension 2026-11-03 14:57:58 +01:00
Zoltan Kochan e68a094b1a fix: preserve Windows command paths containing spaces 2026-11-03 14:55:12 +01:00
Danny MurphyandZoltan Kochan 73e46992e0 docs: clarify manifest-based version selection (#244)
* updating readme to include devEngines.packageManager.version in selecting version

* docs: check out the manifest before inferring pnpm version

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
2026-11-03 14:48:37 +01:00
Zoltan Kochan c05d46d6ff fix: skip saving missing cache directories (#294)
* fix: skip saving missing cache directories

* ci: run cache regression tests on Node.js 24
2026-11-03 14:40:50 +01:00
Andreas Deininger 343d2b1d95 Bump GitHub action workflows (#223) 2026-11-03 14:32:29 +01:00
8 changed files with 245 additions and 135 deletions
+9 -2
View File
@@ -13,14 +13,21 @@ jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
run_install: true
version: 11
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 24
- name: Test
run: pnpm test
- name: Update dist/index.js
run: pnpm run build
+52 -7
View File
@@ -7,6 +7,9 @@ on:
- master
workflow_dispatch:
permissions:
contents: read
jobs:
smoke:
# Cross-OS coverage. Exercises the bootstrap install + PATH on each platform,
@@ -51,7 +54,7 @@ jobs:
version: '12.3.4'
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- id: pnpm
name: Run the action
@@ -134,7 +137,7 @@ jobs:
expect_pm_on_fail_unset: true
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up package.json
run: echo '${{ matrix.manifest }}' > package.json
@@ -183,7 +186,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -234,7 +237,7 @@ jobs:
env:
REQUIRED: ${{ matrix.version }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
@@ -298,7 +301,7 @@ jobs:
name: 'Standalone Windows self-update (PATH regression)'
runs-on: windows-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up package.json with a minimal manifest
# run_install needs a manifest to install against. Removing the
@@ -356,7 +359,7 @@ jobs:
manifest: '{"devEngines":{"packageManager":{"name":"pnpm","version":">=10 <11"}},"dependencies":{"is-odd":"3.0.1"}}'
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up package.json
run: echo '${{ matrix.manifest }}' > package.json
@@ -400,7 +403,7 @@ jobs:
- yarn
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Run the action
uses: ./
@@ -419,3 +422,45 @@ jobs:
exit 1
fi
shell: bash
windows_dest_spaces:
name: 'Windows destination with spaces (${{ matrix.version }} / standalone=${{ matrix.standalone }})'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- version: '10.33.0'
standalone: false
- version: '11.25.0'
standalone: true
- version: '12.3.4'
standalone: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- id: pnpm
uses: ./
with:
version: ${{ matrix.version }}
standalone: ${{ matrix.standalone }}
dest: '${{ runner.temp }}/pnpm setup & tools'
- name: Verify PowerShell and bin_dest use the requested version
shell: pwsh
env:
EXPECTED_VERSION: ${{ matrix.version }}
BIN_DEST: ${{ steps.pnpm.outputs.bin_dest }}
run: |
$actual = pnpm --version
if ($LASTEXITCODE -ne 0 -or $actual -ne $env:EXPECTED_VERSION) {
throw "Expected $env:EXPECTED_VERSION on PATH, got $actual"
}
$command = Get-Command pnpm
$executable = Join-Path $env:BIN_DEST $command.Name
$actual = & $executable --version
if ($LASTEXITCODE -ne 0 -or $actual -ne $env:EXPECTED_VERSION) {
throw "Expected $env:EXPECTED_VERSION via bin_dest, got $actual"
}
$pnpx = Get-Command pnpx -ErrorAction Stop
if ((Split-Path -Parent $pnpx.Source) -ne $env:BIN_DEST) {
throw "pnpx resolves to $($pnpx.Source), expected under $env:BIN_DEST"
}
+3 -1
View File
@@ -64,7 +64,7 @@ Input and output changes:
Version of pnpm to install.
**Optional** when there is a [`packageManager` or `devEngines.packageManager` field in the `package.json`](https://nodejs.org/api/corepack.html).
**Optional** when `package.json` declares pnpm in `packageManager`, or sets `devEngines.packageManager.name` to `"pnpm"` and provides `devEngines.packageManager.version`.
otherwise, this field is **required** It supports npm versioning scheme, it could be an exact version (such as `10.9.8`), or a version range (such as `10`, `10.x.x`, `10.9.x`, `^10.9.8`, `*`, etc.), or `latest`.
@@ -157,6 +157,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v6
```
+115 -115
View File
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -4,7 +4,8 @@
"build:bundle": "esbuild src/index.ts --bundle --platform=node --target=node24 --format=cjs --minify --outfile=dist/index.js --loader:.json=json",
"build": "pnpm run build:bundle",
"start": "pnpm run build && sh ./run.sh",
"update-bootstrap": "node scripts/update-bootstrap.mjs"
"update-bootstrap": "node scripts/update-bootstrap.mjs",
"test": "node --experimental-test-module-mocks --test test/*.test.mjs"
},
"dependencies": {
"@actions/cache": "^4.1.0",
+12
View File
@@ -1,5 +1,6 @@
import { saveCache } from '@actions/cache'
import { getState, info } from '@actions/core'
import { access } from 'fs/promises'
export async function runSaveCache() {
const state = getState('cache_restored_key')
@@ -11,6 +12,17 @@ export async function runSaveCache() {
return
}
try {
await access(cachePath)
} catch (error) {
if (!(error instanceof Error)) throw error
if (!('code' in error)) throw error
if (error.code !== 'ENOENT') throw error
info(`Cache path ${cachePath} does not exist, not saving cache.`)
return
}
const cacheId = await saveCache([cachePath], primaryKey)
if (cacheId == -1) return
+4 -8
View File
@@ -1,4 +1,5 @@
import { addPath, exportVariable } from '@actions/core'
import { exec } from '@actions/exec'
import { spawn } from 'child_process'
import { rm, writeFile, mkdir, symlink } from 'fs/promises'
import { readFileSync, existsSync } from 'fs'
@@ -221,15 +222,10 @@ function getSystemNodeVersion(): Promise<{ major: number; minor: number }> {
}
function runCommand(cmd: string, args: string[], opts: { cwd: string; env?: Record<string, string | undefined> }): Promise<number> {
return new Promise<number>((resolve, reject) => {
const cp = spawn(cmd, args, {
return exec(`"${cmd}"`, args, {
cwd: opts.cwd,
env: opts.env,
stdio: ['pipe', 'inherit', 'inherit'],
shell: process.platform === 'win32',
})
cp.on('error', reject)
cp.on('close', resolve)
env: opts.env && Object.fromEntries(Object.entries(opts.env).filter((entry): entry is [string, string] => entry[1] !== undefined)),
ignoreReturnCode: true,
})
}
+47
View File
@@ -0,0 +1,47 @@
import assert from 'node:assert/strict'
import { mkdtemp, rm, access } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { after, beforeEach, mock, test } from 'node:test'
const directory = await mkdtemp(join(tmpdir(), 'pnpm-cache-save-'))
after(() => rm(directory, { recursive: true, force: true }))
let state
let checkAccess
const saveCache = mock.fn(async () => 1)
mock.module('@actions/cache', { namedExports: { saveCache } })
mock.module('@actions/core', {
namedExports: { getState: name => state[name], info: () => {} },
})
mock.module('fs/promises', { namedExports: { access: path => checkAccess(path) } })
const { runSaveCache } = await import('../src/cache-save/run.ts')
beforeEach(() => {
state = { cache_restored_key: 'old', cache_primary_key: 'new', cache_path: directory }
checkAccess = access
saveCache.mock.resetCalls()
})
test('skips saving a missing directory', async () => {
state.cache_path = join(directory, 'missing')
await runSaveCache()
assert.equal(saveCache.mock.callCount(), 0)
})
test('saves an existing directory with the primary key', async () => {
await runSaveCache()
assert.deepEqual(saveCache.mock.calls[0].arguments, [[directory], 'new'])
})
test('skips saving a primary-key cache hit', async () => {
state.cache_restored_key = 'new'
await runSaveCache()
assert.equal(saveCache.mock.callCount(), 0)
})
test('propagates unexpected filesystem errors', async () => {
const error = Object.assign(new Error('access denied'), { code: 'EACCES' })
checkAccess = async () => { throw error }
await assert.rejects(runSaveCache(), error)
assert.equal(saveCache.mock.callCount(), 0)
})