Skip to content

Commit eb99246

Browse files
authored
Handle package-specific warning suppressions (#34289)
* handle package-specific suppressions. enable our un() to **fail** in the build stage * suppressed build warnings -> suppressed skip warnings
1 parent e0fc7d1 commit eb99246

File tree

8 files changed

+54
-28
lines changed

8 files changed

+54
-28
lines changed

eng/pipelines/templates/steps/build-package-artifacts.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ steps:
9999
ArtifactPath: '$(Build.ArtifactStagingDirectory)'
100100
ArtifactName: 'packages'
101101

102-
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
103-
parameters:
104-
ArtifactPath: '$(Build.SourcesDirectory)/.logs'
105-
ArtifactName: 'build_logs'
106-
107102
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
108103
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
109104
displayName: 'Generate BOM'
@@ -122,11 +117,6 @@ steps:
122117
ArtifactPath: '$(Build.ArtifactStagingDirectory)'
123118
ArtifactName: 'packages_${{ parameters.ArtifactSuffix }}'
124119

125-
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
126-
parameters:
127-
ArtifactPath: '$(Build.SourcesDirectory)/.logs'
128-
ArtifactName: 'build_logs_${{ parameters.ArtifactSuffix }}'
129-
130120
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
131121
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
132122
displayName: 'Generate BOM'

eng/pipelines/templates/steps/build-test.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ steps:
112112
--toxenv="samples"
113113
env: ${{ parameters.EnvVars }}
114114

115-
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
116-
parameters:
117-
ArtifactPath: '$(Build.SourcesDirectory)/.logs'
118-
ArtifactName: '$(System.StageName)_$(Agent.JobName)_logs'
119-
120115
- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
121116
parameters:
122117
ArtifactPath: '$(Build.SourcesDirectory)/_tox_logs'

scripts/devops_tasks/tox_harness.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ci_tools.ci_interactions import output_ci_warning
2121
from ci_tools.scenario.generation import replace_dev_reqs
2222
from ci_tools.functions import cleanup_directory
23+
from ci_tools.parsing import ParsedSetup
2324
from pkg_resources import parse_requirements, RequirementParseError
2425
import logging
2526

@@ -252,6 +253,7 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace) -> No
252253
skipped_tox_checks = {}
253254

254255
for index, package_dir in enumerate(targeted_packages):
256+
parsed_package = ParsedSetup.from_path(package_dir)
255257
destination_tox_ini = os.path.join(package_dir, "tox.ini")
256258
destination_dev_req = os.path.join(package_dir, "dev_requirements.txt")
257259

@@ -316,7 +318,7 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace) -> No
316318
if check not in skipped_tox_checks:
317319
skipped_tox_checks[check] = []
318320

319-
skipped_tox_checks[check].append(package_name)
321+
skipped_tox_checks[check].append(parsed_package)
320322

321323
if not filtered_tox_environment_set:
322324
logging.info(
@@ -342,7 +344,10 @@ def prep_and_run_tox(targeted_packages: List[str], parsed_args: Namespace) -> No
342344
if in_ci() and skipped_tox_checks:
343345
warning_content = ""
344346
for check in skipped_tox_checks:
345-
warning_content += f"{check} is skipped by packages: {sorted(set(skipped_tox_checks[check]))}. \n"
347+
packages_with_suppression = [pkg.name for pkg in skipped_tox_checks[check] if not pkg.is_reporting_suppressed(check)]
348+
349+
if packages_with_suppression:
350+
warning_content += f"{check} is skipped by packages: {sorted(set(packages_with_suppression))}. \n"
346351

347352
if warning_content:
348353
output_ci_warning(

sdk/storage/azure-storage-extensions/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ verifywhl = false
1010
sdist = false
1111
breaking = false
1212
bandit = false
13+
# these can be any number of suppressions. note that * present means that ALL warnings will be suppressed for this package
14+
suppressed_skip_warnings = ["*"]
1315

1416
[tool.cibuildwheel]
1517
build = ["cp38*", "cp39*", "cp310*", "cp311*", "cp312*", "pp38*", "pp39*", "pp310*"]

tools/azure-sdk-tools/ci_tools/build.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,9 @@ def create_package(
180180
setup_parsed = ParsedSetup.from_path(setup_directory_or_file)
181181

182182
if setup_parsed.ext_modules:
183-
run(
184-
[sys.executable, "-m", "cibuildwheel", "--output-dir", dist], cwd=setup_parsed.folder
185-
)
183+
run([sys.executable, "-m", "cibuildwheel", "--output-dir", dist], cwd=setup_parsed.folder, check=True)
186184

187185
if enable_wheel:
188-
run_logged(
189-
[sys.executable, "setup.py", "bdist_wheel", "-d", dist], prefix="create_wheel", cwd=setup_parsed.folder
190-
)
186+
run([sys.executable, "setup.py", "bdist_wheel", "-d", dist], cwd=setup_parsed.folder, check=True)
191187
if enable_sdist:
192-
run_logged(
193-
[sys.executable, "setup.py", "sdist", "-d", dist],
194-
prefix="create_sdist",
195-
cwd=setup_parsed.folder,
196-
)
188+
run([sys.executable, "setup.py", "sdist", "-d", dist], cwd=setup_parsed.folder, check=True)

tools/azure-sdk-tools/ci_tools/parsing/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
get_build_config,
99
get_config_setting,
1010
update_build_config,
11+
compare_string_to_glob_array
1112
)
1213

1314
__all__ = [
@@ -20,4 +21,5 @@
2021
"get_build_config",
2122
"get_config_setting",
2223
"update_build_config",
24+
"compare_string_to_glob_array"
2325
]

tools/azure-sdk-tools/ci_tools/parsing/parse_functions.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import ast
33
import textwrap
44
import re
5+
import fnmatch
56

67
try:
78
# py 311 adds this library natively
@@ -103,6 +104,12 @@ def from_path(cls, parse_directory_or_file: str):
103104
def get_build_config(self) -> Dict[str, Any]:
104105
return get_build_config(self.folder)
105106

107+
def get_config_setting(self, setting: str, default: Any = True) -> Any:
108+
return get_config_setting(self.folder, setting, default)
109+
110+
def is_reporting_suppressed(self, setting: str) -> bool:
111+
return compare_string_to_glob_array(setting, self.get_config_setting("suppressed_skip_warnings", []))
112+
106113

107114
def update_build_config(package_path: str, new_build_config: Dict[str, Any]) -> Dict[str, Any]:
108115
"""
@@ -330,3 +337,10 @@ def get_name_from_specifier(version: str) -> str:
330337
"azure-core<2.0.0,>=1.11.0" -> azure-core
331338
"""
332339
return re.split(r"[><=]", version)[0]
340+
341+
342+
def compare_string_to_glob_array(string: str, glob_array: List[str]) -> bool:
343+
"""
344+
This function is used to easily compare a string to a set of glob strings, if it matches any of them, returns True.
345+
"""
346+
return any([fnmatch.fnmatch(string, glob) for glob in glob_array])
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Used to test the individual functions in the `functions` module of azure-sdk-tools
2+
3+
import os
4+
import pytest
5+
6+
from ci_tools.parsing import ParsedSetup, compare_string_to_glob_array
7+
from typing import List
8+
9+
@pytest.mark.parametrize(
10+
"input_string, glob_array, expected_result",
11+
[
12+
("sphinx", ["*"], True),
13+
("sphinx", ["a*"], False),
14+
("sphinx", [""], False),
15+
("sphinx", ["sphinx2"], False),
16+
("sphinx", ["whl"], False),
17+
("sphinx", ["sphinx"], True),
18+
("sphinx", ["sphinx "], False),
19+
("azure-storage-blob", ["azure-*"], True),
20+
("azure-storage-blob", ["azure-storage*"], True),
21+
],
22+
)
23+
def test_compare_string_to_glob_array(input_string: str, glob_array: List[str], expected_result: bool):
24+
result = compare_string_to_glob_array(input_string, glob_array)
25+
26+
assert result == expected_result

0 commit comments

Comments
 (0)