Skip to content

Commit 33c1cb3

Browse files
committed
ci: grant actions:read, count jobs safely, cover bundler
Three fixes from the second review on #844. Add `actions: read`. Declaring a permissions block sets every unnamed scope to none, and the coverage gate lists the triggering run's jobs, so the Actions API would have returned 403 and aborted the step on every Dependabot pull request. It fails closed, but the automation would never have merged anything. commitlint-comment.yaml declares the same scope for the same reason. Count job names instead of asking jq for a length. `--paginate` applies `-q` per page, so a run spanning two pages yields one count per line ("18\n4"), and `[[ "18\n4" -eq 0 ]]` is an arithmetic syntax error that evaluates false — skipping the refusal and merging. Verified in bash: the multi-line form errors with "syntax error in expression" and takes the else branch. Single-page today at 22 jobs, but the failure direction is fail-open, and the headroom is smaller than it looks. Add the bundler ecosystem for examples/sinatra/app/src/Gemfile, which the original sweep missed. Beyond grouping, this is what gives those PRs a conventional commit prefix: Commit Lint runs on every pull request with no path filter, and #799 shows what the default message costs — commit "bump com.fasterxml.jackson.core:jackson-databind", Lint Commit Messages red.
1 parent f314573 commit 33c1cb3

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,22 @@ updates:
105105
applies-to: security-updates
106106
patterns:
107107
- "*"
108+
109+
# examples/sinatra/app/src/Gemfile. Easy to miss, and the cost of missing it is not
110+
# just ungrouped PRs: without `prefix: chore` Dependabot writes "bump rack from ...",
111+
# which has no conventional type, and Commit Lint runs on every pull request with no
112+
# path filter. #799 is the evidence — its commit message is
113+
# "bump com.fasterxml.jackson.core:jackson-databind" and its Commit Lint check is red.
114+
- package-ecosystem: bundler
115+
directories:
116+
- "/examples/**"
117+
schedule:
118+
interval: weekly
119+
open-pull-requests-limit: 0
120+
commit-message:
121+
prefix: chore
122+
groups:
123+
examples-bundler:
124+
applies-to: security-updates
125+
patterns:
126+
- "*"

.github/workflows/dependabot-automerge.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ on:
2020
permissions:
2121
contents: write
2222
pull-requests: write
23+
# Required to list the triggering run's jobs. Declaring a permissions block sets
24+
# every scope not named here to none, so without this the Actions API returns 403
25+
# and the step aborts on every Dependabot pull request. Same reason
26+
# commitlint-comment.yaml declares it.
27+
actions: read
2328

2429
jobs:
2530
merge:
@@ -98,9 +103,15 @@ jobs:
98103
exit 0
99104
fi
100105
101-
# Covered examples are only actually verified if their jobs ran.
106+
# Covered examples are only actually verified if their jobs ran. Count lines
107+
# rather than asking jq for a length: --paginate applies -q per page, so a
108+
# run spanning two pages would yield one count per line ("18\n4"), and
109+
# `[[ "18\n4" -eq 0 ]]` is an arithmetic syntax error that evaluates false —
110+
# skipping the refusal below and merging. Only the job total keeps this
111+
# single-page today, which is not a property worth depending on.
102112
verified=$(gh api "repos/$REPO/actions/runs/$RUN_ID/jobs" --paginate \
103-
-q '[.jobs[] | select(.name | startswith("test-")) | select(.conclusion == "success")] | length')
113+
-q '.jobs[] | select(.name | startswith("test-")) | select(.conclusion == "success") | .name' \
114+
| wc -l)
104115
if [[ "$verified" -eq 0 ]]; then
105116
echo "No test-* job succeeded in run $RUN_ID; refusing to merge."
106117
exit 0

0 commit comments

Comments
 (0)