Exemple #1
0
def main(args):
    excluded_paths = args.excluded_paths
    excluded_paths.append('env')
    excluded_paths = tuple([
        os.path.join(REPO_ROOT, relative_path)
        for relative_path in excluded_paths
    ])

    files_without_header = []
    for current_dir, _, files in os.walk(get_repo_root()):
        if current_dir.startswith(excluded_paths):
            continue
        file_itr = (os.path.join(current_dir, p) for p in files
                    if p.endswith('.py'))
        for python_file in file_itr:
            with open(python_file, 'r') as f:
                file_text = f.read().replace('\r\n', '\n')
                file_text = file_text.replace('\n#', '')
                if file_text and (LICENSE_HEADER not in file_text):
                    files_without_header.append(
                        os.path.join(current_dir, python_file))

    if files_without_header:
        print(
            "Error: The following files don't have the required license headers: \n{}"
            .format('\n'.join(files_without_header)),
            file=sys.stderr)
        sys.exit(1)
Exemple #2
0
def main():
    cpu_count = multiprocessing.cpu_count()

    root_dir = get_repo_root()
    sdk_modules = _get_sdk_module_list(root_dir)
    sdk_modules.append("vendored_sdks")
    module_paths = _get_azext_module_paths(root_dir)

    scripts_dir = os.path.join(root_dir, "scripts")
    ci_files = _get_ci_py_file_paths(os.path.join(scripts_dir, "ci"))

    rc_file = os.path.join(root_dir, "pylintrc")
    config_file = os.path.join(root_dir, ".flake8")

    print("\nRunning pylint on extensions...")
    _run_pylint(module_paths, ",".join(sdk_modules), rc_file, cpu_count)
    print("Pylint OK.\n")

    print("Running flake8 on extensions...")
    _run_flake8(module_paths, config_file)
    print("Flake8 OK.\n")

    print("Running pylint on CI scripts...")
    _run_pylint(ci_files, rcfile=rc_file, cpu_count=cpu_count)
    print("Pylint OK.\n")

    print("Running flake8 on CI scripts...")
    _run_flake8(ci_files, config_file=config_file)
    print("Pylint OK.\n")

    print("Other Static checks...")

    _verify_codeowners()

    print("All static checks successful!")
def main(args):
    excluded_paths = args.excluded_paths
    excluded_paths.append('env')
    excluded_paths = tuple([os.path.join(REPO_ROOT, relative_path) for relative_path in excluded_paths])

    files_without_header = []
    for current_dir, _, files in os.walk(get_repo_root()):
        if current_dir.startswith(excluded_paths):
            continue
        file_itr = (os.path.join(current_dir, p) for p in files if p.endswith('.py'))
        for python_file in file_itr:
            with open(python_file, 'r') as f:
                file_text = f.read().replace('\r\n', '\n')
                file_text = file_text.replace('\n#', '')
                if file_text and (LICENSE_HEADER not in file_text):
                    files_without_header.append(os.path.join(current_dir, python_file))

    if files_without_header:
        print("Error: The following files don't have the required license headers: \n{}".format(
            '\n'.join(files_without_header)), file=sys.stderr)
        sys.exit(1)
def main():
    cpu_count = multiprocessing.cpu_count()

    root_dir = get_repo_root()
    sdk_modules = _get_sdk_module_list(root_dir)
    sdk_modules.append("vendored_sdks")
    module_paths = _get_azext_module_paths(root_dir)

    scripts_dir = os.path.join(root_dir, "scripts")
    ci_files = _get_ci_py_file_paths(os.path.join(scripts_dir, "ci"))

    rcfile = os.path.join(root_dir, "pylintrc")
    config_file = os.path.join(root_dir, "flake8")

    print("\nRunning pylint on extensions...")
    _run_pylint(module_paths, ",".join(sdk_modules), rcfile, cpu_count)
    print("Pylint OK.\n")

    print("Running flake8 on extensions...")
    _run_flake8(module_paths, config_file)
    print("Flake8 OK.\n")

    print("Running pylint on CI scripts...")
    _run_pylint(ci_files, rcfile=rcfile, cpu_count=cpu_count)
    print("Pylint OK.\n")

    print("Running flake8 on CI scripts...")
    _run_flake8(ci_files, config_file=config_file)
    print("Pylint OK.\n")

    print("Other Static checks...")

    _verify_codeowners()

    parser = argparse.ArgumentParser()
    parser.add_argument('excluded_paths', nargs='*')
    _verify_license(parser.parse_args())

    print("All static checks successful!")
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from __future__ import print_function

import os
import sys

from util import get_repo_root

REPO_ROOT = get_repo_root()
CODEOWNERS = os.path.join(REPO_ROOT, '.github', 'CODEOWNERS')
SRC_DIR = os.path.join(REPO_ROOT, 'src')


def get_src_dir_codeowners():
    contents = []
    with open(CODEOWNERS) as f:
        contents = [x.strip() for x in f.readlines()]
    return dict([x.split(' ', 1) for x in contents if x.startswith('/src/') and x.split(' ')[0].endswith('/')])


def main():
    owners = get_src_dir_codeowners()
    dangling_entries = [e for e in owners if not os.path.isdir(os.path.join(REPO_ROOT, e[1:]))]
    missing_entries = ['/src/{}/'.format(p) for p in os.listdir(SRC_DIR)
                       if os.path.isdir(os.path.join(SRC_DIR, p)) and '/src/{}/'.format(p) not in owners]
    if dangling_entries or missing_entries:
        print('Errors whilst verifying {}!'.format(CODEOWNERS))
Exemple #6
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from __future__ import print_function

import os
import sys
import argparse

from util import get_repo_root

REPO_ROOT = get_repo_root()
SRC_DIR = os.path.join(REPO_ROOT, 'src')

LICENSE_HEADER = ("Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. "
                  "See License.txt in the project root for license information.")


def main(args):
    excluded_paths = args.excluded_paths
    excluded_paths.append('env')
    excluded_paths = tuple([os.path.join(REPO_ROOT, relative_path) for relative_path in excluded_paths])

    files_without_header = []
    for current_dir, _, files in os.walk(get_repo_root()):
        if current_dir.startswith(excluded_paths):
            continue
        file_itr = (os.path.join(current_dir, p) for p in files if p.endswith('.py'))
        for python_file in file_itr:
Exemple #7
0
from __future__ import print_function

import os
import sys
import tempfile
import unittest
import shutil
from subprocess import check_call

import mock
from six import with_metaclass

from util import get_repo_root


SOURCES = os.path.join(get_repo_root(), 'src')

ALL_TESTS = []

for src_d in os.listdir(SOURCES):
    src_d_full = os.path.join(SOURCES, src_d)
    if os.path.isdir(src_d_full):
        pkg_name = next((d for d in os.listdir(src_d_full) if d.startswith('azext_')), None)
        # Find the package and check it has tests
        if pkg_name and os.path.isdir(os.path.join(src_d_full, pkg_name, 'tests')):
            ALL_TESTS.append((pkg_name, src_d_full))


class TestExtensionSourceMeta(type):
    def __new__(mcs, name, bases, _dict):
import os
import sys
import tempfile
import traceback
import unittest
import shutil
from subprocess import check_call, CalledProcessError
from pkg_resources import parse_version, get_distribution

from six import with_metaclass

from util import get_index_data, get_whl_from_url, get_repo_root


REF_GEN_SCRIPT = os.path.join(get_repo_root(), 'scripts', 'refdoc', 'generate.py')

REF_DOC_OUT_DIR = os.environ.get('AZ_EXT_REF_DOC_OUT_DIR', tempfile.mkdtemp())

if not os.path.isdir(REF_DOC_OUT_DIR):
    print('{} is not a directory'.format(REF_DOC_OUT_DIR))
    sys.exit(1)

ALL_TESTS = []

CLI_VERSION = get_distribution('azure-cli').version

for extension_name, exts in get_index_data()['extensions'].items():
    parsed_cli_version = parse_version(CLI_VERSION)
    filtered_exts = []
    for ext in exts:
""" Test the index and the wheels from both the index and from source extensions in repository """

from __future__ import print_function

import os
import json
import tempfile
import unittest
import zipfile
import hashlib
import shutil
import subprocess
from util import get_repo_root
from wheel.install import WHEEL_INFO_RE

INDEX_PATH = os.path.join(get_repo_root(), 'src', 'index.json')
SRC_PATH = os.path.join(get_repo_root(), 'src')

# Extensions to skip dep. check. Aim to keep this list empty.
SKIP_DEP_CHECK = ['azure-cli-iot-ext']


def catch_dup_keys(pairs):
    seen = {}
    for k, v in pairs:
        if k in seen:
            raise ValueError("duplicate key {}".format(k))
        seen[k] = v
    return seen

from __future__ import print_function

import os
import sys
import tempfile
import unittest
import shutil
from subprocess import check_call
from pkg_resources import parse_version, get_distribution

from six import with_metaclass

from util import get_index_data, get_whl_from_url, get_repo_root


REF_GEN_SCRIPT = os.path.join(get_repo_root(), 'scripts', 'refdoc', 'generate.py')

REF_DOC_OUT_DIR = os.environ.get('AZ_EXT_REF_DOC_OUT_DIR', tempfile.mkdtemp())

if not os.path.isdir(REF_DOC_OUT_DIR):
    print('{} is not a directory'.format(REF_DOC_OUT_DIR))
    sys.exit(1)

ALL_TESTS = []

CLI_VERSION = get_distribution('azure-cli').version

for extension_name, exts in get_index_data()['extensions'].items():
    parsed_cli_version = parse_version(CLI_VERSION)
    filtered_exts = []
    for ext in exts: