<commit_before># Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


# Recipe module for Skia Swarming trigger.


import os
import json


DEPS = [
  'build/file',
  'build/gsutil',
  'builder_name_schema',
  'core',
  'depot_tools/git',
  'recipe_engine/json',
  'recipe_engine/path',
  'recipe_engine/properties',
  'recipe_engine/python',
  'recipe_engine/raw_io',
  'recipe_engine/step',
  'recipe_engine/time',
  'run',
  'swarming',
  'vars',
]


TEST_BUILDERS = {
  'client.skia': {
    'skiabot-linux-swarm-000': [
      'Build-Mac-Clang-Arm64-Release-Android',
      'Build-Mac-Clang-x86_64-Release',
      'Build-Ubuntu-GCC-Arm64-Debug-Android_Vulkan',
      'Build-Ubuntu-GCC-x86_64-Debug',
      'Build-Ubuntu-GCC-x86_64-Debug-GN',
      'Build-Ubuntu-GCC-x86_64-Release-RemoteRun',
      'Build-Ubuntu-GCC-x86_64-Release-Trybot',
      'Build-Win-MSVC-x86_64-Release',
      'Build-Win-MSVC-x86_64-Release-Vulkan',
      'Housekeeper-Nightly-RecreateSKPs_Canary',
      'Housekeeper-PerCommit',
      'Housekeeper-PerCommit-Presubmit',
      'Infra-PerCommit',
      'Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Trybot',
      'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs',
      'Perf-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
      'Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Debug-GN_Android',
      'Test-Android-GCC-NVIDIA_Shield-GPU-TegraX1-Arm64-Debug-Vulkan',
      'Test-Android-GCC-Nexus7v2-GPU-Tegra3-Arm7-Release',
      'Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release',
      'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage-Trybot',
      'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN',
      'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug',
      'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
      'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
      'Test-Win8-MSVC-ShuttleA-GPU-HD7770-x86_64-Release',
      'Test-Win8-MSVC-ShuttleB-CPU-AVX2-x86_64-Release',
      'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Release',
    ],
  },
}


UPLOAD_DIMENSIONS = {
  'pool': 'Skia',
  'os': 'Linux',
  'cpu': 'x86-64-avx2',
  'gpu': 'none',
}


def derive_compile_bot_name(api):
  builder_name = api.properties['buildername']
  builder_cfg = api.builder_name_schema.DictForBuilderName(builder_name)
  if builder_cfg['role'] == 'Housekeeper':
    return 'Build-Ubuntu-GCC-x86_64-Release-Shared'
  if builder_cfg['role'] in ('Test', 'Perf'):
    task_os = builder_cfg['os']
    extra_config = builder_cfg.get('extra_config', '')
    if task_os == 'Android':
      if extra_config == 'Vulkan':
        extra_config = '%s_%s' % (task_os, 'Vulkan')
      elif 'GN_Android' in extra_config:
        pass  # i.e. extra_config stays GN_Android or GN_Android_Vulkan
      else:
        extra_config = task_os
      task_os = 'Ubuntu'
    elif task_os == 'iOS':
      extra_config = task_os
      task_os = 'Mac'
    elif 'Win' in task_os:
      task_os = 'Win'
    return api.builder_name_schema.MakeBuilderName(
        role=api.builder_name_schema.BUILDER_ROLE_BUILD,
        os=task_os,
        compiler=builder_cfg['compiler'],
        target_arch=builder_cfg['arch'],
        configuration=builder_cfg['configuration'],
        extra_config=extra_config,
        is_trybot=api.builder_name_schema.IsTrybot(builder_name))
  return builder_name


def swarm_dimensions(builder_cfg):
  """Return a dict of keys and values to be used as Swarming bot dimensions."""
  dimensions = {
    'pool': 'Skia',
  }
  dimensions['os'] = builder_cfg.get('os', 'Ubuntu')
  if builder_cfg.get('extra_config', '').startswith('CT_'):
    dimensions['pool'] = 'SkiaCT'
    return dimensions  # Do not need any more dimensions for CT builders.
  if 'Win' in builder_cfg.get('os', ''):
    dimensions['os'] = 'Windows'
  if builder_cfg['role'] in ('Test', 'Perf'):
    if 'Android' in builder_cfg['os']:
      # For Android, the device type is a better dimension than CPU or GPU.
      device_type, device_os = {
        'AndroidOne':    ('sprout',     'MOB30Q'),
        'GalaxyS7':      ('heroqlteatt','MMB29M'),
        'NVIDIA_Shield': ('foster',     'MRA58K'),
        'Nexus10':       ('manta',      'LMY49J'),
        'Nexus5':        ('hammerhead', 'MOB31E'),
        'Nexus6':        ('shamu',      'M'),
        'Nexus6p':       ('angler',     'NRD91E'),
        'Nexus7':        ('grouper',    'LMY47V'),
        'Nexus7v2':      ('flo',        'M'),
        'Nexus9':        ('flounder',   'NRD91D'),
        'NexusPlayer':   ('fugu',       'NRD90R'),
      }[builder_cfg['model']]
      dimensions['device_type'] = device_type
      dimensions['device_os'] = device_os
    elif 'iOS' in builder_cfg['os']:
      # For iOS, the device type is a better dimension than CPU or GPU.
      dimensions['device'] = {
        'iPad4': 'iPad4,1',
      }[builder_cfg['model']]
      # TODO(borenet): Replace this hack with something better.
      dimensions['os'] = 'iOS-9.2'
    elif builder_cfg['cpu_or_gpu'] == 'CPU':
      dimensions['gpu'] = 'none'
      dimensions['cpu'] = {
        'AVX':  'x86-64',
        'AVX2': 'x86-64-avx2',
        'SSE4': 'x86-64',
      }[builder_cfg['cpu_or_gpu_value']]
      if ('Win' in builder_cfg['os'] and
          builder_cfg['cpu_or_gpu_value'] == 'AVX2'):
        # AVX2 is not correctly detected on Windows. Fall back on other
        # dimensions to ensure that we correctly target machines which we know
        # have AVX2 support.
        dimensions['cpu'] = 'x86-64'
        dimensions['os'] = 'Windows-2008ServerR2-SP1'
    else:<commit_msg>Add recipe support for Pixel and Pixel XL.<commit_after># Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


# Recipe module for Skia Swarming trigger.


import os
import json


DEPS = [
  'build/file',
  'build/gsutil',
  'builder_name_schema',
  'core',
  'depot_tools/git',
  'recipe_engine/json',
  'recipe_engine/path',
  'recipe_engine/properties',
  'recipe_engine/python',
  'recipe_engine/raw_io',
  'recipe_engine/step',
  'recipe_engine/time',
  'run',
  'swarming',
  'vars',
]


TEST_BUILDERS = {
  'client.skia': {
    'skiabot-linux-swarm-000': [
      'Build-Mac-Clang-Arm64-Release-Android',
      'Build-Mac-Clang-x86_64-Release',
      'Build-Ubuntu-GCC-Arm64-Debug-Android_Vulkan',
      'Build-Ubuntu-GCC-x86_64-Debug',
      'Build-Ubuntu-GCC-x86_64-Debug-GN',
      'Build-Ubuntu-GCC-x86_64-Release-RemoteRun',
      'Build-Ubuntu-GCC-x86_64-Release-Trybot',
      'Build-Win-MSVC-x86_64-Release',
      'Build-Win-MSVC-x86_64-Release-Vulkan',
      'Housekeeper-Nightly-RecreateSKPs_Canary',
      'Housekeeper-PerCommit',
      'Housekeeper-PerCommit-Presubmit',
      'Infra-PerCommit',
      'Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Trybot',
      'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs',
      'Perf-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
      'Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Debug-GN_Android',
      'Test-Android-GCC-NVIDIA_Shield-GPU-TegraX1-Arm64-Debug-Vulkan',
      'Test-Android-GCC-Nexus7v2-GPU-Tegra3-Arm7-Release',
      'Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release',
      'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Coverage-Trybot',
      'Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN',
      'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug',
      'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared',
      'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
      'Test-Win8-MSVC-ShuttleA-GPU-HD7770-x86_64-Release',
      'Test-Win8-MSVC-ShuttleB-CPU-AVX2-x86_64-Release',
      'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Release',
    ],
  },
}


UPLOAD_DIMENSIONS = {
  'pool': 'Skia',
  'os': 'Linux',
  'cpu': 'x86-64-avx2',
  'gpu': 'none',
}


def derive_compile_bot_name(api):
  builder_name = api.properties['buildername']
  builder_cfg = api.builder_name_schema.DictForBuilderName(builder_name)
  if builder_cfg['role'] == 'Housekeeper':
    return 'Build-Ubuntu-GCC-x86_64-Release-Shared'
  if builder_cfg['role'] in ('Test', 'Perf'):
    task_os = builder_cfg['os']
    extra_config = builder_cfg.get('extra_config', '')
    if task_os == 'Android':
      if extra_config == 'Vulkan':
        extra_config = '%s_%s' % (task_os, 'Vulkan')
      elif 'GN_Android' in extra_config:
        pass  # i.e. extra_config stays GN_Android or GN_Android_Vulkan
      else:
        extra_config = task_os
      task_os = 'Ubuntu'
    elif task_os == 'iOS':
      extra_config = task_os
      task_os = 'Mac'
    elif 'Win' in task_os:
      task_os = 'Win'
    return api.builder_name_schema.MakeBuilderName(
        role=api.builder_name_schema.BUILDER_ROLE_BUILD,
        os=task_os,
        compiler=builder_cfg['compiler'],
        target_arch=builder_cfg['arch'],
        configuration=builder_cfg['configuration'],
        extra_config=extra_config,
        is_trybot=api.builder_name_schema.IsTrybot(builder_name))
  return builder_name


def swarm_dimensions(builder_cfg):
  """Return a dict of keys and values to be used as Swarming bot dimensions."""
  dimensions = {
    'pool': 'Skia',
  }
  dimensions['os'] = builder_cfg.get('os', 'Ubuntu')
  if builder_cfg.get('extra_config', '').startswith('CT_'):
    dimensions['pool'] = 'SkiaCT'
    return dimensions  # Do not need any more dimensions for CT builders.
  if 'Win' in builder_cfg.get('os', ''):
    dimensions['os'] = 'Windows'
  if builder_cfg['role'] in ('Test', 'Perf'):
    if 'Android' in builder_cfg['os']:
      # For Android, the device type is a better dimension than CPU or GPU.
      device_type, device_os = {
        'AndroidOne':    ('sprout',     'MOB30Q'),
        'GalaxyS7':      ('heroqlteatt','MMB29M'),
        'NVIDIA_Shield': ('foster',     'MRA58K'),
        'Nexus10':       ('manta',      'LMY49J'),
        'Nexus5':        ('hammerhead', 'MOB31E'),
        'Nexus6':        ('shamu',      'M'),
        'Nexus6p':       ('angler',     'NRD91E'),
        'Nexus7':        ('grouper',    'LMY47V'),
        'Nexus7v2':      ('flo',        'M'),
        'Nexus9':        ('flounder',   'NRD91D'),
        'NexusPlayer':   ('fugu',       'NRD90R'),
        'Pixel':         ('sailfish',   'NMF25'),
        'PixelXL':       ('marlin',     'NMF25'),
      }[builder_cfg['model']]
      dimensions['device_type'] = device_type
      dimensions['device_os'] = device_os
    elif 'iOS' in builder_cfg['os']:
      # For iOS, the device type is a better dimension than CPU or GPU.
      dimensions['device'] = {
        'iPad4': 'iPad4,1',
      }[builder_cfg['model']]
      # TODO(borenet): Replace this hack with something better.
      dimensions['os'] = 'iOS-9.2'
    elif builder_cfg['cpu_or_gpu'] == 'CPU':
      dimensions['gpu'] = 'none'
      dimensions['cpu'] = {
        'AVX':  'x86-64',
        'AVX2': 'x86-64-avx2',
        'SSE4': 'x86-64',
      }[builder_cfg['cpu_or_gpu_value']]
      if ('Win' in builder_cfg['os'] and
          builder_cfg['cpu_or_gpu_value'] == 'AVX2'):
        # AVX2 is not correctly detected on Windows. Fall back on other
        # dimensions to ensure that we correctly target machines which we know
        # have AVX2 support.
        dimensions['cpu'] = 'x86-64'
        dimensions['os'] = 'Windows-2008ServerR2-SP1'
    else:
{'fraction_non_alphanumeric': 0.15468599877718578, 'fraction_numerical': 0.03406411040265525, 'mean_word_length': 2.960567277758561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '347433', 'n_tokens_mistral': 4595, 'n_tokens_neox': 4253, 'n_words': 710}