Skip to content

fix: refresh ignored builds when allowBuilds changes#11366

Merged
zkochan merged 3 commits into
pnpm:mainfrom
KimHyeongRae0:fix/10528-allow-builds-state
May 5, 2026
Merged

fix: refresh ignored builds when allowBuilds changes#11366
zkochan merged 3 commits into
pnpm:mainfrom
KimHyeongRae0:fix/10528-allow-builds-state

Conversation

@KimHyeongRae0

@KimHyeongRae0 KimHyeongRae0 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closes #10528.

Summary: tracks allowBuilds in workspace state and clears explicitly denied ignored builds.

Tests: compile, workspace.state, deps.status, lifecycleScripts regression, diff check.

Summary by CodeRabbit

  • New Features

    • Workspace now tracks an allowBuilds setting to control per-package build permissions during install.
  • Improvements

    • allowBuilds is treated as an install-state input; when builds are explicitly disallowed, previously ignored builds are cleared.
    • Modules manifest now records allowBuilds entries to reflect current build permissions.
  • Bug Fixes

    • Preservation of ignored builds now respects allowBuilds, preventing stale ignored entries.
  • Tests

    • Added regression and unit tests covering allowBuilds and ignored-builds handling.

@KimHyeongRae0 KimHyeongRae0 marked this pull request as ready for review May 2, 2026 12:52
@KimHyeongRae0 KimHyeongRae0 requested a review from zkochan as a code owner May 2, 2026 12:52
@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ddaab64-8615-4ef1-9dc2-b4a9a323c9dd

📥 Commits

Reviewing files that changed from the base of the PR and between 7757652 and 65a3834.

📒 Files selected for processing (2)
  • deps/status/src/checkDepsStatus.ts
  • deps/status/test/checkDepsStatus.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • deps/status/test/checkDepsStatus.test.ts

📝 Walkthrough

Walkthrough

Tracks workspace allowBuilds as an install-state input, detects changes to it during status checks, and prevents preserving previously ignored builds when allowBuilds explicitly disallows them.

Changes

AllowBuilds tracked & ignored-builds preservation

Layer / File(s) Summary
Data Shape
workspace/state/src/types.ts
Adds 'allowBuilds' to WORKSPACE_STATE_SETTING_KEYS, widening WorkspaceStateSettings to include the allowBuilds config.
Policy helper
building/policy/src/index.ts, building/policy/package.json, building/policy/tsconfig.json
Adds isBuildExplicitlyDisallowed(depPath, allowBuild?) export; adds @pnpm/deps.path dependency and project reference.
Core Preservation
installing/deps-installer/src/install/index.ts, installing/deps-restorer/src/index.ts
Restore/install logic now keeps modulesFile.ignoredBuilds entries only when the package exists in the lockfile AND isBuildExplicitlyDisallowed(...) is false. Imports updated to use the new helper.
Status Detection
deps/status/src/checkDepsStatus.ts
Special-cases allowBuilds when comparing workspace settings to opts (uses opts.allowBuilds ?? {}) and treats missing/null workspaceState.settings.allowBuilds as a change when opts.allowBuilds is provided and non-empty.
Tests / E2E / Metadata
deps/status/test/checkDepsStatus.test.ts, workspace/state/test/createWorkspaceState.test.ts, pnpm/test/install/lifecycleScripts.ts, building/policy/test/index.ts, .changeset/quiet-geese-build.md
Adds unit tests for allowBuilds detection and isBuildExplicitlyDisallowed; updates workspace-state test; adds lifecycle e2e test validating ignored-builds clearing; documents change and bumps package patches.

Sequence Diagram(s)

sequenceDiagram
  actor CLI
  participant Installer
  participant StatusChecker
  participant WorkspaceState
  participant Lockfile
  CLI->>Installer: run install/add (opts include allowBuilds)
  Installer->>Lockfile: read filtered/current lockfile
  Installer->>WorkspaceState: read modules manifest (.modules.yaml)
  Installer->>Installer: for each ignoredBuild call isBuildExplicitlyDisallowed(depPath, allowBuild)
  alt allowBuild explicitly false
    Installer->>WorkspaceState: drop ignoredBuild (do not preserve)
  else allowBuild true/unknown or depPath unparseable
    Installer->>WorkspaceState: preserve ignoredBuild entry
  end
  CLI->>StatusChecker: checkDepsStatus(opts including allowBuilds)
  StatusChecker->>WorkspaceState: compare settings (special-case allowBuilds)
  alt allowBuilds changed from unset -> non-empty
    StatusChecker->>CLI: upToDate: false (allowBuilds changed)
  else
    StatusChecker->>CLI: upToDate: true/other issues
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • pnpm/pnpm#11452: Touches ignored-builds and allowBuilds handling in building/* modules; modifies related build-approval code paths.

Suggested reviewers

  • zkochan

Poem

🐰 I nibbled on the build-time tracks,
found allowBuilds tucked in the stacks.
When false is whispered, ignored builds flee —
the modules manifest now agrees with me.
Hoppity-hop, tidy installs for tea!

🚥 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 title 'fix: refresh ignored builds when allowBuilds changes' accurately and concisely summarizes the main change: ensuring ignored builds are refreshed when the allowBuilds configuration changes.
Linked Issues check ✅ Passed The PR fully implements the requirements from issue #10528: workspace state now tracks allowBuilds as a setting, detects when it changes, clears explicitly denied ignored builds, and prevents repeated install failures without manual state file removal.
Out of Scope Changes check ✅ Passed All changes are directly related to tracking allowBuilds in workspace state and refreshing ignored builds. Updates span workspace state types, status checks, ignored build filtering, and regression tests, all within the scope of fixing issue #10528.

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

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

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

@zkochan zkochan force-pushed the fix/10528-allow-builds-state branch from 9000d1b to 8e52c9f Compare May 4, 2026 23:34

@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 `@deps/status/src/checkDepsStatus.ts`:
- Around line 148-154: The extra stale-state check for allowBuilds (in
checkDepsStatus.ts where workspaceState.settings.allowBuilds == null &&
opts.allowBuilds != null && !isEmpty(opts.allowBuilds)) ignores the
ignoredWorkspaceStateSettings list; update that conditional to also verify that
'allowBuilds' is not in ignoredWorkspaceStateSettings (e.g. add &&
!ignoredWorkspaceStateSettings.includes('allowBuilds')) before returning
upToDate: false so the check respects purposely ignored settings.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0487e94b-4f03-4fcd-8b96-f1abc122eec4

📥 Commits

Reviewing files that changed from the base of the PR and between 9000d1b and 8e52c9f.

📒 Files selected for processing (3)
  • .changeset/quiet-geese-build.md
  • deps/status/src/checkDepsStatus.ts
  • deps/status/test/checkDepsStatus.test.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/quiet-geese-build.md
  • deps/status/test/checkDepsStatus.test.ts

Comment thread deps/status/src/checkDepsStatus.ts Outdated
Removes the duplicated ignored-build filter from deps-installer and
deps-restorer and exposes it as `isBuildExplicitlyDisallowed` on
`@pnpm/building.policy`, alongside `createAllowBuildFunction`.
… check

The fallback that flagged installs when allowBuilds went from unset to
non-empty bypassed the ignoredSettings filter, so callers that explicitly
opted out of allowBuilds tracking (via ignoredWorkspaceStateSettings)
could still be forced into a redundant install.
@zkochan zkochan enabled auto-merge (squash) May 5, 2026 00:09
@zkochan zkochan merged commit e51c8e2 into pnpm:main May 5, 2026
9 checks passed
@welcome

welcome Bot commented May 5, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

zkochan added a commit that referenced this pull request May 5, 2026
* fix: refresh ignored builds when allowBuilds changes

* refactor: extract isBuildExplicitlyDisallowed into @pnpm/building.policy

Removes the duplicated ignored-build filter from deps-installer and
deps-restorer and exposes it as `isBuildExplicitlyDisallowed` on
`@pnpm/building.policy`, alongside `createAllowBuildFunction`.

* fix: respect ignoredWorkspaceStateSettings in allowBuilds stale-state check

The fallback that flagged installs when allowBuilds went from unset to
non-empty bypassed the ignoredSettings filter, so callers that explicitly
opted out of allowBuilds tracking (via ignoredWorkspaceStateSettings)
could still be forced into a redundant install.

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
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.

Skipping a build doesn't resolve the ignored builds warning

2 participants