From 3d29ed3431ef556099186277a49e27ddbd5ca661 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 20 Nov 2024 14:47:06 +0800 Subject: [PATCH] sample-collection, limit list-releases to 5000 items (#9407) --- .../automation/main.py | 4 ++++ .../dotnet/test_main.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/azure-rest-api-specs-examples-automation/automation/main.py b/tools/azure-rest-api-specs-examples-automation/automation/main.py index 1a8b3140f44..560b799f250 100644 --- a/tools/azure-rest-api-specs-examples-automation/automation/main.py +++ b/tools/azure-rest-api-specs-examples-automation/automation/main.py @@ -262,6 +262,7 @@ def process_sdk(operation: OperationConfiguration, sdk: SdkConfiguration, report logging.info(f"Processing sdk: {sdk.name}") count = 0 + max_count = 5000 releases: List[Release] = [] repo = GitHubRepository(sdk.repository_owner, sdk.repository_name, github_token) # since there is no ordering from GitHub, just get all releases (exclude draft=True), and hope paging is correct @@ -283,6 +284,9 @@ def process_sdk(operation: OperationConfiguration, sdk: SdkConfiguration, report release = Release(release_tag, package, version, published_at) releases.append(release) logging.info(f"Found release tag: {release.tag}") + if count > max_count: + # typically we only need releases from recent 10 days, abort before hit GitHub rate limit + break except Exception as e: report.aggregated_error.errors.append(e) break diff --git a/tools/azure-rest-api-specs-examples-automation/dotnet/test_main.py b/tools/azure-rest-api-specs-examples-automation/dotnet/test_main.py index 0ff3b5388b0..53c79a89638 100644 --- a/tools/azure-rest-api-specs-examples-automation/dotnet/test_main.py +++ b/tools/azure-rest-api-specs-examples-automation/dotnet/test_main.py @@ -3,6 +3,7 @@ from main import break_down_aggregated_dotnet_example, format_dotnet, get_dotnet_using_statements from typing import List + class TestMain(unittest.TestCase): @parameterized.parameterized.expand( [ @@ -378,12 +379,12 @@ def test_break_down_aggregated_dotnet_example(self, file_content: str): "using Azure.ResourceManager.Compute.Models;\n", "using Azure.ResourceManager.Resources;\n", "using Azure.ResourceManager.Resources.Models;\n", - ] + ], ) ] ) def test_example_usings(self, content: str, expected_usings: List[str]): lines = content.splitlines(keepends=True) usings = get_dotnet_using_statements(lines) - + self.assertSetEqual(set(expected_usings), set(usings))