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

Add Keyword Check #31823

Merged
merged 11 commits into from
Sep 7, 2023
Prev Previous commit
Next Next commit
add the classifier check. currently failing as none of the packages h…
…ave an azure-sdk classifer
  • Loading branch information
scbedd committed Aug 26, 2023
commit 64740f349fe0f18e08df5e09f36f5a49d2b9a19d
14 changes: 14 additions & 0 deletions eng/tox/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,19 @@ commands =
python {repository_root}/scripts/devops_tasks/test_run_samples.py -t {tox_root}


[testenv:classifiers]
description="Ensures that the classifiers for a given package align with azure-sdk requirements."
skipsdist = true
skip_install = true
setenv =
{[testenv]setenv}
PROXY_URL=http://localhost:5005
deps =
{[base]deps}
commands =
sdk_verify_classifiers -t {tox_root}


[testenv:breaking]
description=Runs the breaking changes checker against a package
skipsdist = true
Expand All @@ -512,6 +525,7 @@ commands =
--package-type sdist
python {repository_root}/scripts/breaking_changes_checker/detect_breaking_changes.py -t {tox_root}


[testenv:black]
description=Runs the code formatter black
skip_install=true
Expand Down
36 changes: 36 additions & 0 deletions tools/azure-sdk-tools/ci_tools/classifiers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import argparse
import logging

from ci_tools.parsing import ParsedSetup
from ci_tools.variables import in_ci
from ci_tools.environment_exclusions import is_check_enabled

def verify_classifiers() -> None:
parser = argparse.ArgumentParser(
description="""This is the primary entrypoint for the "build" action. This command is used to build any package within the azure-sdk-for-python repository.""",
)

parser.add_argument(
"-t",
"--target",
dest="target",
help=("Directory containing a setup.py"),
)

args = parser.parse_args()

pkg_details = ParsedSetup.from_path(args.target)

if in_ci():
if not is_check_enabled(args.target_package, "pylint"):
logging.info(
f"Package {pkg_details.name} opts-out of pylint check."
)
exit(0)

if "azure-sdk" not in pkg_details.classifiers:
scbedd marked this conversation as resolved.
Show resolved Hide resolved
print(f"Classifier 'azure-sdk' not present in classifers for {pkg_details.name}. Before attempting publishing, ensure that package {pkg_details.name} has classifier 'azure-sdk' present in the classifier set.")
exit(1)
else:
exit(0)

3 changes: 2 additions & 1 deletion tools/azure-sdk-tools/ci_tools/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fnmatch
import subprocess
import shutil
from ast import Not

from packaging.specifiers import SpecifierSet
from packaging.version import Version, parse, InvalidVersion
from pkg_resources import Requirement
Expand Down Expand Up @@ -541,3 +541,4 @@ def discover_prebuilt_package(dist_directory: str, setup_path: str, package_type
if prebuilt_package is not None:
packages.append(prebuilt_package)
return packages

1 change: 1 addition & 0 deletions tools/azure-sdk-tools/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"sdk_increment_version=ci_tools.versioning.version_increment:version_increment_main",
"sdk_analyze_deps=ci_tools.dependency_analysis:analyze_dependencies",
"sdk_find_invalid_versions=ci_tools.versioning.find_invalid_versions:find_invalid_versions_main",
"sdk_verify_classifiers=ci_tools.classifiers:verify_classifiers",
"multiapi_combiner=packaging_tools.multiapi_combiner:combine",
],
},
Expand Down