Issue filing, part A: Integrations settings and tracker adapters #94

Merged
jfro merged 2 commits from issues-52a-integrations into main 2026-11-22 17:36:58 +00:00
Owner

Refs #52 (PR A of two, D9; PR B, filing with strike + stamp, stacks on this and closes #52).

What

  • Settings › Integrations (new nav section, /settings/integrations): a card each for Forgejo (or Gitea), GitHub and Linear. Each has its own credentials, an on/off switch (off by default, even when env vars set the credentials), and a connection test that shows who the token is for and where issues can be filed.
  • RmAnalyzer.Issues context (separate from todo sync, D8) with issue_integrations (one per tracker per user, token encrypted, never rendered, logged or inspected).
  • Env vars (D10): ISSUES_FORGEJO_URL, ISSUES_FORGEJO_TOKEN, ISSUES_GITHUB_TOKEN, ISSUES_LINEAR_API_KEY. They win over the user's settings and show read-only. A Forgejo token without its URL fails boot.
  • Adapters (Issues.Tracker: check, list_targets, list_labels, create_issue), Req only:
    • Forgejo /api/v1 with token auth: repos the token can push to with issues on; repo and org labels as ids.
    • GitHub at the fixed API with X-GitHub-Api-Version: 2026-03-10: repos without push access are marked, since GitHub drops their labels; labels by name.
    • Linear GraphQL: teams with projects, team and workspace labels; errors checked on every answer, 200 included.
    • Errors 401/403/404/410/422 become messages. 429 or a spent rate limit gives {:rate_limited, seconds}. A create with no answer gives {:maybe_filed, _} and is never retried.
  • Safety: a user-entered Forgejo URL goes through Backups.Network.resolve/4 and is pinned, with no redirects. A saved token only goes to the host it was entered for. Issues.Content.title/1 strips control characters, caps titles at 255, and neutralises @name, #12 and GH-12.
  • Docs: docs/issue-filing.md.

Tests

mix precommit: 1509 passed. The new tests use stubbed Req per tracker: create, labels, picker paging, 401/403/404/410/422, 429 + retry-after, the GitHub reset header, Linear 200-with-errors, and transport errors. There are also context tests (env precedence, token kept or refused on a host move, SSRF refusal, test results kept) and LiveView tests.

Screenshots

Example data: a Forgejo with 5 repos (jfro/rm-analyzer, lodge/homelab, lodge/kuiper-forge; jfro/dotfiles has issues off and upstream/mirror is pull-only, so both are filtered out).

  • empty-390.png: all three trackers off and empty
  • connected-390.png, connected-desktop.png: Forgejo on and tested, with its repositories

The URL in the shots is a local stand-in Forgejo (127.0.0.1, allowed via BACKUP_S3_ALLOWED_NETWORKS for the shots).

Screenshots

connected-390.png

connected-390.png

connected-desktop.png

connected-desktop.png

empty-390.png

empty-390.png

Refs #52 (PR A of two, D9; PR B, filing with strike + stamp, stacks on this and closes #52). ## What - **Settings › Integrations** (new nav section, `/settings/integrations`): a card each for Forgejo (or Gitea), GitHub and Linear. Each has its own credentials, an on/off switch (off by default, even when env vars set the credentials), and a connection test that shows who the token is for and where issues can be filed. - **`RmAnalyzer.Issues`** context (separate from todo sync, D8) with `issue_integrations` (one per tracker per user, token encrypted, never rendered, logged or inspected). - **Env vars** (D10): `ISSUES_FORGEJO_URL`, `ISSUES_FORGEJO_TOKEN`, `ISSUES_GITHUB_TOKEN`, `ISSUES_LINEAR_API_KEY`. They win over the user's settings and show read-only. A Forgejo token without its URL fails boot. - **Adapters** (`Issues.Tracker`: check, list_targets, list_labels, create_issue), Req only: - Forgejo `/api/v1` with `token` auth: repos the token can push to with issues on; repo and org labels as ids. - GitHub at the fixed API with `X-GitHub-Api-Version: 2026-03-10`: repos without push access are marked, since GitHub drops their labels; labels by name. - Linear GraphQL: teams with projects, team and workspace labels; `errors` checked on every answer, 200 included. - Errors 401/403/404/410/422 become messages. 429 or a spent rate limit gives `{:rate_limited, seconds}`. A create with no answer gives `{:maybe_filed, _}` and is never retried. - **Safety**: a user-entered Forgejo URL goes through `Backups.Network.resolve/4` and is pinned, with no redirects. A saved token only goes to the host it was entered for. `Issues.Content.title/1` strips control characters, caps titles at 255, and neutralises `@name`, `#12` and `GH-12`. - Docs: `docs/issue-filing.md`. ## Tests `mix precommit`: 1509 passed. The new tests use stubbed Req per tracker: create, labels, picker paging, 401/403/404/410/422, 429 + retry-after, the GitHub reset header, Linear 200-with-errors, and transport errors. There are also context tests (env precedence, token kept or refused on a host move, SSRF refusal, test results kept) and LiveView tests. ## Screenshots Example data: a Forgejo with 5 repos (`jfro/rm-analyzer`, `lodge/homelab`, `lodge/kuiper-forge`; `jfro/dotfiles` has issues off and `upstream/mirror` is pull-only, so both are filtered out). - empty-390.png: all three trackers off and empty - connected-390.png, connected-desktop.png: Forgejo on and tested, with its repositories The URL in the shots is a local stand-in Forgejo (127.0.0.1, allowed via BACKUP_S3_ALLOWED_NETWORKS for the shots). ## Screenshots **connected-390.png** ![connected-390.png](https://git.knope.dev/attachments/33540cae-0d4d-4ccd-996c-22d05670eb96) **connected-desktop.png** ![connected-desktop.png](https://git.knope.dev/attachments/6d4c5f70-7b8c-49b5-ba7c-3ebaae8e1436) **empty-390.png** ![empty-390.png](https://git.knope.dev/attachments/c7cd6ca2-64d2-445b-91a3-1596d95dbe09)
feat(issues): Integrations settings and Forgejo, GitHub, Linear adapters
All checks were successful
CI / test (pull_request) Successful in 1m55s
df20e925e9
Refs #52 (PR A of two, D9): a new Issues context with a connection per
tracker (issue_integrations), set by ISSUES_* env vars or Settings >
Integrations, off until turned on. The adapters check a token, list where
issues can be filed and their labels, and create an issue, with rate
limits and 'may already be filed' kept apart for PR B.
fix(issues): renumber issue_integrations migration after #93's quick note migrations
All checks were successful
CI / test (pull_request) Successful in 1m47s
dc3d96a971
Both used version 20261122120000, so Ecto would refuse to migrate once
#93 and #94 merge.
jfro merged commit 5d2c7951a7 into main 2026-11-22 17:36:58 +00:00
jfro deleted branch issues-52a-integrations 2026-11-22 17:36:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!94
No description provided.