Skip to content

[EPAC-2011]: inherit Linear projectId from originating PR's EPAC issue#586

Merged
riddim-developer-bot[bot] merged 1 commit into
mainfrom
symphony/epac-2011-inherit-linear-projectid-from-originating-pr-s-e
May 25, 2026
Merged

[EPAC-2011]: inherit Linear projectId from originating PR's EPAC issue#586
riddim-developer-bot[bot] merged 1 commit into
mainfrom
symphony/epac-2011-inherit-linear-projectid-from-originating-pr-s-e

Conversation

@riddim-developer-bot

Copy link
Copy Markdown
Contributor

Why

CI-failure issues created by the handler landed unparented in Linear. When a workflow fails after a PR merge, the failure issue should inherit the originating PR's EPAC issue's Linear project so it appears in the same project view as the work that caused it.

What changed

  • GitHubPRClient: New thin client with find_pr_for_commit(repo, sha) that calls GET /repos/{owner}/{repo}/commits/{sha}/pulls, preferring the PR whose merge_commit_sha matches the head SHA and falling back to the first PR.
  • PRInfo / OriginatingContext: Value objects carrying the originating PR metadata and optional Linear project inheritance.
  • extract_linear_id(pr_title): Regex \bEPAC-\d+\b extracts the first EPAC identifier from a PR title. Non-EPAC prefixes are ignored.
  • LinearClient.get_issue_project_id(identifier): GraphQL query returning the originating issue's projectId (or None if unparented/missing).
  • resolve_originating_context: Orchestrates the lookup chain (GitHub PR → regex → Linear project). Best-effort: any failure is logged and falls through to unparented creation.
  • report_ci_workflow_outcome: Accepts optional github_client; on the create path, resolves originating context, sets projectId on the new issue, and appends a "Triggered by" footer linking back to the PR and originating EPAC issue.
  • LinearIssueRequest.project_id: New optional field; create_issue includes projectId in the mutation payload when set.
  • Workflow YAML: Added pull-requests: read permission and GITHUB_TOKEN env var.

Trade-offs not taken

  • Separate scripts/ci/github_pr_client.py module: kept inline with the existing single-file pattern since the client is thin (one method) and the script has no other modules.
  • Caching across handler runs: unnecessary since each workflow_run event is a single invocation.
  • Cross-team ID parsing (e.g. AUTO-XXX): out of scope per the issue.

Test plan

Unit tests cover all 6 AC scenarios plus extract_linear_id edge cases (22 tests, all passing):

  • (a) PR found + Linear ID matches + issue has projectId → inherits projectId, footer present
  • (b) PR found + Linear ID matches + issue unparented → no projectId, footer present
  • (c) PR found + no Linear ID regex match → no projectId, no footer
  • (d) No PR for SHA (direct push) → no projectId, no footer
  • (e) GitHub API failure → graceful no-op, issue still created
  • (f) Linear project lookup failure → graceful no-op, issue still created with footer
$ python3 -m pytest scripts/ci/tests/test_ci_failure_to_linear.py -v
22 passed in 0.05s

Verification evidence

  • All 22 unit tests pass
  • Existing EPAC-2009/2010 dedup and auto-close behavior unchanged (dedup path is untouched)
  • Workflow actionlint passes (pre-commit hook validated)

Resolves EPAC-2011

Reviewer-Boundary: review-only

When the CI failure handler creates a new Linear issue, it now looks up
the originating PR via head_sha, extracts the EPAC-XXXX identifier from
the PR title, queries Linear for that issue's projectId, and sets it on
the new CI-failure issue. A "Triggered by" footer with PR and issue links
is appended to the description when both are available.

The lookup is best-effort: GitHub or Linear API failures are logged and
the issue is created without project inheritance.
@riddim-developer-bot riddim-developer-bot Bot added the autonomous Enrolled in prconverged daemon for automated review and merge label May 25, 2026
@riddim-developer-bot riddim-developer-bot Bot enabled auto-merge (squash) May 25, 2026 14:52
@riddim-developer-bot riddim-developer-bot Bot merged commit bb4bbd9 into main May 25, 2026
5 checks passed
@riddim-developer-bot riddim-developer-bot Bot deleted the symphony/epac-2011-inherit-linear-projectid-from-originating-pr-s-e branch May 25, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autonomous Enrolled in prconverged daemon for automated review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants