Skip to content

Use GraphQL to collect eng/common from GitHub #4828

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

premun
Copy link
Member

@premun premun commented May 9, 2025

@Copilot Copilot AI review requested due to automatic review settings May 9, 2025 14:50
Copy link
Contributor

@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 migrates GitHub file retrieval to use GraphQL, reducing rate limiting issues and improving performance. Key changes include:

  • Removing legacy caching and abuse retry tests.
  • Removing memory cache support from RemoteRepoBase and adjusting dependent constructors.
  • Updating GitHubClient to perform file retrieval via GraphQL with added logging and caching.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Microsoft.DotNet.DarcLib.Tests/GitHubClientTests.cs Removed tests for caching and abuse exception retry scenarios
src/Microsoft.DotNet.Darc/DarcLib/RemoteRepoBase.cs Removed memory cache parameter and property to simplify repository access
src/Microsoft.DotNet.Darc/DarcLib/LocalLibGit2Client.cs Added error handling around file mode conversion with improved logging
src/Microsoft.DotNet.Darc/DarcLib/Helpers/GitFile.cs Updated newline logic for content normalization
src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs Implemented GraphQL query execution with caching and improved error handling
src/Microsoft.DotNet.Darc/DarcLib/AzureDevOpsClient.cs Adjusted base constructor call to reflect changes in caching support
Comments suppressed due to low confidence (1)

test/Microsoft.DotNet.DarcLib.Tests/GitHubClientTests.cs:191

  • The removal of caching and abuse exception tests reduces test coverage for key scenarios. Please ensure that the new GraphQL integration is adequately tested.
[TestCase(true)]

}
catch
{
_logger.LogError("Failed to parse file mode {mode} for file {ilePath}", file.Mode, file.FilePath);
Copy link
Preview

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

The log message placeholder '{ilePath}' appears to be a typo. Consider updating it to '{filePath}' for clarity.

Suggested change
_logger.LogError("Failed to parse file mode {mode} for file {ilePath}", file.Mode, file.FilePath);
_logger.LogError("Failed to parse file mode {mode} for file {filePath}", file.Mode, file.FilePath);

Copilot uses AI. Check for mistakes.

Comment on lines +773 to +776
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DarcLib", DarcLibVersion));
Copy link
Preview

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

Creating a new HttpClient instance for every GraphQL query may lead to socket exhaustion. Consider using IHttpClientFactory or reusing a shared HttpClient instance.

Suggested change
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DarcLib", DarcLibVersion));
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
_httpClient.DefaultRequestHeaders.UserAgent.Clear();
_httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DarcLib", DarcLibVersion));

Copilot uses AI. Check for mistakes.

@premun premun marked this pull request as draft May 9, 2025 15:01
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