コード例 #1
0
def test():
    emojize = bootstrap()
    clean_up('test-output')
    os.mkdir('test-output')
    # exit_code = execute_command('pipenv lock')
    # success = not exit_code
    # if success:
    #     LOGGER.info('Successfully created lock file %s',
    #                  emojize(':white_heavy_check_mark:'),
    #                  emojize(':thumbs_up:'))
    # else:
    #     LOGGER.error('%s Errors creating lock file! %s',
    #                   emojize(':cross_mark:'),
    #                   emojize(':crying_face:'))
    #     raise SystemExit(1)
    save_requirements()
    exit_code = execute_command('tox')
    success = not exit_code
    if success:
        open_file(os.path.join('test-output', 'coverage', 'index.html'))
        sleep(0.5)
        open_file(os.path.join('test-output', 'nosetests.html'))
        LOGGER.info('%s No testing errors found! %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Testing errors found! %s',
                     emojize(':cross_mark:'),
                     emojize(':crying_face:'))
    raise SystemExit(exit_code)
コード例 #2
0
def build():
    emojize = bootstrap()
    clean_up(('build', 'dist'))
    success = execute_command('pipenv lock')
    if success:
        LOGGER.info('Successfully created lock file %s %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Errors creating lock file! %s',
                     emojize(':cross_mark:'), emojize(':crying_face:'))
        raise SystemExit(1)
    save_requirements()
    for file in BUILD_REQUIRED_FILES:
        shutil.copy(file, os.path.join(f'{PROJECT_SLUG}', file))
    success = execute_command('python setup.py sdist bdist_egg')
    if success:
        LOGGER.info('%s Successfully built artifact %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Errors building artifact! %s',
                     emojize(':cross_mark:'), emojize(':crying_face:'))
    clean_up([
        os.path.join(f'{PROJECT_SLUG}', file) for file in BUILD_REQUIRED_FILES
    ])
    return emojize if success else None
コード例 #3
0
def build():
    emojize = bootstrap()
    clean_up(('build', 'dist'))
    # exit_code = execute_command('pipenv lock')
    # success = not exit_code
    # if success:
    #     LOGGER.info('Successfully created lock file %s',
    #                  emojize(':white_heavy_check_mark:'),
    #                  emojize(':thumbs_up:'))
    # else:
    #     LOGGER.error('%s Errors creating lock file! %s',
    #                   emojize(':cross_mark:'),
    #                   emojize(':crying_face:'))
    #     raise SystemExit(1)
    save_requirements()
    for file in BUILD_REQUIRED_FILES:
        shutil.copy(file, os.path.join('{{cookiecutter.project_slug}}', file))
    exit_code = execute_command('python setup.py sdist bdist_egg')
    success = not exit_code
    if success:
        LOGGER.info('%s Successfully built artifact %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Errors building artifact! %s',
                     emojize(':cross_mark:'), emojize(':crying_face:'))
    clean_up([
        os.path.join('pythonlibproject', file) for file in BUILD_REQUIRED_FILES
    ])
    return emojize if success else None
コード例 #4
0
def build():
    bootstrap()
    # clean_up(('build', 'dist'))
    success = execute_command('pipenv lock')
    if success:
        LOGGER.info('Successfully created lock file %s %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Errors creating lock file! %s',
                     emojize(':cross_mark:'), emojize(':crying_face:'))
        raise SystemExit(1)

    save_requirements(get_venv_parent_path(), [], True)

    [
        save_requirements('./src/containers/' + folder, [], False)
        for folder in os.listdir('./src/containers/')
        if os.path.isdir('./src/containers/' +
                         folder) and '__pycache__' not in folder
    ]
    environment = get_environment()
    ref_name = os.environ.get('CI_COMMIT_REF_NAME')
    if ref_name:
        ref_name = ref_name.replace("/", "-")
    ecr_repo = os.environ.get('ECR_REPOSITORY')
    if not ecr_repo:
        ecr_repo = PROJECT_PREFIX
    version = os.environ.get('CI_COMMIT_TAG')
    base_name = ecr_repo + '/' + PROJECT_PREFIX + environment + '-' + PROJECT_SLUG + '-' + ref_name
    for folder in os.listdir('./src/containers/'):
        if os.path.isdir('./src/containers/' +
                         folder) and '__pycache__' not in folder:
            docker_build = 'docker build -t ' + base_name + '-' + folder + ':latest'
            if version:
                docker_build += ' -t ' + base_name + '-' + folder + ':' + version
            docker_build += ' ./src/containers/' + folder
            success = execute_command(docker_build)
        if not success:
            break

    [
        save_requirements('./src/functions/' + folder, ['boto3'], False)
        for folder in os.listdir('./src/functions/')
        if os.path.isdir('./src/functions/' +
                         folder) and '__pycache__' not in folder
    ]
    if success:
        success = execute_command('sam build --template template.yml')

    # success = execute_command('python setup.py sdist bdist_egg')
    if success:
        LOGGER.info('%s Successfully built artifact %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Errors building artifact! %s',
                     emojize(':cross_mark:'), emojize(':crying_face:'))
    return True if success else False
コード例 #5
0
ファイル: test.py プロジェクト: yutanicorp/powermolecli
def test():
    bootstrap()
    clean_up('test-output')
    os.mkdir('test-output')
    save_requirements()
    success = execute_command('tox')
    try:
        open_file(os.path.join('test-output', 'coverage', 'index.html'))
        sleep(0.5)
        open_file(os.path.join('test-output', 'nosetests.html'))
    except Exception:
        LOGGER.warning('Could not execute UI portion. Maybe running headless?')
    if success:
        LOGGER.info('%s No testing errors found! %s',
                    emojize(':white_heavy_check_mark:'),
                    emojize(':thumbs_up:'))
    else:
        LOGGER.error('%s Testing errors found! %s', emojize(':cross_mark:'),
                     emojize(':crying_face:'))
    raise SystemExit(0 if success else 1)