Skip to content

ci(nix): fix the bump workflow's PR creation, and catch npmDepsHash drift - #230

Merged
EtienneLescot merged 4 commits into
mainfrom
claude/nix-ci-issue-1f6454
Aug 3, 2026
Merged

ci(nix): fix the bump workflow's PR creation, and catch npmDepsHash drift#230
EtienneLescot merged 4 commits into
mainfrom
claude/nix-ci-issue-1f6454

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #136.

The visible break

gh pr create in bump-nix-package.yml ran under GITHUB_TOKEN, but the repo has Allow GitHub Actions to create and approve pull requests off:

{"default_workflow_permissions":"read","can_approve_pull_request_reviews":false}

So the v1.7.0 run pushed its branch and then died on the API call — run 29707554857:

pull request create failed: GraphQL: GitHub Actions is not permitted to create or approve pull requests

That is why #136 was opened by hand, and v1.8.0 would have hit it again. Switched to OPENSCREEN_RELEASE_TOKEN, which every other release workflow already uses — it isn't subject to that restriction, and its PRs trigger CI, so the "push an empty commit if you want CI" note in the generated body is gone.

Preferred over flipping the repo setting, which would loosen PR creation repo-wide for one workflow.

The quiet one

src is this repo's own tree (a fileset, not a fetched tarball), so npmDepsHash has to agree with the package-lock.json sitting beside it. The only thing that ever refreshed that hash was this release-time workflow.

  • nix/package.nix last changed 2026-07-05 (bump nix package to v1.6.0)
  • package-lock.json last changed 2026-07-29, after 10 commits touching it

So nix run github:getopenscreen/openscreen had been failing on main for about four weeks, and nothing reported it — no workflow ran nix build or otherwise looked at the hash.

A release-time bump structurally cannot cover this: the drift starts the moment a lockfile PR merges, not at the next release. nix-check.yml runs on PRs touching package-lock.json or nix/**, compares the recorded hash against prefetch-npm-deps package-lock.json, and fails with the value to paste. Same command the bump workflow already uses, so no new tooling.

The guard proved itself on this PR

First push kept the stale hash deliberately. Run 30789853182failed, as it should have:

recorded in nix/package.nix:     sha256-IZypOLWlDShIjCKWxlJcrdtIkMu0P/DuXaq4c0HW3FY=
expected from package-lock.json: sha256-SggSPoDnKzmvgXpIGP11y6h390SkoZszeMjFTaokRjQ=
Error: npmDepsHash is stale — set it to sha256-SggSPoDnKzmvgXpIGP11y6h390SkoZszeMjFTaokRjQ=

Pasted that value, run 30789963366green, In sync.

Worth noting: #136 carried sha256-cb8loUzQs4fz3um0xbYgtjQdcRZh/Ptk2YPgv3FHP/s=, computed from main as it stood on 2026-07-19. That is neither of the two values above — it was stale for the same reason, so merging #136 would not have fixed the build either.

version also goes to 1.7.0, which is all #136 carried.

Not covered here

No required_status_checks rule exists in the main-protection ruleset, so this check reports but does not block a merge. Making it blocking is a separate call — there are currently no required checks at all on this repo.

Summary by CodeRabbit

  • Chores
    • Updated the Nix package to version 1.7.0.
    • Improved automated release pull requests.
    • Added automated checks to verify dependency hashes remain synchronized with the package lockfile.

…he PR that causes it

Two failures, one visible and one not.

`gh pr create` ran under GITHUB_TOKEN while the repo has "Allow GitHub
Actions to create and approve pull requests" turned off, so the v1.7.0 bump
pushed its branch and then died on the API call. #136 was opened by hand to
work around it. Every other release workflow already authenticates with
OPENSCREEN_RELEASE_TOKEN, which is not subject to that restriction and whose
PRs trigger CI — so the note telling reviewers to push an empty commit goes
away too.

The quiet one: `src` is this repo's tree rather than a fetched tarball, so
npmDepsHash has to agree with whatever package-lock.json sits beside it, and
the only thing that refreshed it fired on stable releases. main's hash last
matched on 2026-07-05 while the lockfile moved ten more times, leaving
`nix run github:getopenscreen/openscreen` broken for four weeks with nothing
reporting it. A release-time bump structurally cannot cover that gap, so the
check now runs on lockfile and nix/ changes and prints the hash to paste.

Version goes to 1.7.0 here, which is what #136 was for.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

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: 1aa7a7b6-644f-41dc-9e41-38d346189516

📥 Commits

Reviewing files that changed from the base of the PR and between 4a4ec2f and e67d665.

📒 Files selected for processing (2)
  • .github/workflows/bump-nix-package.yml
  • .github/workflows/nix-check.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/bump-nix-package.yml
  • .github/workflows/nix-check.yml

📝 Walkthrough

Walkthrough

The Nix package version and dependency hash are updated. A workflow validates hash synchronization on relevant pull requests and pushes. Release bump pull requests use OPENSCREEN_RELEASE_TOKEN.

Changes

Nix release automation

Layer / File(s) Summary
Nix metadata and dependency validation
nix/package.nix, .github/workflows/nix-check.yml
The package version changes to 1.7.0, and npmDepsHash is updated. The workflow checks the computed hash against package-lock.json and nix/package.nix on selected branches and paths.
Release pull request authentication
.github/workflows/bump-nix-package.yml
The workflow removes pull request write permission, uses OPENSCREEN_RELEASE_TOKEN to create release bump pull requests, and removes the obsolete GITHUB_TOKEN CI warning.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant Nix
  participant PackageFiles
  GitHubActions->>Nix: Compute npm dependency hash
  Nix->>PackageFiles: Read package-lock.json
  GitHubActions->>PackageFiles: Read npmDepsHash from nix/package.nix
  GitHubActions->>GitHubActions: Compare the hashes
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: fixing PR creation in the Nix bump workflow and detecting npmDepsHash drift.
Description check ✅ Passed The description clearly explains the problems, changes, testing evidence, package update, and known limitation, despite not following every template heading.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/nix-ci-issue-1f6454

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

The value dated to v1.6.0 on 2026-07-05; package-lock.json moved ten times
after that, so `nix build` had been refusing the mismatch ever since. The
replacement is what the new check computed from the current lockfile:

  recorded  sha256-IZypOLWlDShIjCKWxlJcrdtIkMu0P/DuXaq4c0HW3FY=
  expected  sha256-SggSPoDnKzmvgXpIGP11y6h390SkoZszeMjFTaokRjQ=

#136 carried sha256-cb8loUzQs4fz3um0xbYgtjQdcRZh/Ptk2YPgv3FHP/s=, computed
from main as it stood on 2026-07-19 — stale for the same reason, which is
why merging it would not have fixed anything.

@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.

🧹 Nitpick comments (1)
.github/workflows/nix-check.yml (1)

33-33: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Disable checkout credential persistence.

actions/checkout@v4 persists its token in local Git configuration by default. Set persist-credentials: false. Set workflow permissions to contents: read because this validation job does not write repository data.

Proposed hardening
 name: Nix
+
+permissions:
+  contents: read
 
 # nix/package.nix records `npmDepsHash`, a hash of the npm dependency set that
@@
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@v4
+        with:
+          persist-credentials: false
🤖 Prompt for 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.

In @.github/workflows/nix-check.yml at line 33, Update the checkout step using
actions/checkout@v4 to set persist-credentials to false, and configure the
workflow permissions to contents: read for this validation job. Preserve the
existing checkout behavior otherwise.

Source: Linters/SAST tools

🤖 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.

Nitpick comments:
In @.github/workflows/nix-check.yml:
- Line 33: Update the checkout step using actions/checkout@v4 to set
persist-credentials to false, and configure the workflow permissions to
contents: read for this validation job. Preserve the existing checkout behavior
otherwise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f86bfb60-e847-45e2-ac6f-b88a969b0a01

📥 Commits

Reviewing files that changed from the base of the PR and between e383f9b and f305faa.

📒 Files selected for processing (3)
  • .github/workflows/bump-nix-package.yml
  • .github/workflows/nix-check.yml
  • nix/package.nix

The push trigger listed main alone, which is the same gap ci.yml carries a
comment about after PRs #167-#169 merged into a release branch with every job
skipped. Pull requests were already covered everywhere — that trigger has no
branch filter — but a rebase force-push onto release/** is not a pull request,
and a release branch is the last place to let a stale hash through unnoticed.
@
ci(nix): least-privilege the two nix workflows, symmetric path filters

Review follow-ups, all three mechanical:

- nix-check.yml declares `permissions: contents: read` instead of inheriting
  it. It was the only workflow in .github/workflows/ without a permissions
  block, and inheriting a repo-level setting is precisely what broke the bump
  workflow it ships alongside.
- The push trigger now watches .github/workflows/nix-check.yml like the
  pull_request trigger already did, so an edit to the check itself is checked
  on both legs.
- bump-nix-package.yml drops `pull-requests: write`. The PR is opened with the
  PAT now, so that grant on GITHUB_TOKEN buys nothing.
@
@EtienneLescot
EtienneLescot merged commit 7f63dba into main Aug 3, 2026
17 checks passed
@EtienneLescot
EtienneLescot deleted the claude/nix-ci-issue-1f6454 branch August 3, 2026 07:29
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.

1 participant