From e8d80005203453b9547485e4d03cf8c7e914d82e Mon Sep 17 00:00:00 2001 From: ItsPaulAT <76869048+ItsPaulAT@users.noreply.github.com> Date: Sat, 21 Nov 2026 08:25:23 +0100 Subject: [PATCH 1/4] ci: let Dependabot merge patch and minor updates Weekly grouped updates with majors in their own group. Patch and minor updates are approved and set to auto-merge (squash); majors stay manual. The PR-title check no longer limits the length of Dependabot titles. Signed-off-by: ItsPaulAT <76869048+ItsPaulAT@users.noreply.github.com> --- .github/dependabot.yml | 10 +++ .github/workflows/dependabot-automerge.yml | 75 ++++++++++++++++++++++ scripts/check_pr_title.py | 11 ++-- tests/test_check_pr_title.py | 7 ++ 4 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/dependabot-automerge.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 31f737f..f1978e7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,9 +13,14 @@ updates: prefix: ci include: scope labels: [dependencies] + open-pull-requests-limit: 5 groups: actions: patterns: ["*"] + update-types: ["minor", "patch"] + actions-major: + patterns: ["*"] + update-types: ["major"] - package-ecosystem: pip directory: / @@ -28,6 +33,11 @@ updates: prefix: build include: scope labels: [dependencies] + open-pull-requests-limit: 5 groups: dev-tools: patterns: ["*"] + update-types: ["minor", "patch"] + dev-tools-major: + patterns: ["*"] + update-types: ["major"] diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..6410110 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,75 @@ +# Approves Dependabot's patch and minor updates and turns on auto-merge (squash); GitHub merges +# once the required checks pass. Majors, 0.x minors and updates without a semver type (image +# digests) stay for a manual review. The update types come from the metadata block of +# Dependabot's commit message, the same source dependabot/fetch-metadata reads. +name: dependabot-automerge + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: {} + +concurrency: + group: dependabot-automerge-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + automerge: + name: automerge + if: >- + github.event.pull_request.user.login == 'dependabot[bot]' && + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + contents: write + pull-requests: write + steps: + - name: Approve and enable auto-merge for patch and minor updates + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + set -euo pipefail + commits="$(gh api "repos/$REPO/pulls/$PR_NUMBER/commits?per_page=100")" + authors="$(jq -r '[.[].author.login // "unknown"] | unique | join(",")' <<<"$commits")" + if [ "$authors" != "dependabot[bot]" ]; then + echo "::notice::Commits by $authors; left for a manual review." + exit 0 + fi + export MESSAGE + MESSAGE="$(jq -r '.[-1].commit.message' <<<"$commits")" + verdict="$(python3 - <<'PY' + import os + deps, block = [], False + for line in os.environ["MESSAGE"].splitlines(): + if line == "updated-dependencies:": + block = True + elif block and line in ("...", "---", ""): + break + elif block and line.startswith("- "): + deps.append({}) + if block and deps and ":" in line: + key, _, value = line[2:].partition(":") + deps[-1][key.strip()] = value.strip().strip("'\"") + reasons = [] + for d in deps: + kind = d.get("update-type", "") + name = d.get("dependency-name", "?") + if kind not in ("version-update:semver-patch", "version-update:semver-minor"): + reasons.append(f"{name}: {kind or 'no semver update type'}") + elif kind.endswith("minor") and d.get("dependency-version", "").startswith("0."): + reasons.append(f"{name}: minor update below 1.0") + print("; ".join(reasons) if deps else "no update metadata") + PY + )" + if [ -n "$verdict" ]; then + echo "::notice::Left for a manual review ($verdict)." + exit 0 + fi + url="https://github.com/$REPO/pull/$PR_NUMBER" + gh pr review "$url" --approve || echo "::warning::Could not approve the pull request." + gh pr merge "$url" --auto --squash --match-head-commit "$HEAD_SHA" diff --git a/scripts/check_pr_title.py b/scripts/check_pr_title.py index ed5942d..0b7e247 100755 --- a/scripts/check_pr_title.py +++ b/scripts/check_pr_title.py @@ -26,9 +26,10 @@ TYPES = ("feat", "fix", "docs", "refactor", "perf", "test", "style", "build", "ci", "chore", "revert", "security") TITLE_RE = re.compile(r"^(?P[a-z]+)(?:\((?P[a-z0-9][a-z0-9._/-]*)\))?(?P!)?: (?P\S.*)$") MAX_LENGTH = 100 -# Bots whose titles follow Conventional Commits but start the summary with a capital ("Bump ..."). -# Only the lower-case rule is relaxed for them; format, types, length and wording still apply. -CAPITALISED_SUMMARY_OK = ("dependabot[bot]",) +# Bots whose titles follow Conventional Commits but start the summary with a capital ("Bump ...") +# and can run past MAX_LENGTH ("... in the actions group across 1 directory"). Only the lower-case +# rule and the length limit are relaxed for them; format, types and wording still apply. +BOT_AUTHORS = ("dependabot[bot]",) def problems(title: str, author: str = "") -> list[str]: @@ -45,9 +46,9 @@ def problems(title: str, author: str = "") -> list[str]: if subject.endswith("."): out.append("the summary must not end with a full stop") if (subject[:1].isupper() and not subject.split()[0].isupper() - and author not in CAPITALISED_SUMMARY_OK): + and author not in BOT_AUTHORS): out.append("the summary must start with a lower-case letter (imperative mood: 'add', 'fix')") - if len(title) > MAX_LENGTH: + if len(title) > MAX_LENGTH and author not in BOT_AUTHORS: out.append(f"the title is {len(title)} characters long; keep it to {MAX_LENGTH}") out += [f"wording: {e.split(': ', 1)[-1]}" for e in check_string(title)] return out diff --git a/tests/test_check_pr_title.py b/tests/test_check_pr_title.py index 4ad0b48..db2395c 100644 --- a/tests/test_check_pr_title.py +++ b/tests/test_check_pr_title.py @@ -44,6 +44,13 @@ def test_dependabot_may_capitalise(self): self.assertTrue(pt.problems("Bump the actions group", "dependabot[bot]")) self.assertTrue(any(p.startswith("wording") for p in pt.problems("ci(deps): Bump the pro version", "dependabot[bot]"))) + def test_dependabot_may_exceed_the_length_limit(self): + title = ("ci(deps): Bump DavidAnson/markdownlint-cli2-action from 24.2.0 to 25.0.0 " + "in the actions group across 1 directory") + self.assertGreater(len(title), pt.MAX_LENGTH) + self.assertEqual(pt.problems(title, "dependabot[bot]"), []) + self.assertTrue(pt.problems(title.replace("Bump", "bump"), "someone")) + def test_offer_wording_is_rejected(self): """Release notes are built from the titles, so they must be offer-free too.""" for title in ("feat: add pro version toggle", "docs: add donation link", "feat: coming soon page", From 1219578e71916e8c7d9ef2dbbe563ecf8b34bf35 Mon Sep 17 00:00:00 2001 From: ItsPaulAT <76869048+ItsPaulAT@users.noreply.github.com> Date: Sat, 21 Nov 2026 08:26:53 +0100 Subject: [PATCH 2/4] docs: list the auto-merge settings in the publishing checklist Signed-off-by: ItsPaulAT <76869048+ItsPaulAT@users.noreply.github.com> --- PUBLISHING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PUBLISHING.md b/PUBLISHING.md index 56bd052..4d307a8 100644 --- a/PUBLISHING.md +++ b/PUBLISHING.md @@ -11,8 +11,8 @@ - [ ] Licence: see [licenses/CHOOSING.md](licenses/CHOOSING.md). - [ ] Tests: replace `tests/` and set `test-command` in `ci.yml` and `release.yml` if needed. - [ ] Settings: required checks `ci / lint-test`, `secrets / gitleaks`, `pr / pr-title`, `DCO` - (the ruleset is in luminare-dev/.github `rulesets/main.json`); allow Actions to create pull - requests; immutable releases on. + (the ruleset is in luminare-dev/.github `rulesets/main.json`); allow Actions to create and + approve pull requests; allow auto-merge (dependabot-automerge.yml); immutable releases on. ## Before going public From 90cac73fa5e3ef1751439234b42d5a77957970ac Mon Sep 17 00:00:00 2001 From: ItsPaul <76869048+ItsPaulAT@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:32:00 +0100 Subject: [PATCH 3/4] Enhance review condition for Dependabot commits Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: ItsPaul <76869048+ItsPaulAT@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 6410110..6d761de 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -36,8 +36,8 @@ jobs: set -euo pipefail commits="$(gh api "repos/$REPO/pulls/$PR_NUMBER/commits?per_page=100")" authors="$(jq -r '[.[].author.login // "unknown"] | unique | join(",")' <<<"$commits")" - if [ "$authors" != "dependabot[bot]" ]; then - echo "::notice::Commits by $authors; left for a manual review." + if [ "$authors" != "dependabot[bot]" ] || ! jq -e 'all(.[]; .commit.verification.verified == true)' <<<"$commits" >/dev/null; then + echo "::notice::Unverified commits or commits by $authors; left for a manual review." exit 0 fi export MESSAGE From 8c9259f78a42caa147feb12e5fd5c591a02abd15 Mon Sep 17 00:00:00 2001 From: ItsPaul <76869048+ItsPaulAT@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:32:09 +0100 Subject: [PATCH 4/4] Refine version check for minor updates in workflow Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: ItsPaul <76869048+ItsPaulAT@users.noreply.github.com> --- .github/workflows/dependabot-automerge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 6d761de..30b7840 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -61,8 +61,8 @@ jobs: name = d.get("dependency-name", "?") if kind not in ("version-update:semver-patch", "version-update:semver-minor"): reasons.append(f"{name}: {kind or 'no semver update type'}") - elif kind.endswith("minor") and d.get("dependency-version", "").startswith("0."): - reasons.append(f"{name}: minor update below 1.0") + elif kind.endswith("minor") and (not d.get("dependency-version") or d["dependency-version"].removeprefix("v").startswith("0.")): + reasons.append(f"{name}: unknown version or minor update below 1.0") print("; ".join(reasons) if deps else "no update metadata") PY )"