Skip to content

Make Dependabot pip PRs produce coherent hash-pinned lockfiles#14

Merged
brianmacy merged 2 commits into
Placekey:mainfrom
brianmacy:chore/dependabot-friendlier
Apr 22, 2026
Merged

Make Dependabot pip PRs produce coherent hash-pinned lockfiles#14
brianmacy merged 2 commits into
Placekey:mainfrom
brianmacy:chore/dependabot-friendlier

Conversation

@brianmacy

Copy link
Copy Markdown
Contributor

Summary

Context: after #7 merged, Dependabot opened 6 pip PRs within 5 minutes. The GitHub Actions ones (#8, #9, #10) were clean. The pip ones (#11 ipykernel 7.2, #12 awscli 1.44.84, #13 pandas 3.0.2) were all red. Two failure modes, both inherent to Dependabot's pip ecosystem:

  1. Capped-major bumps get proposed anyway. #11 and #13 cross caps in requirements.in (ipykernel<7.0, pandas<3.0). Dependabot reads requirements.txt directly and doesn't honor .in ranges, so the lockfile drift-check job fires every time.
  2. Hash set goes incoherent. When a direct-dep bump shifts transitives, Dependabot's pip updater edits a few == pins but leaves other transitives unversioned / un-hashed. pip install --require-hashes rejects the file. That's what killed deps(deps): bump awscli from 1.44.81 to 1.44.84 in the aws group across 1 directory #12 even though its version is range-compatible.

Neither is fixable by tweaking requirements.in. This PR addresses both.

Changes

  • Drop the lockfile drift-check job in tests.yml. It was brittle against uv version skew and didn't pull its weight once caps live in dependabot.yml.
  • Add ignore: rules in dependabot.yml mirroring requirements.in's upper bounds. Dependabot no longer proposes capped majors, so the weekly pip PR stream shrinks to patch/minor only. Folium is intentionally uncapped (0.x for a decade; eventual 1.0 expected non-breaking per upstream's changelog cadence).
  • Add .github/workflows/dependabot-lockfile.yml — a pull_request_target workflow that fires on Dependabot pip PRs, regenerates requirements.txt with uv pip compile --universal --generate-hashes, pushes the coherent lockfile back onto the PR branch, and re-dispatches validation CI. Runs only for the dependabot[bot] actor.
  • README: document the new flow (caps live in two places; auto-regen workflow handles hash coherence).

Why pull_request_target

pull_request from Dependabot runs with a read-only token and can't push back. pull_request_target runs with the base branch's perms and can, but is scoped only to this workflow and gated on github.actor == 'dependabot[bot]', so no attacker-controlled code executes with elevated perms. Pushes made via GITHUB_TOKEN don't re-trigger workflows automatically, so the workflow also re-dispatches tests.yml, notebook-ci.yml, notebook-hygiene.yml, and deps-audit.yml against the updated branch.

Test plan

🤖 Generated with Claude Code

- Drop the `lockfile` drift-check job in tests.yml. It only enforced
  the .in → .txt relationship and produced brittle failures whenever uv
  version or PyPI state differed between local and CI.
- Add `ignore:` rules in dependabot.yml mirroring requirements.in's
  upper bounds. Dependabot no longer proposes capped majors, so the
  weekly pip PR stream shrinks to patch/minor only. Folium is
  intentionally uncapped (0.x for a decade; eventual 1.0 expected
  non-breaking).
- Add dependabot-lockfile.yml: a pull_request_target workflow that
  fires on Dependabot pip PRs and regenerates requirements.txt with
  `uv pip compile --universal --generate-hashes` so the hash set stays
  coherent across transitives. Dependabot's own pip ecosystem bumps a
  direct dep's pin without re-pinning/re-hashing transitives, which
  breaks `pip install --require-hashes` (observed on PR #12). The
  workflow also re-dispatches validation CI against the updated branch
  since pushes via GITHUB_TOKEN don't trigger workflows by default.
- README: document the new flow — caps in two places, auto-regen
  workflow handles hash coherence.
Pass PR-controlled values (head ref, PR number, repo) through env vars
instead of interpolating them directly into inline shell commands.
@brianmacy brianmacy merged commit 9c33eb4 into Placekey:main Apr 22, 2026
8 checks passed
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