Skip to content

Commit

Permalink
updates to support non-azure package during linting and whl verificat…
Browse files Browse the repository at this point in the history
…ion (Azure#15055)

* updates to support non-azure package during linting and whl verification

* update coverage paths from opentelemetry to microsoft
  • Loading branch information
scbedd authored Nov 9, 2020
1 parent 244ec1a commit 2a26c2b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
12 changes: 10 additions & 2 deletions eng/tox/run_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

from allowed_pylint_failures import PYLINT_ACCEPTABLE_FAILURES

from tox_helper_tasks import (
get_package_details
)

logging.getLogger().setLevel(logging.INFO)

root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
Expand All @@ -37,7 +41,11 @@

args = parser.parse_args()

package_name = os.path.basename(os.path.abspath(args.target_package))

pkg_dir = os.path.abspath(args.target_package)
package_name, namespace, ver = get_package_details(os.path.join(pkg_dir, "setup.py"))

top_level_module = namespace.split('.')[0]

if package_name not in PYLINT_ACCEPTABLE_FAILURES:
try:
Expand All @@ -48,7 +56,7 @@
"pylint",
"--rcfile={}".format(rcFileLocation),
"--output-format=parseable",
os.path.join(args.target_package, "azure"),
os.path.join(args.target_package, top_level_module),
]
)
except CalledProcessError as e:
Expand Down
2 changes: 2 additions & 0 deletions eng/tox/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ deps =
source =
azure
**/azure
microsoft
**/microsoft


[base]
Expand Down
1 change: 0 additions & 1 deletion eng/tox/tox_helper_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

logging.getLogger().setLevel(logging.INFO)


def get_package_details(setup_filename):
mock_setup = textwrap.dedent(
"""\
Expand Down
14 changes: 8 additions & 6 deletions eng/tox/verify_whl.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def extract_whl(dist_dir, version):
return extract_location


def verify_whl_root_directory(dist_dir, version):
# This method ensures root directory in whl is azure only

def verify_whl_root_directory(dist_dir, expected_top_level_module, version):
# This method ensures root directory in whl is the directoy indicated by our top level namespace
extract_location = extract_whl(dist_dir, version)
root_folders = os.listdir(extract_location)

# check for non 'azure' folder as root folder
non_azure_folders = [
d for d in root_folders if d != "azure" and not d.endswith(".dist-info")
d for d in root_folders if d != expected_top_level_module and not d.endswith(".dist-info")
]
if non_azure_folders:
logging.error(
Expand Down Expand Up @@ -107,11 +107,13 @@ def should_verify_package(package_name):

# get target package name from target package path
pkg_dir = os.path.abspath(args.target_package)
pkg_name, _, ver = get_package_details(os.path.join(pkg_dir, "setup.py"))
pkg_name, namespace, ver = get_package_details(os.path.join(pkg_dir, "setup.py"))

top_level_module = namespace.split('.')[0]

if should_verify_package(pkg_name):
logging.info("Verifying root directory in whl for package: [%s]", pkg_name)
if verify_whl_root_directory(args.dist_dir, ver):
if verify_whl_root_directory(args.dist_dir, top_level_module, ver):
logging.info("Verified root directory in whl for package: [%s]", pkg_name)
else:
logging.info(
Expand Down

0 comments on commit 2a26c2b

Please sign in to comment.