Skip to content

GitHub Service Improvements #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 16, 2025
Merged

GitHub Service Improvements #143

merged 8 commits into from
Apr 16, 2025

Conversation

GrantBirki
Copy link
Member

@GrantBirki GrantBirki commented Apr 15, 2025

GitHub Service Improvements

This pull request does the following:

  • Refactors the organization_members() to make it bit easier to read.
  • Adds the retryable gem to the project as a runtime dep and assigns it a standard configuration.
  • Wraps all network calls through octokit with a retryable block for unhandled exception classes.
  • Bumps the per_page setting of Octokit from 30 -> 100. This changes it from the default to the max.
  • Adds more unit tests to cover potential edge cases.

A pretty significant bonus of setting the per_page default from 30 -> 100 is an increase in performance for large organizations. Specifically orgs with a few thousand members (or more), will see a performance bump here.

@GrantBirki GrantBirki self-assigned this Apr 15, 2025
@GrantBirki GrantBirki added the enhancement New feature or request label Apr 15, 2025
@GrantBirki GrantBirki marked this pull request as ready for review April 15, 2025 23:32
@Copilot Copilot AI review requested due to automatic review settings April 15, 2025 23:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the GitHub service integration by refactoring organization member retrieval for clarity and performance, adding retry logic to network calls, and enhancing test coverage.

  • Refactors organization member fetching to use retryable wrappers
  • Increases Octokit per_page setting for better performance on large orgs
  • Adds additional unit tests for various edge cases

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/unit/spec_helper.rb Adds stubs for sleep to bypass delays in tests
spec/unit/entitlements/service/github_spec.rb Adds new contexts for admin/member edge cases
spec/unit/entitlements/backend/github_team/service_spec.rb Adjusts test expectations for retry behavior
lib/entitlements/service/github.rb Refactors methods to use Retryable, increases per_page
lib/entitlements/config/retry.rb Adds custom Retryable configuration
lib/entitlements/backend/github_team/service.rb Wraps GitHub team API calls in retryable blocks
lib/entitlements/backend/github_team.rb Adds Retry setup call
lib/entitlements/backend/github_org/service.rb Wraps organization membership updates in retryable
lib/entitlements/backend/github_org.rb Adds Retry setup call
entitlements-github-plugin.gemspec Adds dependency on retryable gem
Comments suppressed due to low confidence (1)

spec/unit/entitlements/backend/github_team/service_spec.rb:848

  • [nitpick] Hardcoding the retry count as exactly 3 times may lead to brittle tests if the retry configuration is updated in the future. Consider using the configured retry value or a more flexible expectation to ensure the test remains robust.
expect(octokit).to receive(:team).with(1234).and_raise(exc).exactly(3).times

@GrantBirki GrantBirki merged commit 6472bf3 into main Apr 16, 2025
13 checks passed
@GrantBirki GrantBirki deleted the github-service-improvements branch April 16, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants