Skip to content

Commit 03f98eb

Browse files
tclemCopilot
andcommitted
Add update-deps skill for automated dependency updates
Defines a Copilot skill that automates the full dependency update lifecycle for this Rust workspace: discover outdated deps via dependabot alerts/PRs, apply updates grouped by ecosystem (cargo, github-actions, npm), fix breakage, get CI green, and create PRs for human review. Also adds github/rust-gems to the update-deps-supervisor target list. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1c55dd8 commit 03f98eb

File tree

1 file changed

+287
-0
lines changed

1 file changed

+287
-0
lines changed
Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
---
2+
name: update-deps
3+
description: Keep dependencies up-to-date. Discovers outdated deps via dependabot alerts/PRs, creates one PR per ecosystem, iterates until CI is green, then assigns for review.
4+
user-invocable: true
5+
---
6+
7+
# Update Dependencies
8+
9+
Automate the full dependency update lifecycle: discover what's outdated, apply updates grouped by ecosystem, fix breakage, get CI green, and hand off for human review.
10+
11+
## Repository context
12+
13+
This is a Rust workspace containing utility crates published to crates.io. All dependency update PRs target the **`main`** branch.
14+
15+
Dependabot is configured (`.github/dependabot.yaml`) to open PRs against `main` on the 2nd of each month. This skill gathers individual dependabot PRs, combines updates by ecosystem, fixes any breakage, gets CI green, and creates consolidated PRs for human review.
16+
17+
### Crates in this workspace
18+
19+
| Crate | Description |
20+
|---|---|
21+
| **bpe** | Fast byte-pair encoding |
22+
| **bpe-openai** | OpenAI tokenizers built on bpe |
23+
| **geo_filters** | Probabilistic cardinality estimation |
24+
| **string-offsets** | UTF-8/UTF-16/Unicode position conversion (with WASM/JS bindings) |
25+
26+
Supporting packages (not published): `bpe-tests`, `bpe-benchmarks`.
27+
28+
### Ecosystems in this repo
29+
30+
| Ecosystem | Directories | Notes |
31+
|---|---|---|
32+
| **cargo** | `/` (workspace root) | All Rust deps managed at workspace level via `Cargo.lock` |
33+
| **github-actions** | `.github/workflows/` | CI and publish workflows |
34+
| **npm** | `crates/string-offsets/js/` | JS bindings for string-offsets (WASM) |
35+
36+
### Build and validation commands
37+
38+
```bash
39+
make build # cargo build --all-targets --all-features
40+
make build-js # npm run compile in crates/string-offsets/js
41+
make lint # cargo fmt --check + cargo clippy (deny warnings, forbid unwrap_used)
42+
make test # cargo test + doc tests
43+
```
44+
45+
CI runs on `ubuntu-latest` with the `mold` linker. The lint job depends on build.
46+
47+
## Workflow
48+
49+
### 1. Assess repo state
50+
51+
Determine the repo identity and confirm the target branch.
52+
53+
```bash
54+
git remote get-url origin # extract owner/repo
55+
git fetch origin main
56+
git rev-parse --verify origin/main
57+
```
58+
59+
Detect which ecosystems have pending updates:
60+
61+
```bash
62+
[ -f Cargo.toml ] && echo "cargo"
63+
ls .github/workflows/*.yml .github/workflows/*.yaml 2>/dev/null && echo "github-actions"
64+
[ -f crates/string-offsets/js/package.json ] && echo "npm"
65+
```
66+
67+
Report discovered ecosystems to the user.
68+
69+
### 2. Gather dependency intelligence
70+
71+
Fetch open dependabot PRs:
72+
73+
```bash
74+
gh pr list --author 'app/dependabot' --base main --state open --json number,title,headRefName,labels --limit 100
75+
```
76+
77+
Fetch open dependabot alerts:
78+
79+
```bash
80+
gh api /repos/{owner}/{repo}/dependabot/alerts --jq '[.[] | select(.state=="open") | {number: .number, package: .security_vulnerability.package.name, ecosystem: .security_vulnerability.package.ecosystem, severity: .security_advisory.severity, summary: .security_advisory.summary}]'
81+
```
82+
83+
For ecosystems without dependabot coverage or when running ad-hoc, use native tooling:
84+
85+
- **cargo:** `cargo update --dry-run`
86+
- **npm:** `cd crates/string-offsets/js && npm outdated --json`
87+
88+
Cross-reference and group all updates by ecosystem. Present a summary to the user:
89+
90+
- How many updates per ecosystem
91+
- Which have security alerts (and severity)
92+
- Which dependabot PRs already exist
93+
94+
**Flag high-risk upgrades.** Before proceeding, explicitly call out upgrades that carry elevated risk:
95+
96+
- **Major version bumps** — likely contain breaking API changes
97+
- **Packages with wide blast radius** — for this repo, pay special attention to: `serde`, `itertools`, `regex-automata`, `wasm-bindgen`, `criterion`, and the Rust toolchain itself
98+
- **Multiple major bumps in the same PR** — each major bump multiplies the risk; consider splitting them
99+
100+
Present the risk assessment to the user and recommend which upgrades to include vs. defer. When in doubt, prefer a smaller, safe update over an ambitious one that might break.
101+
102+
### 3. Create branch and apply updates
103+
104+
For each selected ecosystem, starting from `main`:
105+
106+
```bash
107+
git checkout main
108+
git pull origin main
109+
git checkout -b deps/{ecosystem}-updates-$(date +%Y-%m-%d)
110+
```
111+
112+
Apply updates using ecosystem-appropriate tooling:
113+
114+
**cargo:**
115+
116+
```bash
117+
cargo update
118+
# For major bumps, edit Cargo.toml version constraints then:
119+
cargo check
120+
```
121+
122+
This is a Cargo workspace — always run from the repo root. All crate `Cargo.toml` files are in `crates/`. The `Cargo.lock` at the root is the single source of truth.
123+
124+
**npm:**
125+
126+
```bash
127+
cd crates/string-offsets/js
128+
npm update
129+
npm install
130+
```
131+
132+
**github-actions:**
133+
134+
- Parse workflow YAML files in `.github/workflows/` for `uses:` directives
135+
- For each action with an outdated version (from dependabot PRs/alerts), update the SHA or version tag
136+
- Be careful to preserve comments and formatting
137+
138+
### 4. Build, lint, and test locally
139+
140+
Always run:
141+
142+
```bash
143+
make lint # cargo fmt --check + clippy with deny warnings
144+
make test # cargo test with backtrace
145+
make build # full workspace build (all targets, all features)
146+
```
147+
148+
If npm dependencies changed:
149+
150+
```bash
151+
make build-js # npm compile for string-offsets JS binding
152+
```
153+
154+
**If the build/lint/test fails:**
155+
156+
1. Read the error output carefully
157+
2. Analyze what broke — likely API changes, type errors, or deprecation removals
158+
3. Make the necessary code changes to fix the breakage
159+
4. Run the pipeline again
160+
5. Repeat up to 3 times
161+
162+
If still failing after 3 iterations, report the situation to the user and ask for guidance. Do not push broken code.
163+
164+
### 5. Commit and push
165+
166+
Stage all changes and commit with a descriptive message:
167+
168+
```bash
169+
git add -A
170+
git commit -m "chore(deps): update {ecosystem} dependencies
171+
172+
Updated packages:
173+
- package-a: 1.0.0 → 2.0.0
174+
- package-b: 3.1.0 → 3.2.0
175+
176+
{If code changes were needed:}
177+
Fixed breaking changes:
178+
- Updated X API usage for package-a v2
179+
180+
Supersedes: #{dependabot_pr_1}, #{dependabot_pr_2}
181+
"
182+
```
183+
184+
Push the branch:
185+
186+
```bash
187+
git push -u origin HEAD
188+
```
189+
190+
### 6. Create the PR
191+
192+
**Title:** `chore(deps): update {ecosystem} dependencies`
193+
194+
**Body should include:**
195+
196+
- List of updated dependencies with version changes (old → new)
197+
- Any security alerts resolved (with severity)
198+
- **High-risk changes flagged for reviewer attention** (major version bumps, wide-blast-radius packages)
199+
- Code changes made to fix breakage (if any)
200+
- References to superseded dependabot PRs
201+
- Note that this was generated by the update-deps skill
202+
203+
Write the body to a temp file and create the PR **targeting `main`**:
204+
205+
```bash
206+
gh pr create --title "chore(deps): update {ecosystem} dependencies" --body-file /tmp/deps-pr-body.md --base main
207+
rm /tmp/deps-pr-body.md
208+
```
209+
210+
### 7. Monitor CI and iterate on failures
211+
212+
Watch the PR's checks:
213+
214+
```bash
215+
gh pr checks {pr_number} --watch --fail-fast
216+
```
217+
218+
**If checks fail:**
219+
220+
1. Get the failed run details:
221+
222+
```bash
223+
gh run list --branch {branch} --status failure --json databaseId,name --limit 1
224+
gh run view {run_id} --log-failed
225+
```
226+
227+
2. Analyze the failure — CI runs on `ubuntu-latest` with `mold` linker, which may differ from local builds.
228+
229+
3. Fix the issue locally, commit, and push:
230+
231+
```bash
232+
git add -A
233+
git commit -m "fix: resolve CI failure in {ecosystem} dep update
234+
235+
{Brief description of what failed and why}"
236+
git push
237+
```
238+
239+
4. Monitor again. Repeat up to 3 iterations total.
240+
241+
5. If still failing after 3 pushes, report to the user with the failure details and ask for help.
242+
243+
### 8. Close superseded dependabot PRs
244+
245+
For each dependabot PR that this update supersedes:
246+
247+
```bash
248+
gh pr close {dependabot_pr_number} --comment "Superseded by #{new_pr_number} which includes this update along with other {ecosystem} dependency updates."
249+
```
250+
251+
### 9. Assign for review
252+
253+
Determine the current user:
254+
255+
```bash
256+
gh api user --jq '.login'
257+
```
258+
259+
Request review:
260+
261+
```bash
262+
gh pr edit {pr_number} --add-reviewer {user_login}
263+
```
264+
265+
Report the final PR URL and a summary of what was done.
266+
267+
## Guidelines
268+
269+
- **All PRs target `main`.** There is no separate dev branch.
270+
- **Never push to `main` directly.** Always work on a feature branch.
271+
- **Never push code that doesn't pass `make lint` and `make test`.** If you can't fix it in 3 tries, stop and ask.
272+
- **Be conservative with major version bumps.** If a major version update breaks things and the fix isn't obvious, skip that package and note it in the PR description.
273+
- **Preserve lockfiles.** Always regenerate `Cargo.lock` and `package-lock.json` after updating — don't just edit manifests.
274+
- **One ecosystem at a time.** Complete the full cycle (update → build → push → PR → CI green) for one ecosystem before moving to the next.
275+
- **If no updates are needed** for an ecosystem, skip it and tell the user.
276+
- **Security alerts take priority.** Address security alerts first within each ecosystem.
277+
- **Clippy is strict.** This repo forbids `unwrap_used` outside tests and denies all warnings. New dependency versions may trigger new clippy lints — fix them.
278+
279+
## Edge cases
280+
281+
- **Cargo workspace:** All Rust dependencies are managed at the workspace root. Always run `cargo update` and `cargo check` from the repo root.
282+
- **npm is scoped to string-offsets:** The only npm package is in `crates/string-offsets/js/`. Don't look for npm elsewhere.
283+
- **WASM builds:** After updating `wasm-bindgen` or related deps, verify `make build-js` still works — WASM toolchain version mismatches are common.
284+
- **Rate limits:** If `gh api` hits rate limits, wait and retry. Report to user if persistent.
285+
- **Nothing to update:** Report cleanly and move to the next ecosystem (or exit).
286+
- **Merge conflicts on push:** Rebase on `main` and retry: `git fetch origin main && git rebase origin/main`.
287+
- **Branch already exists:** If `deps/{ecosystem}-updates-{date}` already exists, append a counter or ask user.

0 commit comments

Comments
 (0)