Skip to content
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

Use GraphQL to generate release content #3848

Merged
merged 1 commit into from
Jul 4, 2024
Merged

Use GraphQL to generate release content #3848

merged 1 commit into from
Jul 4, 2024

Conversation

ludeeus
Copy link
Member

@ludeeus ludeeus commented Jul 3, 2024

Attempt 2...

#3841 had to be reverted (in #3846) because of an issue with releases that were not latest, and not draft/pre.
That information was not in the REST API, so this had to be changed to using GraphQL...

Copy link

coderabbitai bot commented Jul 3, 2024

Walkthrough

Walkthrough

The changes primarily introduce a prerelease attribute to various components within the HACS module, enhancing the repository handling and validation processes. Exception handling and string formatting have been refactored for better readability and maintainability. Several test scripts and snapshot files have been updated to reflect these changes, with new test cases ensuring robustness and accuracy in data handling, especially focusing on handling pre-release information and improving data validation.

Changes

Files/Modules Change Summary
custom_components/hacs/repositories/base.py Added prerelease attribute to RepositoryData class, improved exception handling, and string formatting.
custom_components/hacs/utils/data.py Introduced the prerelease attribute to the data structure and updated accordingly in async_restore_repository method.
custom_components/hacs/utils/validate.py Added optional prerelease field to the validate_version function.
scripts/data/generate_category_data.py Modified GraphQL query structure, repository data handling, and error validation, refactoring logic for better data retrieval.
tests/output/proxy_calls.json Added new GitHub API endpoint URLs for category data generation tests.
tests/scripts/data/test_generate_category_data.py Adjusted file handling and added new test function for generating category data with prior content.
tests/snapshots/diagnostics/base.json Introduced prerelease field with null value.
tests/snapshots/diagnostics/exception.json Added prerelease field with null value in the HACS software package JSON object.
tests/snapshots/.../integration/data.json Added new repository entries with various attributes.
tests/snapshots/.../integration/repositories.json Included two new repositories.
tests/snapshots/.../integration/summary.json Added fields related to rate limits for core and GraphQL APIs.

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 1d5e9a6 and 4a9f3b9.

Files selected for processing (11)
  • custom_components/hacs/repositories/base.py (10 hunks)
  • custom_components/hacs/utils/data.py (3 hunks)
  • custom_components/hacs/utils/validate.py (1 hunks)
  • scripts/data/generate_category_data.py (8 hunks)
  • tests/output/proxy_calls.json (1 hunks)
  • tests/scripts/data/test_generate_category_data.py (3 hunks)
  • tests/snapshots/diagnostics/base.json (1 hunks)
  • tests/snapshots/diagnostics/exception.json (1 hunks)
  • tests/snapshots/scripts/data/generate_category_data_with_prior_content/integration/data.json (1 hunks)
  • tests/snapshots/scripts/data/generate_category_data_with_prior_content/integration/repositories.json (1 hunks)
  • tests/snapshots/scripts/data/generate_category_data_with_prior_content/integration/summary.json (1 hunks)
Additional context used
Path-based instructions (6)
tests/snapshots/scripts/data/generate_category_data_with_prior_content/integration/repositories.json (1)

Pattern tests/**/*.json: Never suggest changes to the JSON files located under the tests directory

tests/snapshots/scripts/data/generate_category_data_with_prior_content/integration/summary.json (1)

Pattern tests/**/*.json: Never suggest changes to the JSON files located under the tests directory

tests/snapshots/scripts/data/generate_category_data_with_prior_content/integration/data.json (1)

Pattern tests/**/*.json: Never suggest changes to the JSON files located under the tests directory

tests/snapshots/diagnostics/exception.json (1)

Pattern tests/**/*.json: Never suggest changes to the JSON files located under the tests directory

tests/snapshots/diagnostics/base.json (1)

Pattern tests/**/*.json: Never suggest changes to the JSON files located under the tests directory

tests/output/proxy_calls.json (1)

Pattern tests/**/*.json: Never suggest changes to the JSON files located under the tests directory

Additional comments not posted (19)
custom_components/hacs/utils/validate.py (1)

121-121: Change Approved: Added prerelease field.

The addition of the prerelease field to the validation schema looks good.

tests/scripts/data/test_generate_category_data.py (3)

60-60: Change Approved: Added snapshot validation for summary data.

The addition of snapshot validation for summary data looks good and ensures consistency.


99-105: Change Approved: Added snapshot validation for summary data.

The addition of snapshot validation for summary data looks good and ensures consistency.


107-185: Change Approved: Added test case for generating category data with prior content.

The new test case for handling prior content is comprehensive and covers various scenarios, including mocking GraphQL responses.

custom_components/hacs/utils/data.py (3)

50-50: Change Approved: Added prerelease field to exported repository data.

The addition of the prerelease field to the exported repository data looks good.


293-293: Change Approved: Added prerelease field to restored repository data.

The addition of the prerelease field to the restored repository data looks good.


306-307: Change Approved: Added logic to handle prerelease field during repository restoration.

The logic to handle the prerelease field during the repository restoration process looks good.

scripts/data/generate_category_data.py (4)

60-86: Change Approved: Added GraphQL query for fetching release information.

The addition of the GraphQL query for fetching release information looks good.


195-195: Change Approved: Added initialization for HacsDataClient.

The initialization of HacsDataClient looks good and is necessary for the new functionality.


238-292: Change Approved: Updated concurrent_update_repository to use GraphQL for fetching release data.

The update to use GraphQL for fetching release data looks good and improves the accuracy of the data retrieval process.


Line range hint 456-513: Change Approved: Added logic to validate and store fetched data.

The added logic to validate and store the fetched data ensures data integrity and consistency.

custom_components/hacs/repositories/base.py (7)

117-117: Change approved: Added prerelease to REPOSITORY_KEYS_TO_EXPORT.

The addition of the prerelease attribute is consistent with the PR objectives and appears necessary for the intended functionality.


169-169: Change approved: Added prerelease to RepositoryData class.

The addition of the prerelease attribute to the RepositoryData class aligns with the PR objectives and is necessary for the intended functionality.


574-578: Change approved: Improved exception handling in download_zip_files method.

The improved exception handling by catching BaseException and logging the error enhances robustness.


617-618: Change approved: Improved exception handling in async_download_zip_file method.

The improved exception handling by catching BaseException and logging the error enhances robustness.


727-728: Change approved: Improved exception handling in async_get_hacs_json method.

The improved exception handling by catching BaseException and logging the error enhances robustness.


829-830: Change approved: Improved exception handling in remove_local_directory method.

The improved exception handling by catching BaseException and logging the error enhances robustness.


1283-1284: Change approved: Improved exception handling in dowload_repository_content method.

The improved exception handling by catching BaseException and logging the error enhances robustness.

tests/output/proxy_calls.json (1)

1255-1270: Verify the accuracy of the added API endpoints.

The new test case test_generate_category_data_with_prior_content[category_test_data0] and its associated API endpoints have been added. Ensure these endpoints are correct and relevant to the test case.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ludeeus ludeeus merged commit b1b218a into main Jul 4, 2024
26 checks passed
@ludeeus ludeeus deleted the genrelgql branch July 4, 2024 06:10
@hacs-bot hacs-bot bot added this to the next milestone Jul 4, 2024
ludeeus added a commit that referenced this pull request Jul 4, 2024
ludeeus added a commit that referenced this pull request Jul 4, 2024
Revert "Use GraphQL to generate release content (#3848)"

This reverts commit b1b218a.
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant