Skip to content

Commit

Permalink
{CI} Check cli core min version both remote and local (#5604)
Browse files Browse the repository at this point in the history
* update

* Update test_index.py

* Update test_index.py

* Update test_index.py

* Update test_index.py

* Update azext_metadata.json

* Update test_index.py
  • Loading branch information
wangzelin007 authored Dec 6, 2022
1 parent 1fc201a commit cfd1e19
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions scripts/ci/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,49 @@

from __future__ import print_function

import os
import glob
import hashlib
import json
import logging
import os
import shutil
import tempfile
import unittest
import hashlib
import shutil

from packaging import version
from util import SRC_PATH
from wheel.install import WHEEL_INFO_RE

from util import get_ext_metadata, get_whl_from_url, get_index_data


logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)


def get_sha256sum(a_file):
sha256 = hashlib.sha256()
with open(a_file, 'rb') as f:
sha256.update(f.read())
return sha256.hexdigest()


def check_min_version(extension_name, metadata):
if 'azext.minCliCoreVersion' not in metadata:
try:
azext_metadata = glob.glob(os.path.join(SRC_PATH, extension_name, 'azext_*', 'azext_metadata.json'))[0]
with open(azext_metadata, 'r') as f:
metadata = json.load(f)
if not metadata.get('azext.minCliCoreVersion'):
raise AssertionError(f'{extension_name} can not get azext.minCliCoreVersion')
except Exception as e:
logger.error(f'{extension_name} can not get azext.minCliCoreVersion: {e}')
raise e


class TestIndex(unittest.TestCase):

@classmethod
Expand Down Expand Up @@ -158,7 +181,8 @@ def test_metadata(self):
raise ex

try:
self.assertIn('azext.minCliCoreVersion', metadata) # check key properties exists
# check key properties exists
check_min_version(ext_name, metadata)
except AssertionError as ex:
if ext_name in historical_extensions:
threshold_version = historical_extensions[ext_name]
Expand Down

0 comments on commit cfd1e19

Please sign in to comment.