Skip to content

Commit

Permalink
changes to dependency check (#226)
Browse files Browse the repository at this point in the history
* changes to dependency check

* CI
  • Loading branch information
williexu authored Jun 30, 2018
1 parent b56e5f5 commit 86720dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions scripts/ci/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import hashlib
import shutil
from wheel.install import WHEEL_INFO_RE
from util import get_ext_metadata, get_whl_from_url, get_index_data, SKIP_DEP_CHECK
from util import get_ext_metadata, get_whl_from_url, get_index_data, verify_dependency


def get_sha256sum(a_file):
Expand Down Expand Up @@ -136,10 +136,10 @@ def test_metadata(self):
"{}".format(item['filename'], json.dumps(metadata, indent=2, sort_keys=True,
separators=(',', ': '))))
run_requires = metadata.get('run_requires')
if run_requires and ext_name not in SKIP_DEP_CHECK:
if run_requires:
deps = run_requires[0]['requires']
self.assertTrue(
all(not dep.startswith('azure-') or dep.startswith('azure-batch-extensions') for dep in deps),
all(verify_dependency(dep) for dep in deps),
"Dependencies of {} use disallowed extension dependencies. "
"Remove these dependencies: {}".format(item['filename'], deps))
shutil.rmtree(extensions_dir)
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from wheel.install import WHEEL_INFO_RE
from six import with_metaclass

from util import get_ext_metadata, SRC_PATH, SKIP_DEP_CHECK
from util import get_ext_metadata, verify_dependency, SRC_PATH


ALL_TESTS = []
Expand Down Expand Up @@ -86,9 +86,9 @@ def test_source_wheels(self):
ext_name = WHEEL_INFO_RE(filename).groupdict().get('name')
metadata = get_ext_metadata(ext_dir, ext_file, ext_name)
run_requires = metadata.get('run_requires')
if run_requires and ext_name not in SKIP_DEP_CHECK:
if run_requires:
deps = run_requires[0]['requires']
self.assertTrue(all(not dep.startswith('azure-') for dep in deps),
self.assertTrue(all(verify_dependency(dep) for dep in deps),
"Dependencies of {} use disallowed extension dependencies. "
"Remove these dependencies: {}".format(filename, deps))
shutil.rmtree(built_whl_dir)
Expand Down
12 changes: 10 additions & 2 deletions scripts/ci/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import zipfile
from wheel.install import WHEEL_INFO_RE

# Extensions to skip dep. check. Aim to keep this list empty.
SKIP_DEP_CHECK = ['azure-cli-iot-ext']
# Dependencies that will not be checked.
# This is for packages starting with 'azure-' but do not use the 'azure' namespace.
SKIP_DEP_CHECK = ['azure-batch-extensions']


def get_repo_root():
Expand Down Expand Up @@ -99,3 +100,10 @@ def get_index_data():
return json.load(f, object_pairs_hook=_catch_dup_keys)
except ValueError as err:
raise AssertionError("Invalid JSON in {}: {}".format(INDEX_PATH, err))


def verify_dependency(dep):
# ex. "azure-batch-extensions (<3.1,>=3.0.0)", "paho-mqtt (==1.3.1)", "pyyaml"
# check if 'azure-' dependency, as they use 'azure' namespace.
dep_split = dep.split()
return not (dep_split and dep_split[0].startswith('azure-') and dep_split[0] not in SKIP_DEP_CHECK)

0 comments on commit 86720dc

Please sign in to comment.