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} Check cli core min version both remote and local #5604

Merged
merged 7 commits into from
Dec 6, 2022
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,48 @@

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_local(extension_name):
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 metadata.get('azext.minCliCoreVersion'):
return True
except Exception as e:
logger.error(f'{extension_name} can not get minCliCoreVersion from local: {e}')
return False


class TestIndex(unittest.TestCase):

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

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