Skip to content

feat(landprovider): basic github implementation#109

Closed
kevinlnew wants to merge 4 commits into
kevin.new/landproviderfrom
kevin.new/github-landprovider
Closed

feat(landprovider): basic github implementation#109
kevinlnew wants to merge 4 commits into
kevin.new/landproviderfrom
kevin.new/github-landprovider

Conversation

@kevinlnew
Copy link
Copy Markdown
Contributor

@kevinlnew kevinlnew commented Mar 2, 2026

Summary

feat(landprovider): basic github implementation

Why?
We need a default github implementation of the LandProvider extension for "dumb queue".

What?
Adding github implementation of the LandProvider. It uses the github merge API and wraps errors into the LandRejected sentinel error based on the HTTP code returned.

Test Plan

Unit tests, CI

Issues

Stack

  1. feat(landprovider): Adding land provider extension interface #104
  2. @ feat(landprovider): basic github implementation #109
  3. feat(controller): hooking up merge controller #105

@kevinlnew kevinlnew force-pushed the kevin.new/github-landprovider branch from d511180 to 32190ca Compare March 2, 2026 20:41
@kevinlnew kevinlnew marked this pull request as ready for review March 2, 2026 21:19
@kevinlnew kevinlnew requested review from a team, behinddwalls and sbalabanov as code owners March 2, 2026 21:19
Comment on lines +21 to +22
// (e.g., "https://api.github.com" or "https://ghe.example.com/api/v3").
APIURL string
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need it in the input? can this be encapsulated in httpClient?

// For single-PR landing, idempotency is ensured by checking if the PR is already
// merged before attempting the merge. Returns ErrAlreadyLanded if so.
func (l *landProvider) Land(ctx context.Context, queue string, entries []entity.LandEntry) error {
l.metricsScope.Counter("land_started").Inc(1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you update to use the core/metrics pkg?

return fmt.Errorf("unexpected status %d merging PR #%d: %s", resp.StatusCode, cid.PRNumber, string(body))
}

l.logger.Infow("PR merged successfully",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe debug?

Comment on lines +125 to +126
default:
return fmt.Errorf("unexpected status %d merging PR #%d: %s", resp.StatusCode, cid.PRNumber, string(body))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should this be retruned as infra retryable error?

// isPRMerged checks whether a pull request has already been merged.
// Uses the dedicated GitHub "check if merged" endpoint which returns
// 204 if merged, 404 if not merged (empty response body).
func (l *landProvider) isPRMerged(ctx context.Context, cid entitygithub.ChangeID) (bool, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we have to check for this? can we not just call merge and let it fail to know that PR is already merged?

// validateSinglePR ensures entries contain exactly one PR.
// This implementation does not support batch landing because the GitHub merge API
// operates on individual PRs, making multi-PR landing non-idempotent on retry.
func validateSinglePR(entries []entity.LandEntry) error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i guess we can let it panic if anyof this is not true? i think we are mostly checking there are some entries in there?

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.

2 participants