From b1c4345765e7c079536128d00a01f2ca3f3b0a76 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 15:49:04 +0000 Subject: [PATCH 1/3] chore: group Dependabot updates, add a cooldown and document the merge protocol Signed-off-by: Flavio Oliva --- .github/dependabot.yml | 19 ++++++++++ docs/development/ci.md | 17 +++++++++ tests/docs/test_procurement_docs.py | 58 ++++++++++++++++++++++------- 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5de1bea9a..3ef577beb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,9 +1,17 @@ version: 2 updates: + # Cooldowns do not delay Dependabot security updates. - package-ecosystem: "uv" directory: "/" schedule: interval: "weekly" + groups: + uv-minor-and-patch: + update-types: + - "minor" + - "patch" + cooldown: + default-days: 3 commit-message: prefix: "chore(deps)" @@ -11,6 +19,8 @@ updates: directory: "/website" schedule: interval: "weekly" + cooldown: + default-days: 3 commit-message: prefix: "chore(deps)" @@ -18,6 +28,13 @@ updates: directory: "/" schedule: interval: "weekly" + groups: + github-actions-minor-and-patch: + update-types: + - "minor" + - "patch" + cooldown: + default-days: 3 commit-message: prefix: "chore(deps)" @@ -26,6 +43,8 @@ updates: directory: "/ui" schedule: interval: "weekly" + cooldown: + default-days: 3 open-pull-requests-limit: 2 groups: ui-dependencies: diff --git a/docs/development/ci.md b/docs/development/ci.md index 8554a274a..2f2375cb1 100644 --- a/docs/development/ci.md +++ b/docs/development/ci.md @@ -80,6 +80,23 @@ full matrix runs on every merge before anything ships. of that branch, which refreshes the base analysis the PR scans compare against (a stale one made each PR's Python sensor re-parse ~848 files). Every push is its own concurrency group (`run_id`), so none cancels another. +## Dependency updates + +At the start of each release wave, list open Dependabot pull requests with `gh pr list --author "app/dependabot"`. +Land them one at a time. Main protection requires an up-to-date branch and auto-merge is off: merge `origin/main` into +the Dependabot branch, push it, wait for CI, then merge the pull request. + +Complete per-bump fixes before merging: + +- A SonarSource scan-action bump also updates the scanner cache key + `sonar-${{ runner.os }}-vX.Y.Z` in `.github/workflows/ci.yml`. The key is pinned by + `test_the_sonar_scanner_cache_is_keyed_and_pinned`. +- An npm bump rebuilds `src/sharpit/ui/static` with `cd ui && npm ci --ignore-scripts && npm run build`, then commits the + built assets. + +A maintainer commit on a Dependabot branch is signed off. A failed DCO check is fixed with a signed remediation commit, +never a force-push. When every Dependabot pull request fails the same shards, check `main` first. + ## CodeQL on release pull requests The classic branch protection rule for `release/*` enables CodeQL default setup on pull requests into version diff --git a/tests/docs/test_procurement_docs.py b/tests/docs/test_procurement_docs.py index 68570ba6a..a61597a91 100644 --- a/tests/docs/test_procurement_docs.py +++ b/tests/docs/test_procurement_docs.py @@ -196,29 +196,40 @@ def _clean_val(val: str) -> object: def _parse_block(block: str) -> dict[str, object]: entry: dict[str, object] = {} - for line in block.splitlines(): + stack: list[tuple[int, dict[str, object] | list[object]]] = [(-1, entry)] + lines = block.splitlines() + for index, line in enumerate(lines): + if not line.strip() or line.lstrip().startswith("#"): + continue + indent = len(line) - len(line.lstrip()) stripped = line.strip() - if not stripped or stripped.startswith("#") or ":" not in stripped: + while stack[-1][0] >= indent: + stack.pop() + parent = stack[-1][1] + if stripped.startswith("- "): + assert isinstance(parent, list) + parent.append(_clean_val(stripped[2:])) + continue + if ":" not in stripped: continue k, v = stripped.split(":", 1) key, val = k.strip(), v.strip() if val: - entry[key] = _clean_val(val) + assert isinstance(parent, dict) + parent[key] = _clean_val(val) else: - entry[key] = {} + next_line = next( + (line for line in lines[index + 1 :] if line.strip() and not line.lstrip().startswith("#")), + "", + ) + child: dict[str, object] | list[object] = [] if next_line.strip().startswith("- ") else {} + assert isinstance(parent, dict) + parent[key] = child + stack.append((indent, child)) return entry def _parse_yaml(text: str) -> dict[str, object]: - try: - import yaml # type: ignore[import-not-found] - - loaded = yaml.safe_load(text) - if isinstance(loaded, dict): - return loaded - except ImportError: - pass - result: dict[str, object] = {"version": 2, "updates": []} updates_list: list[dict[str, object]] = [] result["updates"] = updates_list @@ -251,6 +262,27 @@ def test_dependabot_covers_uv_pip_actions_and_ui_npm() -> None: assert ("github-actions", "/") in entries, "Dependabot must cover github-actions at /" assert ("npm", "/ui") in entries, "Dependabot must cover npm at /ui" + for update in updates: + assert isinstance(update, dict) + schedule = update.get("schedule") + assert isinstance(schedule, dict) + assert schedule.get("interval") == "weekly" + + for ecosystem in ("uv", "github-actions"): + entry = next(u for u in updates if u.get("package-ecosystem") == ecosystem and u.get("directory") == "/") + groups = entry.get("groups") + assert isinstance(groups, dict) + group = next(iter(groups.values())) + assert isinstance(group, dict) + assert {"minor", "patch"}.issubset(set(group.get("update-types", []))) + + for update in updates: + assert isinstance(update, dict) + cooldown = update.get("cooldown") + assert isinstance(cooldown, dict) + assert isinstance(cooldown.get("default-days"), int) + assert cooldown["default-days"] >= 3 + npm_entry = next( ( u From cea62cd439ffdb7253ed45c87e4ccef53f660f7b Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 15:56:55 +0000 Subject: [PATCH 2/3] test: name the ecosystem in each Dependabot assertion Signed-off-by: Flavio Oliva --- .github/dependabot.yml | 2 +- tests/docs/test_procurement_docs.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3ef577beb..40cdbb037 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -38,7 +38,7 @@ updates: commit-message: prefix: "chore(deps)" - # npm updates require running `npm --prefix ui run build` and committing built assets (checked by CI drift job) + # npm updates require rebuilding the committed UI with `npm --prefix ui run build` as described in docs/development/ci.md (Dependency updates); CI checks for drift - package-ecosystem: "npm" directory: "/ui" schedule: diff --git a/tests/docs/test_procurement_docs.py b/tests/docs/test_procurement_docs.py index a61597a91..c57d06a97 100644 --- a/tests/docs/test_procurement_docs.py +++ b/tests/docs/test_procurement_docs.py @@ -219,7 +219,7 @@ def _parse_block(block: str) -> dict[str, object]: parent[key] = _clean_val(val) else: next_line = next( - (line for line in lines[index + 1 :] if line.strip() and not line.lstrip().startswith("#")), + (later for later in lines[index + 1 :] if later.strip() and not later.lstrip().startswith("#")), "", ) child: dict[str, object] | list[object] = [] if next_line.strip().startswith("- ") else {} @@ -278,10 +278,11 @@ def test_dependabot_covers_uv_pip_actions_and_ui_npm() -> None: for update in updates: assert isinstance(update, dict) + ecosystem = update.get("package-ecosystem") cooldown = update.get("cooldown") - assert isinstance(cooldown, dict) - assert isinstance(cooldown.get("default-days"), int) - assert cooldown["default-days"] >= 3 + assert isinstance(cooldown, dict), f"{ecosystem} needs a cooldown block" + assert isinstance(cooldown.get("default-days"), int), f"{ecosystem} needs an integer cooldown.default-days" + assert cooldown["default-days"] >= 3, f"{ecosystem} needs cooldown.default-days >= 3" npm_entry = next( ( From 0601bb6b2577a76ddc2fc09e3ad9d044ef66f227 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sat, 5 Dec 2026 19:07:11 +0000 Subject: [PATCH 3/3] docs: name the code-scan action without the vendor word Signed-off-by: Flavio Oliva --- docs/development/ci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/ci.md b/docs/development/ci.md index 2f2375cb1..44bbcaeab 100644 --- a/docs/development/ci.md +++ b/docs/development/ci.md @@ -88,7 +88,7 @@ the Dependabot branch, push it, wait for CI, then merge the pull request. Complete per-bump fixes before merging: -- A SonarSource scan-action bump also updates the scanner cache key +- A code-scan action bump also updates the scanner cache key `sonar-${{ runner.os }}-vX.Y.Z` in `.github/workflows/ci.yml`. The key is pinned by `test_the_sonar_scanner_cache_is_keyed_and_pinned`. - An npm bump rebuilds `src/sharpit/ui/static` with `cd ui && npm ci --ignore-scripts && npm run build`, then commits the