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

{CI} Add build wheel check and extension name check #7131

Merged
merged 9 commits into from
Dec 28, 2023
30 changes: 28 additions & 2 deletions scripts/ci/azdev_linter_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
import json
import logging
import os
import shutil
from subprocess import check_call, check_output, CalledProcessError

import service_name
from pkg_resources import parse_version

import service_name
from util import get_ext_metadata

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
Expand Down Expand Up @@ -87,7 +90,28 @@ def style(self):
self._cmd('azdev style {}'.format(self.extension_name))

def build(self):
pass
self._cmd('azdev extension build {}'.format(self.extension_name))

def check_extension_name(self):
original_cwd = os.getcwd()
dist_dir = os.path.join(original_cwd, 'dist')
files = os.listdir(dist_dir)
logger.info(f"wheel files in the dist directory: {files}")
logger.info(f"extension name is: {self.extension_name}")
for f in files:
if f.endswith('.whl'):
ext_file = os.path.join(dist_dir, f)
break
metadata = get_ext_metadata(dist_dir, ext_file, self.extension_name)
logger.info(f"metadata name in setup.py is: {metadata['name']}")
shutil.rmtree(dist_dir)
if '_' in self.extension_name:
raise ValueError(f"Underscores `_` are not allowed in the extension root directory, "
f"please change it to a hyphen `-`.")
if metadata['name'] != self.extension_name:
raise ValueError(f"The name {metadata['name']} in setup.py "
f"is not the same as the extension name {self.extension_name}! \n"
f"Please fix the name in setup.py!")


def find_modified_files_against_master_branch():
Expand Down Expand Up @@ -200,6 +224,8 @@ def azdev_on_internal_extension(modified_files, azdev_type):
azdev_extension.add_from_code()
if azdev_type in ['all', 'linter']:
azdev_extension.linter()
azdev_extension.build()
azdev_extension.check_extension_name()
if azdev_type in ['all', 'style']:
try:
azdev_extension.style()
Expand Down