Exemple #1
0
def __main(args: list) -> int:
    validate_supported_runtime()
    args = __process_arguments(args)
    verbose = not args.quiet
    setup_loggers(verbose=verbose)

    # if repository is not set, then we are doing a core-sdk in performance repo run
    # if repository is set, user needs to supply the commit_sha
    if not ((args.commit_sha is None) == (args.repository is None)):
        raise ValueError(
            'Either both commit_sha and repository should be set or neither')

    # Acquire necessary tools (dotnet)
    # For arm64 runs, download the x64 version so we can get the information we need, but set all variables
    # as if we were running normally. This is a workaround due to the fact that arm64 binaries cannot run
    # in the cross containers, so we are running the ci setup script in a normal ubuntu container
    architecture = 'x64' if args.architecture == 'arm64' else args.architecture

    init_tools(architecture=architecture,
               dotnet_versions=args.dotnet_versions,
               channel=args.channel,
               verbose=verbose,
               install_dir=args.install_dir)

    # dotnet --info
    dotnet.info(verbose=verbose)

    # When running on internal repos, the repository comes to us incorrectly
    # (ie https://github.com/dotnet-coreclr). Replace dashes with slashes in that case.
    repo_url = None if args.repository is None else args.repository.replace(
        '-', '/')

    variable_format = 'set %s=%s\n' if sys.platform == 'win32' else 'export %s=%s\n'
    path_variable = 'set PATH=%%PATH%%;%s\n' if sys.platform == 'win32' else 'export PATH=$PATH:%s\n'
    dotnet_path = '%HELIX_CORRELATION_PAYLOAD%\dotnet' if sys.platform == 'win32' else '$HELIX_CORRELATION_PAYLOAD/dotnet'
    owner, repo = ('dotnet', 'core-sdk') if args.repository is None else (
        dotnet.get_repository(repo_url))
    config_string = ';'.join(
        args.build_configs) if sys.platform == 'win32' else '"%s"' % ';'.join(
            args.build_configs)

    output = ''

    with push_dir(get_repo_root_path()):
        output = check_output(['git', 'rev-parse', 'HEAD'])

    decoded_lines = []

    for line in output.splitlines():
        decoded_lines = decoded_lines + [line.decode('utf-8')]

    decoded_output = ''.join(decoded_lines)

    perfHash = decoded_output if args.get_perf_hash else args.perf_hash

    framework = ChannelMap.get_target_framework_moniker(args.channel)
    if framework.startswith('netcoreapp'):
        target_framework_moniker = dotnet.FrameworkAction.get_target_framework_moniker(
            framework)
        dotnet_version = dotnet.get_dotnet_version(target_framework_moniker,
                                                   args.cli)
        commit_sha = dotnet.get_dotnet_sdk(
            target_framework_moniker,
            args.cli) if args.commit_sha is None else args.commit_sha
        source_timestamp = dotnet.get_commit_date(target_framework_moniker,
                                                  commit_sha, repo_url)

        branch = ChannelMap.get_branch(
            args.channel) if not args.branch else args.branch

        getLogger().info("Writing script to %s" % args.output_file)

        with open(args.output_file, 'w') as out_file:
            out_file.write(variable_format % ('PERFLAB_INLAB', '1'))
            out_file.write(variable_format %
                           ('PERFLAB_REPO', '/'.join([owner, repo])))
            out_file.write(variable_format % ('PERFLAB_BRANCH', branch))
            out_file.write(variable_format % ('PERFLAB_PERFHASH', perfHash))
            out_file.write(variable_format % ('PERFLAB_HASH', commit_sha))
            out_file.write(variable_format % ('PERFLAB_QUEUE', args.queue))
            out_file.write(variable_format %
                           ('PERFLAB_BUILDNUM', args.build_number))
            out_file.write(variable_format %
                           ('PERFLAB_BUILDARCH', args.architecture))
            out_file.write(variable_format % ('PERFLAB_LOCALE', args.locale))
            out_file.write(variable_format %
                           ('PERFLAB_BUILDTIMESTAMP', source_timestamp))
            out_file.write(variable_format %
                           ('PERFLAB_CONFIGS', config_string))
            out_file.write(variable_format %
                           ('DOTNET_VERSION', dotnet_version))
            out_file.write(variable_format %
                           ('PERFLAB_TARGET_FRAMEWORKS', framework))
            out_file.write(variable_format %
                           ('DOTNET_CLI_TELEMETRY_OPTOUT', '1'))
            out_file.write(variable_format % ('DOTNET_MULTILEVEL_LOOKUP', '0'))
            out_file.write(variable_format % ('UseSharedCompilation', 'false'))
            out_file.write(variable_format % ('DOTNET_ROOT', dotnet_path))
            out_file.write(path_variable % dotnet_path)

    else:
        with open(args.output_file, 'w') as out_file:
            out_file.write(variable_format % ('PERFLAB_INLAB', '0'))
            out_file.write(variable_format %
                           ('PERFLAB_TARGET_FRAMEWORKS', framework))
            out_file.write(path_variable % dotnet_path)

    # The '_Framework' is needed for specifying frameworks in proj files and for building tools later in the pipeline
    __write_pipeline_variable('_Framework', framework)
Exemple #2
0
def __main(args: list) -> int:
    validate_supported_runtime()
    args = __process_arguments(args)
    verbose = not args.quiet
    setup_loggers(verbose=verbose)

    # if repository is not set, then we are doing a core-sdk in performance repo run
    # if repository is set, user needs to supply the commit_sha
    if not ((args.commit_sha is None) == (args.repository is None)):
        raise ValueError(
            'Either both commit_sha and repository should be set or neither')

    target_framework_monikers = micro_benchmarks \
        .FrameworkAction \
        .get_target_framework_monikers(args.frameworks)

    # Acquire necessary tools (dotnet, and BenchView)
    # For arm64 runs, download the x64 version so we can get the information we need, but set all variables
    # as if we were running normally. This is a workaround due to the fact that arm64 binaries cannot run
    # in the cross containers, so we are running the ci setup script in a normal ubuntu container
    architecture = 'x64' if args.architecture == 'arm64' else args.architecture

    init_tools(architecture=architecture,
               dotnet_versions=args.dotnet_versions,
               target_framework_monikers=target_framework_monikers,
               verbose=verbose)

    # dotnet --info
    dotnet.info(verbose=verbose)

    # When running on internal repos, the repository comes to us incorrectly
    # (ie https://github.com/dotnet-coreclr). Replace dashes with slashes in that case.
    repo_url = None if args.repository is None else args.repository.replace(
        '-', '/')

    variable_format = 'set %s=%s\n' if sys.platform == 'win32' else 'export %s=%s\n'
    owner, repo = ('dotnet', 'core-sdk') if args.repository is None else (
        dotnet.get_repository(repo_url))
    config_string = ';'.join(
        args.build_configs) if sys.platform == 'win32' else '"%s"' % ';'.join(
            args.build_configs)

    remove_dotnet = False

    output = ''

    with push_dir(get_repo_root_path()):
        output = check_output(['git', 'rev-parse', 'HEAD'])

    decoded_lines = []

    for line in output.splitlines():
        decoded_lines = decoded_lines + [line.decode('utf-8')]

    decoded_output = ''.join(decoded_lines)

    perfHash = decoded_output if args.get_perf_hash else args.perf_hash

    remove_frameworks = ['netcoreapp3.0', 'netcoreapp5.0']

    for framework in target_framework_monikers:
        if framework.startswith('netcoreapp'):
            if framework in remove_frameworks:
                remove_dotnet = True
            target_framework_moniker = micro_benchmarks.FrameworkAction.get_target_framework_moniker(
                framework)
            dotnet_version = dotnet.get_dotnet_version(
                target_framework_moniker, args.cli)
            commit_sha = dotnet.get_dotnet_sdk(
                target_framework_moniker,
                args.cli) if args.commit_sha is None else args.commit_sha
            source_timestamp = dotnet.get_commit_date(target_framework_moniker,
                                                      commit_sha, repo_url)

            branch = micro_benchmarks.FrameworkAction.get_branch(
                target_framework_moniker) if not args.branch else args.branch

            getLogger().info("Writing script to %s" % args.output_file)

            with open(args.output_file, 'w') as out_file:
                out_file.write(variable_format % ('PERFLAB_INLAB', '1'))
                out_file.write(variable_format %
                               ('PERFLAB_REPO', '/'.join([owner, repo])))
                out_file.write(variable_format % ('PERFLAB_BRANCH', branch))
                out_file.write(variable_format %
                               ('PERFLAB_PERFHASH', perfHash))
                out_file.write(variable_format % ('PERFLAB_HASH', commit_sha))
                out_file.write(variable_format % ('PERFLAB_QUEUE', args.queue))
                out_file.write(variable_format %
                               ('PERFLAB_BUILDNUM', args.build_number))
                out_file.write(variable_format %
                               ('PERFLAB_BUILDARCH', args.architecture))
                out_file.write(variable_format %
                               ('PERFLAB_LOCALE', args.locale))
                out_file.write(variable_format %
                               ('PERFLAB_BUILDTIMESTAMP', source_timestamp))
                out_file.write(variable_format %
                               ('PERFLAB_CONFIGS', config_string))
                out_file.write(variable_format %
                               ('DOTNET_VERSION', dotnet_version))
                out_file.write(variable_format %
                               ('PERFLAB_TARGET_FRAMEWORKS', framework))

        else:
            with open(args.output_file, 'w') as out_file:
                out_file.write(variable_format % ('PERFLAB_INLAB', '0'))
                out_file.write(variable_format %
                               ('PERFLAB_TARGET_FRAMEWORKS', framework))

    # On non-windows platforms, delete dotnet, so that we don't have to deal with chmoding it on the helix machines
    # This is only necessary for netcoreapp3.0 and netcoreapp5.0
    if sys.platform != 'win32' and remove_dotnet:
        dotnet.remove_dotnet(architecture)
Exemple #3
0
def __main(args: list) -> int:
    validate_supported_runtime()
    args = __process_arguments(args)
    verbose = not args.quiet
    setup_loggers(verbose=verbose)

    # if repository is not set, then we are doing a core-sdk in performance repo run
    # if repository is set, user needs to supply the commit_sha
    if not ((args.commit_sha is None) == (args.repository is None)):
        raise ValueError('Either both commit_sha and repository should be set or neither')

    target_framework_monikers = micro_benchmarks \
        .FrameworkAction \
        .get_target_framework_monikers(args.frameworks)
    # Acquire necessary tools (dotnet, and BenchView)
    init_tools(
        architecture=args.architecture,
        dotnet_versions=args.dotnet_versions,
        target_framework_monikers=target_framework_monikers,
        verbose=verbose
    )

    # dotnet --info
    dotnet.info(verbose=verbose)

    variable_format = 'set %s=%s\n' if sys.platform == 'win32' else 'export %s=%s\n'
    owner, repo = ('dotnet', 'core-sdk') if args.repository is None else (dotnet.get_repository(args.repository))
    config_string = ';'.join(args.build_configs) if sys.platform == 'win32' else '"%s"' % ';'.join(args.build_configs)

    is_netcoreapp_30 = False

    output = ''

    with push_dir(get_repo_root_path()):
        output = check_output(['git', 'rev-parse', 'HEAD'])

    decoded_lines = []

    for line in output.splitlines():
        decoded_lines = decoded_lines + [line.decode('utf-8')]

    decoded_output = ''.join(decoded_lines)

    perfHash = decoded_output if args.get_perf_hash else args.perf_hash

    for framework in target_framework_monikers:
        if framework.startswith('netcoreapp'):
            if framework == 'netcoreapp3.0':
                is_netcoreapp_30 = True
            target_framework_moniker = micro_benchmarks.FrameworkAction.get_target_framework_moniker(framework)
            dotnet_version = dotnet.get_dotnet_version(target_framework_moniker, args.cli)
            commit_sha =  dotnet.get_dotnet_sdk(target_framework_moniker, args.cli) if args.commit_sha is None else args.commit_sha
            source_timestamp = dotnet.get_commit_date(target_framework_moniker, commit_sha, args.repository)

            branch = micro_benchmarks.FrameworkAction.get_branch(target_framework_moniker) if not args.branch else args.branch

            getLogger().info("Writing script to %s" % args.output_file)

            with open(args.output_file, 'w') as out_file:
                out_file.write(variable_format % ('PERFLAB_INLAB', '1'))
                out_file.write(variable_format % ('PERFLAB_REPO', '/'.join([owner, repo])))
                out_file.write(variable_format % ('PERFLAB_BRANCH', branch))
                out_file.write(variable_format % ('PERFLAB_PERFHASH', perfHash))
                out_file.write(variable_format % ('PERFLAB_HASH', commit_sha))
                out_file.write(variable_format % ('PERFLAB_QUEUE', args.queue))
                out_file.write(variable_format % ('PERFLAB_BUILDNUM', args.build_number))
                out_file.write(variable_format % ('PERFLAB_BUILDARCH', args.architecture))
                out_file.write(variable_format % ('PERFLAB_LOCALE', args.locale))
                out_file.write(variable_format % ('PERFLAB_BUILDTIMESTAMP', source_timestamp))
                out_file.write(variable_format % ('PERFLAB_CONFIGS', config_string))
                out_file.write(variable_format % ('DOTNET_VERSION', dotnet_version))

        else:
            with open(args.output_file, 'w') as out_file:
                out_file.write(variable_format % ('PERFLAB_INLAB', '0'))

    # On non-windows platforms, delete dotnet, so that we don't have to deal with chmoding it on the helix machines
    # This is only necessary for netcoreapp3.0
    if sys.platform != 'win32' and is_netcoreapp_30:
        dotnet.remove_dotnet(args.architecture)