Skip to content

feat: add getCheckRunByName to look up check run ID by commit ref and…#109

Open
HarshMN2345 wants to merge 3 commits into
mainfrom
feat/get-check-run-by-name
Open

feat: add getCheckRunByName to look up check run ID by commit ref and…#109
HarshMN2345 wants to merge 3 commits into
mainfrom
feat/get-check-run-by-name

Conversation

@HarshMN2345
Copy link
Copy Markdown
Member

… name

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This PR adds getCheckRunByName(), a method that looks up a GitHub check-run ID given a commit ref and check name, using the GitHub check-runs API with filter=latest and per_page=1 to retrieve the most recently created matching run.

  • src/VCS/Adapter.php — adds the stub method following the established "not implemented" pattern for the abstract adapter base.
  • src/VCS/Adapter/Git/GitHub.php — implements the lookup; on HTTP ≥ 400 it returns 0 instead of throwing (consistent with the documented "0 if none found" contract, confirmed by testGetCheckRunByNameInvalidRepositoryReturnsZero).
  • tests/VCS/Adapter/GitHubTest.php — adds five integration tests: happy path, name-mismatch returns zero, invalid repo returns zero, most-recent wins when duplicates exist, and a full create → lookup → update end-to-end flow.

Confidence Score: 5/5

Safe to merge; the new method is additive, follows established patterns, and is guarded by a thorough integration test suite.

The implementation is a straightforward additive read-only API call with no mutation risk. The silent-zero-on-error contract is intentional, well-documented in code comments, and exercised by a dedicated test. The five integration tests cover all the meaningful branches.

No files require special attention. The testGetCheckRunByNameReturnsMostRecent test has a minor readability nuance around assertGreaterThan argument order, but the assertion itself is correct.

Important Files Changed

Filename Overview
src/VCS/Adapter.php Adds getCheckRunByName() stub to the abstract base class, consistent with the existing pattern of throwing 'not implemented' for adapter-level stubs.
src/VCS/Adapter/Git/GitHub.php Implements getCheckRunByName against the GitHub check-runs API using filter=latest and per_page=1; returns 0 on HTTP errors (intentional graceful-fallback contract) rather than throwing, consistent with the method's documented semantics.
tests/VCS/Adapter/GitHubTest.php Adds five integration tests covering the happy path, no-name-match, invalid repo, most-recent-run, and end-to-end create-lookup-update workflow; each test creates and cleans up its own repository in a finally block.

Reviews (1): Last reviewed commit: "test: rewrite getCheckRunByName tests — ..." | Re-trigger Greptile

status: 'in_progress',
);

$this->assertGreaterThan($first['id'], $second['id']);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The assertGreaterThan before calling getCheckRunByName is used to validate that GitHub assigned a higher ID to the second run, but it's also a load-bearing pre-condition of the test: if GitHub ever returns equal IDs (e.g. the same check run was deduplicated), the assertion fails before the actual behavior is exercised. Swapping the argument order also silently inverts the comparison — assertGreaterThan($expected, $actual) means "assert that $expected > $actual", so assertGreaterThan($first['id'], $second['id']) asserts that $first['id'] > $second['id'], which is the opposite of what the comment says. Here the call is correct as written — but consider using assertLessThan for clarity: assertLessThan($second['id'], $first['id']) reads more naturally as "first is less than second".

Suggested change
$this->assertGreaterThan($first['id'], $second['id']);
$this->assertLessThan($second['id'], $first['id']);

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant