aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipes/update_meta_config.py
blob: a8f17cc03bac313be5a2ffc81237ea47985ce24b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright 2017 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 for the Bot that updates meta config."""


DEPS = [
  'depot_tools/gclient',
  'recipe_engine/context',
  'recipe_engine/file',
  'recipe_engine/path',
  'recipe_engine/properties',
  'recipe_engine/python',
  'recipe_engine/raw_io',
  'recipe_engine/step',
  'core',
  'infra',
  'run',
  'vars',
]


TEST_BUILDERS = {
  'client.skia.compile': {
    'skiabot-linux-swarm-000': [
      'Housekeeper-Nightly-UpdateMetaConfig',
    ],
  },
}


UPDATE_META_CONFIG_GITCOOKIES_FILE = 'update_meta_config.git_cookies'
UPDATE_META_CONFIG_KEY = 'update_meta_config_git_cookies'


def RunSteps(api):
  api.core.setup()

  if api.vars.is_trybot:
    raise Exception('Cannot run update_meta_config recipe as a trybot')
  update_meta_config_gitcookies = api.path.join(
      api.path.expanduser('~'), UPDATE_META_CONFIG_GITCOOKIES_FILE)
  repo_name = api.properties.get('repository').split('/')[-1].rstrip('.git')
  cmd = ['python',
         api.vars.skia_dir.join('infra', 'bots', 'update_meta_config.py'),
         '--repo_name', repo_name,
         '--tasks_json', api.vars.skia_dir.join('infra', 'bots', 'tasks.json'),
         '--gitcookies', str(update_meta_config_gitcookies)]
  with api.infra.MetadataFetch(
      api, UPDATE_META_CONFIG_KEY, UPDATE_META_CONFIG_GITCOOKIES_FILE):
    with api.context(cwd=api.vars.skia_dir):
      api.run(api.step, 'Update meta/config', cmd=cmd)


def GenTests(api):
  builder = 'Housekeeper-Nightly-UpdateMetaConfig'
  yield (
      api.test(builder) +
      api.properties(buildername=builder,
                     repository='https://skia.googlesource.com/skia.git',
                     revision='abc123',
                     path_config='kitchen',
                     swarm_out_dir='[SWARM_OUT_DIR]')
  )

  yield (
      api.test('failed_update') +
      api.properties(buildername=builder,
                     repository='https://skia.googlesource.com/skia.git',
                     revision='abc123',
                     path_config='kitchen',
                     swarm_out_dir='[SWARM_OUT_DIR]') +
      api.step_data('Update meta/config', retcode=1)
  )

  yield (
      api.test('trybot_test') +
      api.properties(buildername=builder,
                     repository='https://skia.googlesource.com/skia.git',
                     revision='abc123',
                     path_config='kitchen',
                     swarm_out_dir='[SWARM_OUT_DIR]',
                     patch_issue=123,
                     patch_set=3) +
      api.expect_exception('Exception')
  )