Give a push-triggered job somewhere to report a failure #15
Labels
Clear labels
Compat
Breaking
Breaking change that won't be backward compatible
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Question
A question that has to be answered before the work can be specified
Kind
Security
This is security issue
Kind
Testing
Issue or pull request related to testing
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Medium
3
The priority is medium
Priority
Low
4
The priority is low
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
4
This issue won't be fixed
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Status
On Hold
3
Deliberately deferred. Not blocked by a dependency and not waiting on a fact
Status
Abandoned
4
Somebody has started to work on this but abandoned work
Type
Bug
Something is not working
Type
Chore
Infrastructure, CI, tooling or packaging. No user-visible change
Type
Epic
An umbrella issue with sub-issues. Never worked directly
Type
Meta
About how work is done here rather than about the code
Type
Spike
The deliverable is a measurement or a decision, not merged code
Type
Task
An ordinary unit of work with a deliverable. The default
No labels
Milestone
No items
No Milestone
Notifications
Due Date
No due date set.
Reference: weblib/weblib-ci#15
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem.
report_job_log.pyonly ever commented on an open pullrequest. A
push-triggered job -- the shape of a publish pipeline, which hasno
pull_requesttrigger at all -- has none: the branch pushed to is themerge's target, not the already-closed PR that produced it. Combined with
job logs returning 500 on this Gitea, that made a push-triggered failure
completely invisible. Real cost: weblib-viewer run 1769 (
publish,pushondevelopment) failed after ~12.5 minutes and posted nothing anywhere;diagnosing it needed a throwaway commit hardcoding
--pr 27just to get thelog somewhere visible. Filed as #14.
What I checked first. A GitHub-style commit-comment endpoint
(
commits/{sha}/comments) does not exist on this Gitea: 404, and it isabsent from
/swagger.v1.jsonentirely -- not a permissions or path issue,the route simply is not registered. Ruled out with the swagger dump, not
just the one probe #14 already had.
What actually works, verified live against
git.chaosbit.de:GET repos/{repo}/commits/{sha}/pullresolves the PR that produced a givencommit, open or closed, keyed on the exact commit rather than a branch
name. Checked against both merge styles this org uses: an explicit merge
commit (weblib-ci#13 ->
8c00889...) and a fast-forward promotion, wherethe "merge commit" is just the PR branch's own tip (weblib-fs#27 ->
1aaad66...). Both resolved to the right PR number. It needs the full40-character sha -- a short one gets the identical 404 shape as a commit
with no PR at all, so truncating it would silently look like "nothing
found" rather than erroring loudly.
POST repos/{repo}/statuses/{sha}(commit status) is the fallback for theresidual case: a commit that was never part of any PR. Verified it accepts
a long description unmodified (3000 chars round-tripped exactly), and did
a full live run of the actual script against this repo -- see below.
What changed. Before giving up,
report_job_log.pynow tries thesha-based PR lookup after the existing event-payload and branch-name lookups.
If a PR is found (open or closed), behaviour is identical to before: the
same comment, same format. Only when no PR exists anywhere for the commit
does it fall back to a commit status -- shorter (
STATUS_TAIL, 500characters, truncated from the log tail) and less discoverable than a
comment, but not silence.
statefollows the reported outcome(
failed→failure,passed→success,cancelled→warning,skipped→skipped; an unrecognised status maps toerrorrather thanguessing pass or fail), and
target_urlpoints at the commit.No CLI changes -- existing callers (all four consumer repos) are unaffected;
the whole thing is additive to the environment-variable-driven path they
already use.
Verification:
python3 test_report_job_log.py: 28/28 (was 22/22; +6 new testscovering the sha-lookup success case, ordering -- branch lookup still wins
when it applies -- the commit-status fallback with the outcome-to-state
mapping, the no-sha/no-PR dead end not crashing, and that the ordinary
pull_request-event path is untouched).repo, this branch's own tip commit (
c2947db0, which has no PR yet):resolved to "no PR anywhere" and posted a real commit status --
state: success, correct description andtarget_url, confirmed byreading it back via the API. That status is visible on this PR's own head
commit.
Not done: the "reuse/dedup an issue" option from #14 was not built -- the
sha lookup turned out to cover the actual failure case (a push is almost
always a merge landing) well enough that the noisier issue-based fallback
didn't seem worth the complexity. Worth revisiting only if a repo here ever
pushes commits that were never part of any PR as routine practice.
Closes #14
report_job_log.py only ever commented on an open PR, so a push to development/main -- the shape of a publish pipeline, which has no pull_request trigger -- had nowhere to post: the branch pushed to is the merge's target, not the already-closed PR that produced it. Combined with job logs 500ing on this Gitea, that made a push-triggered failure completely invisible (weblib-viewer run 1769, diagnosed only by hardcoding --pr on a throwaway commit). A GitHub-style commit-comment endpoint, the first thing tried, does not exist on this Gitea: 404, and absent from /swagger.v1.json entirely. What does exist and was verified live: GET commits/{sha}/pull resolves the PR that produced a given commit, open or closed, across both merge styles this org uses -- so the closed PR the push actually came from can still be found and commented on as before. When even that finds nothing (a commit that was never part of any PR), fall back to a commit status, since that endpoint is already proven to work here. No CLI changes; existing callers are unaffected. Closes #14 Co-authored-by: bit <bit@das-labor.org>