Beispiel #1
0
  def optionsMatch(config):
    # In this case, build_configs are config name fragments. If the config
    # name doesn't contain any of the fragments, filter it out.
    for build_config in build_config_fragments:
      if build_config not in config.name:
        return False

    return config_lib.isTryjobConfig(config) != production
    def testTryjobConfigsDontDefineOverrides(self):
        """Make sure that no tryjob safe configs define test overrides."""
        for build_name, config in self.site_config.items():
            if not config_lib.isTryjobConfig(config):
                continue

            self.assertIsNone(
                config.vm_tests_override,
                'Config %s: is tryjob safe, but defines vm_tests_override.' % \
                build_name)

            self.assertIsNone(
                config.hw_tests_override,
                'Config %s: is tryjob safe, but defines hw_tests_override.' % \
                build_name)
def main(argv):
    _ = _ParseArguments(argv)

    site_config = config_lib.GetConfig()

    # Organize the builds as:
    #  {Display Label: [build_config]}

    labeled_builds = {}
    for config in site_config.values():
        if config.schedule:
            labeled_builds.setdefault(config.display_label, []).append(config)

    for label in sorted(labeled_builds.keys()):
        displayConfigs(label, labeled_builds[label])

    # Force the tryjob section to be last.
    displayConfigs(
        'tryjob',
        [c for c in site_config.values() if config_lib.isTryjobConfig(c)])
Beispiel #4
0
def VerifyOptions(options, site_config):
  """Verify that our command line options make sense.

  Args:
    options: Parsed cros tryjob tryjob arguments.
    site_config: config_lib.SiteConfig containing all config info.
  """
  # Handle --list before checking that everything else is valid.
  if options.list:
    PrintKnownConfigs(site_config,
                      options.production,
                      options.build_configs)
    raise cros_build_lib.DieSystemExit(0)  # Exit with success code.

  # Validate specified build_configs.
  if not options.build_configs:
    cros_build_lib.Die('At least one build_config is required.')

  on_branch = options.branch != 'master'

  if not (options.yes or on_branch):
    unknown_build_configs = [b for b in options.build_configs
                             if b not in site_config]
    if unknown_build_configs:
      prompt = ('Unknown build configs; are you sure you want to schedule '
                'for %s?' % ', '.join(unknown_build_configs))
      if not cros_build_lib.BooleanPrompt(prompt=prompt, default=False):
        cros_build_lib.Die('No confirmation.')

  # Ensure that production configs are only run with --production.
  if not (on_branch or options.production or options.where == CBUILDBOT):
    # We can't know if branched configs are tryjob safe.
    # It should always be safe to run a tryjob config with --production.
    prod_configs = []
    for b in options.build_configs:
      if b in site_config and not config_lib.isTryjobConfig(site_config[b]):
        prod_configs.append(b)

    if prod_configs:
      # Die, and explain why.
      alternative_configs = ['%s-tryjob' % b for b in prod_configs]
      msg = ('These configs are not tryjob safe:\n'
             '  %s\n'
             'Consider these configs instead:\n'
             '  %s\n'
             'See go/cros-explicit-tryjob-build-configs-psa.' %
             (', '.join(prod_configs), ', '.join(alternative_configs)))

      if options.branch == 'master':
        # On master branch, we know the status of configs for sure.
        cros_build_lib.Die(msg)
      elif not options.yes:
        # On branches, we are just guessing. Let people override.
        prompt = '%s\nAre you sure you want to continue?' % msg
        if not cros_build_lib.BooleanPrompt(prompt=prompt, default=False):
          cros_build_lib.Die('No confirmation.')

  patches_given = options.gerrit_patches or options.local_patches
  if options.production:
    # Make sure production builds don't have patches.
    if patches_given and not options.debug:
      cros_build_lib.Die('Patches cannot be included in production builds.')
  elif options.where != CBUILDBOT:
    # Ask for confirmation if there are no patches to test.
    if not patches_given and not options.yes:
      prompt = ('No patches were provided; are you sure you want to just '
                'run a build of %s?' % (
                    options.branch if options.branch else 'ToT'))
      if not cros_build_lib.BooleanPrompt(prompt=prompt, default=False):
        cros_build_lib.Die('No confirmation.')

  if options.where in (REMOTE, INFRA_TESTING):
    if options.buildroot:
      cros_build_lib.Die('--buildroot is not used for remote tryjobs.')

    if options.git_cache_dir:
      cros_build_lib.Die('--git-cache-dir is not used for remote tryjobs.')
  else:
    if options.json:
      cros_build_lib.Die('--json can only be used for remote tryjobs.')
Beispiel #5
0
def _PostParseCheck(parser, options, site_config):
    """Perform some usage validation after we've parsed the arguments

  Args:
    parser: Option parser that was used to parse arguments.
    options: The options returned by optparse.
    site_config: config_lib.SiteConfig containing all config info.
  """

    if not options.branch:
        options.branch = git.GetChromiteTrackingBranch()

    # Because the default cache dir depends on other options, FindCacheDir
    # always returns None, and we setup the default here.
    if options.cache_dir is None:
        # Note, options.sourceroot is set regardless of the path
        # actually existing.
        options.cache_dir = os.path.join(options.buildroot, '.cache')
        options.cache_dir = os.path.abspath(options.cache_dir)
        parser.ConfigureCacheDir(options.cache_dir)

    osutils.SafeMakedirsNonRoot(options.cache_dir)

    # Ensure that all args are legitimate config targets.
    if options.build_config_name not in site_config:
        cros_build_lib.Die('Unkonwn build config: "%s"' %
                           options.build_config_name)

    build_config = site_config[options.build_config_name]
    is_payloads_build = build_config.build_type == constants.PAYLOADS_TYPE

    if options.channels and not is_payloads_build:
        cros_build_lib.Die('--channel must only be used with a payload config,'
                           ' not target (%s).' % options.build_config_name)

    if not options.channels and is_payloads_build:
        cros_build_lib.Die(
            'payload configs (%s) require --channel to do anything'
            ' useful.' % options.build_config_name)

    # If the build config explicitly forces the debug flag, set the debug flag
    # as if it was set from the command line.
    if build_config.debug:
        options.debug = True

    if not (config_lib.isTryjobConfig(build_config) or options.buildbot):
        cros_build_lib.Die(
            'Refusing to run non-tryjob config as a tryjob.\n'
            'Please "repo sync && cros tryjob --list %s" for alternatives.\n'
            'See go/cros-explicit-tryjob-build-configs-psa.',
            build_config.name)

    # The --version option is not compatible with an external target unless the
    # --buildbot option is specified.  More correctly, only "paladin versions"
    # will work with external targets, and those are only used with --buildbot.
    # If --buildbot is specified, then user should know what they are doing and
    # only specify a version that will work.  See crbug.com/311648.
    if (options.force_version
            and not (options.buildbot or build_config.internal)):
        cros_build_lib.Die('Cannot specify --version without --buildbot for an'
                           ' external target (%s).' %
                           options.build_config_name)