Sync issue links via webhook, with a polling fallback, and detect a spec code typed in an issue #27
Labels
No labels
breaking
bug
ci
dependencies
documentation
feature
security
skip-changelog
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thierryade/backend#27
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Second slice of the Forgejo issue <-> spec link feature (see thierryade/backend#25/#26 for the first, and the plan discussed in chat).
Scope (PR 2 of 3):
ForgejoRepoWebhookmodel (one per repo,events=["issues"]), registered lazily byapps.specs.forgejo.ensure_webhook-- triggered when aProject.default_repois set/changed, or when a link (manual/create-issue) targets a repo with none yet. Deregistered (remove_webhook_if_unused) once the lastSpecVersionIssueLinkpointing at a repo is removed.POST /api/webhooks/forgejo/issues/<repo_full_name>/: verifies the delivery's HMAC signature (X-Gitea-Signature/X-Forgejo-Signature) against the repo's own secret, then (B1) syncscached_state/cached_titleon every existing link to that issue, and (B2) on anopened/editeddelivery, detects a spec code typed on its ownSpec: CODE/Thierryade: CODEline in the title/body -- creates adetected_in_bodylink for a match not already linked, drops one whose code disappeared from a later edit (never a manual/issue_buttonlink).apps.specs.tasks.poll_stale_issue_links(Celery beat, every 15 min): re-fetches every (repo, issue) pair whose last sync is stale or missing, applying the same B1/B2 rules -- the polling fallback for a missed/never-registered webhook.apps.specs.tasks.sync_confirmation_comment: posts (or edits in place, never reposts) a "🔗 Spec liée" comment on the issue, pointing back at the spec in Thierryade -- queued whenever a link is created (any of the three paths) or itscached_statechanges.THIERRYADE_BASE_URLsetting (builds the webhook callback URL and the comment's spec link) andCELERY_BEAT_SCHEDULE(nodjango-celery-beat: incompatible with this project's Django pin, so this uses Celery's own file-based scheduler -- a newthierryade-beatservice,deploy/docker-compose.yml). Also wiresFORGEJO_API_TOKEN_FILEintodeploy/docker-compose.yml/README, missed in PR 1.No extract-PDF-on-the-issue-comment yet -- that's PR 3.
Test plan
manage.py test-- 197/197 passing (35 new)pylint apps config-- 10.00/10autopep8 --diffcleanbandit -r apps config-- 0 issuesgit.stationmyr.netinstance (ensure_webhook/sync_confirmation_commentweren't mocked in a couple of PR 1 tests once this PR wired them into the same code paths)Unverified against the real Forgejo instance: the webhook registration payload shape (
type: "forgejo",config/events/secret) and the signature header name (X-Gitea-SignaturevsX-Forgejo-Signature) are per Gitea/Forgejo's documented convention, not confirmed end-to-end againstgit.stationmyr.netyet -- worth a real smoke test once this is deployed, before relying on it.