Skip to content

Commit 37369cf

Browse files
committed
Dispatch tests after predictable conflict resolutions
1 parent eb21eaa commit 37369cf

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

.github/actions/github/resolve-predictable-conflicts/run.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,32 @@ is_allowed_conflict_scope() {
5858
return 0
5959
}
6060

61+
dispatch_required_tests() {
62+
local head_ref="$1"
63+
64+
if ! gh workflow view tests.yml >/dev/null 2>&1; then
65+
append_summary " - tests dispatch skipped: tests.yml workflow was not found"
66+
67+
return 0
68+
fi
69+
70+
if gh workflow run tests.yml --ref "${head_ref}" -f max-outdated=-1 -f publish-required-statuses=true >/dev/null 2>&1; then
71+
append_summary " - tests dispatch requested with required status mirroring"
72+
73+
return 0
74+
fi
75+
76+
if gh workflow run tests.yml --ref "${head_ref}" >/dev/null 2>&1; then
77+
append_summary " - tests dispatch requested without required status mirroring"
78+
79+
return 0
80+
fi
81+
82+
append_summary " - failed: resolved branch was pushed, but tests.yml could not be dispatched"
83+
84+
return 1
85+
}
86+
6187
resolve_pull_request() {
6288
local number="$1"
6389
local title="$2"
@@ -162,6 +188,13 @@ resolve_pull_request() {
162188
git -C "${workdir}/repo" commit -m "Resolve predictable conflicts with ${base_ref}" >/dev/null 2>&1
163189
git -C "${workdir}/repo" push origin "HEAD:${head_ref}" >/dev/null 2>&1
164190
append_summary " - resolved: pushed an automatic conflict-resolution commit for \`${title}\`"
191+
192+
if ! dispatch_required_tests "${head_ref}"; then
193+
failed_count=$((failed_count + 1))
194+
195+
return
196+
fi
197+
165198
resolved_count=$((resolved_count + 1))
166199
}
167200

.github/workflows/auto-resolve-conflicts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ on:
3131
types: [opened, reopened, synchronize, ready_for_review]
3232

3333
permissions:
34+
actions: write
3435
contents: write
3536
pull-requests: write
3637

docs/advanced/branch-protection-and-bot-commits.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ the only conflicts are ``.github/wiki`` pointer drift and/or ``CHANGELOG.md``
118118
``Unreleased`` drift. It keeps pull request wiki preview pointers on the branch
119119
side and replays branch-only changelog entries into the current base
120120
``Unreleased`` section, which avoids placing new entries under a freshly
121-
published release after ``main`` moved.
121+
published release after ``main`` moved. Because those automatic resolutions are
122+
also pushed with the built-in workflow token, the workflow dispatches
123+
``tests.yml`` for the refreshed branch after a successful push so required test
124+
statuses can be reported for the new commit.
122125

123126
At a high level, the workflows need permission to read repository contents,
124127
write generated preview commits, update pull request comments, and publish Pages
@@ -150,6 +153,11 @@ pointer updates, ``actions: write`` to dispatch ``tests.yml`` after bot-authored
150153
pointer commits, and ``pull-requests: read`` to inspect pull request metadata
151154
safely.
152155

156+
``auto-resolve-conflicts.yml`` keeps ``contents: write`` so it can push
157+
predictable conflict-resolution commits, ``pull-requests: write`` so it can
158+
inspect pull request state through GitHub tooling, and ``actions: write`` so it
159+
can dispatch ``tests.yml`` after it pushes a bot-authored resolution commit.
160+
153161
``wiki-maintenance-entry.yml`` and ``wiki-maintenance.yml`` keep
154162
``contents: write`` for wiki publication and cleanup tasks, and
155163
``pull-requests: read`` on jobs that need to distinguish merged, closed, and

resources/github-actions/auto-resolve-conflicts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
default: ''
2424

2525
permissions:
26+
actions: write
2627
contents: write
2728
pull-requests: write
2829

0 commit comments

Comments
 (0)