Visitar URL original
fix: restore inputs from state in post by haines · Pull Request #255 · pnpm/action-setup · GitHub
Skip to content

fix: restore inputs from state in post - #255

Merged
zkochan merged 1 commit into
pnpm:masterfrom
haines:fix-inputs
May 11, 2026
Merged

zkochan merged 1 commit into
pnpm:masterfrom
haines:fix-inputs

Conversation

@haines

@haines haines commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #253

Summary by CodeRabbit

  • Refactor
    • Improved the action's internal lifecycle management with better separation of main and post step execution flows, enhancing state management for more reliable pnpm setup and caching operations.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The action entrypoint is refactored to use GitHub Action state (saveState/getState) to persist inputs between the main and post-cleanup steps, fixing issues when the action runs via a composite action. The dispatcher routes based on stored state instead of function arguments, runMain() derives and saves inputs, and runPost() reconstructs them for cleanup.

Changes

State-based input persistence for GitHub Action post step

Layer / File(s) Summary
Main dispatcher routing
src/index.ts
main() now invokes runPost() or runMain() without arguments, using getState('is_post') to determine which path to execute.
Main step with input persistence
src/index.ts
runMain() takes no parameters; it creates inputs via getInputs(), persists them to action state with saveState('inputs', JSON.stringify(inputs)), sets is_post to 'true', then runs the install sequence and cache restore.
Post step with input reconstruction
src/index.ts
New runPost() function reconstructs inputs from persisted action state via JSON.parse(getState('inputs')), then executes pruneStore(inputs) and saveCache(inputs) for cleanup.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A rabbit hops through the state, storing inputs for later fate,
No more mixed-up args in the post-action stage,
With saveState and getState upon the page,
Composite actions now work great! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: restoring inputs from state in the post step, which directly addresses the core fix for issue #253.
Linked Issues check ✅ Passed The PR implementation directly addresses the root causes identified in issue #253: inputs are now persisted via saveState() in main and restored from STATE in post, fixing the composite-action input-loss issue.
Out of Scope Changes check ✅ Passed All changes in src/index.ts are scoped to refactoring the control flow to persist and restore inputs via GitHub Action state, which is directly required by issue #253.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/index.ts`:
- Line 34: The code unconditionally calls JSON.parse(getState('inputs')) when
assigning const inputs in src/index.ts, which can throw if getState('inputs') is
missing/empty/corrupted; wrap the retrieval and parse in a safe guard: read
const raw = getState('inputs'), check raw is truthy before parsing, and/or parse
inside a try/catch that falls back to a safe default (e.g., undefined or an
empty Inputs-like object) and logs the parse error, so the post-cleanup path
(and the rest of the process) cannot be interrupted by JSON.parse; update the
assignment of inputs accordingly to use the guarded value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86c3a3df-8941-4d0f-80fb-43dd0041dfb5

📥 Commits

Reviewing files that changed from the base of the PR and between 1155470 and 496058d.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/index.ts
📜 Review details
🔇 Additional comments (2)
src/index.ts (2)

11-15: Good post/main dispatch split.

Using getState('is_post') to route between phases is clear and matches the intended GitHub Action lifecycle fix.


18-21: Good: inputs are persisted before main work starts.

Saving inputs up front reduces drift risk between main and post, especially for composite-action invocations.

Comment thread src/index.ts Resolved
@zkochan
zkochan merged commit 7a5507b into pnpm:master May 11, 2026
17 checks passed
@haines
haines deleted the fix-inputs branch May 11, 2026 10:50
dbmikus pushed a commit to gofixpoint/amika that referenced this pull request Oct 23, 2026
Bumps [pnpm/action-setup](https://github.com/pnpm/action-setup) from 5.0.0 to 6.1.0.

## Release notes

Sourced from pnpm/action-setup's releases.

### v6.1.0

### What's Changed
- feat: support pnpm v12 by `@zkochan` in pnpm/action-setup#288

Full Changelog: pnpm/action-setup@v6.0.10...v6.1.0

### v6.0.10

### What's Changed
- docs(README): point users to the successor pnpm/setup action by `@BlackHole1` in pnpm/action-setup#282
- refactor: introduce restore keys for cache by `@SukkaW` in pnpm/action-setup#280
- ci: use pnpm 11 for `pr-check` by `@jamietanna` in pnpm/action-setup#284
- fix: update pnpm to v11.19.0 by `@jamietanna` in pnpm/action-setup#283
- docs: update README to include devEngines.packageManager by `@nemchik` in pnpm/action-setup#273

### New Contributors
- `@jamietanna` made their first contribution in pnpm/action-setup#284
- `@nemchik` made their first contribution in pnpm/action-setup#273

Full Changelog: pnpm/action-setup@v6...v6.0.10

### v6.0.9

### What's Changed
- fix: update pnpm to v11.7.0 by `@zkochan` in pnpm/action-setup#267

Full Changelog: pnpm/action-setup@v6...v6.0.9

### v6.0.8

### What's Changed
- docs(README): fix `cache_dependency_path` type by `@haines` in pnpm/action-setup#257
- fix: drop patchPnpmEnv so standalone+self-update works on Windows by `@zkochan` in pnpm/action-setup#258
- fix: update pnpm to 11.1.1 by `@mungodewar` in pnpm/action-setup#248

### New Contributors
- `@mungodewar` made their first contribution in pnpm/action-setup#248

Full Changelog: pnpm/action-setup@v6.0.7...v6.0.8

### v6.0.7

### What's Changed
- fix: honor devEngines.packageManager.onFail=error (#252) by `@zkochan` in pnpm/action-setup#254
- fix: restore inputs from state in post by `@haines` in pnpm/action-setup#255
- fix: self-update bootstrap to packageManager-pinned version (#233) by `@zkochan` in pnpm/action-setup#256

### New Contributors
- `@haines` made their first contribution in pnpm/action-setup#255

Full Changelog: pnpm/action-setup@v6.0.6...v6.0.7

... (truncated)

## Commits
- `ea17c68` feat: support pnpm v12 (#288)
- `0977fd9` docs: Update README to include devEngines.packageManager (#273)
- `48261ac` fix: update pnpm to v11.19.0 (#283)
- `75677f7` ci: use pnpm 11 for `pr-check` (#284)
- `769ae71` refactor: introduce restore keys for cache (#280)
- `6fed91f` docs(README): point users to the successor pnpm/setup action (#282)
- `0ebf471` fix: update pnpm to v11.7.0 (#267)
- `0e279bb` fix: update pnpm to 11.1.1 (#248)
- `3e83581` fix: drop patchPnpmEnv so standalone+self-update works on Windows (#258)
- `551b42e` docs(README): fix `cache_dependency_path` type (#257)
- Additional commits viewable in compare view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors in post-install when called via composite action

2 participants