Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from common import cros_chromite | 5 from common import cros_chromite |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'chromite', | 8 'chromite', |
| 9 'gitiles', | 9 'gitiles', |
| 10 'properties', | 10 'properties', |
| 11 ] | 11 ] |
| 12 | 12 |
| 13 # Map master name to 'chromite' configuration name. | 13 # Map master name to 'chromite' configuration name. |
| 14 _MASTER_CONFIG_MAP = { | 14 _MASTER_CONFIG_MAP = { |
| 15 'chromiumos.tryserver': { | 15 'chromiumos.tryserver': { |
| 16 'master_config': 'external', | 16 'master_config': 'chromiumos_tryserver', |
| 17 'variants': { | 17 'variants': { |
| 18 'etc': ['chromeos_tryserver_etc'], | 18 'etc': ['chromiumos_tryserver_etc'], |
| 19 }, | 19 }, |
| 20 }, | 20 }, |
| 21 } | 21 } |
| 22 | 22 |
| 23 | 23 |
| 24 # Testing: Tryjob data file JSON. | 24 # Testing: Tryjob data file JSON. |
| 25 _TRYJOB_DATA = """ | 25 _TRYJOB_DATA = """ |
| 26 { | 26 { |
| 27 "name": "12345", | 27 "name": "12345", |
| 28 "email": "testauthor@fake.chromium.org", | 28 "email": "testauthor@fake.chromium.org", |
| 29 "extra_args": [ | 29 "extra_args": [ |
| 30 "--timeout", | 30 "--timeout", |
| 31 "14400", | 31 "14400", |
| 32 "--remote-trybot", | 32 "--remote-trybot", |
| 33 "--remote-version=4" | 33 "--remote-version=4" |
| 34 ] | 34 ] |
| 35 } | 35 } |
| 36 """ | 36 """ |
| 37 | 37 |
| 38 | 38 |
| 39 def RunSteps(api): | 39 def RunSteps(api): |
| 40 # The 'cbuildbot' config name to build is the name of the builder. | 40 # The 'cbuildbot' config name to build is the name of the builder. |
| 41 cbb_config_name = api.properties.get('buildername') | 41 # |
| 42 # TODO(dnj): After we fully switch to BuildBucket scheduling, load the config | |
| 43 # name from the BuildBucket job instead of `cbb_config` build | |
| 44 # property. We can't do this yet b/c the job description can | |
| 45 # specify multiple configs in one tryjob, so there's no way for us | |
| 46 # to know which one we are. | |
| 47 cbb_config_name = api.properties.get('cbb_config') | |
| 48 assert cbb_config_name, "No configuration name specified." | |
| 42 | 49 |
| 43 cbb = cros_chromite.Get() | 50 cbb = cros_chromite.Get() |
| 44 cbb_config = cbb.get(cbb_config_name) | 51 cbb_config = cbb.get(cbb_config_name) |
| 45 | 52 |
| 46 # Apply our generic configuration. | 53 # Apply our generic configuration. |
| 47 api.chromite.configure( | 54 api.chromite.configure( |
| 48 api.properties, | 55 api.properties, |
| 49 _MASTER_CONFIG_MAP) | 56 _MASTER_CONFIG_MAP) |
| 50 api.chromite.c.cbb.config = cbb_config_name | 57 api.chromite.c.cbb.config = cbb_config_name |
| 51 | 58 |
| 52 # Determine our build directory name. | 59 repository = api.properties.get('repository') |
| 53 namebase = cbb_config_name | 60 revision = api.properties.get('revision') |
| 54 if cbb_config: | 61 assert repository, "A repository must be specified." |
| 55 namebase = 'internal' if cbb_config.get('internal') else 'external' | 62 assert revision, "A revision must be specified." |
| 56 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) | 63 assert api.chromite.check_repository('tryjob', repository), ( |
| 64 "Refusing to query unknown tryjob repository: %s" % (repository,)) | |
| 65 # If we are a tryjob, add parameters specified in the description. | |
|
martiniss
2015/09/15 17:58:58
Why does it say "if"? This is a tryjob recipe, cor
dnj
2015/09/15 18:33:27
Copy/pasted comment; fixed/done.
| |
| 66 tryjob_args = api.chromite.load_try_job(repository, revision) | |
| 67 | |
| 68 # Determine our build directory name based on whether this build is internal | |
| 69 # or external. | |
| 70 if not api.chromite.c.cbb.builddir: | |
| 71 namebase = cbb_config_name | |
| 72 if cbb_config: | |
| 73 namebase = 'internal' if cbb_config.get('internal') else 'external' | |
| 74 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) | |
| 57 | 75 |
| 58 # Run our 'cbuildbot'. | 76 # Run our 'cbuildbot'. |
| 59 api.chromite.run_cbuildbot(tryjob=True) | 77 api.chromite.run_cbuildbot(args=tryjob_args) |
| 60 | 78 |
| 61 | 79 |
| 62 def GenTests(api): | 80 def GenTests(api): |
| 63 # Test a CrOS tryjob. | 81 # Test a CrOS tryjob. |
| 64 yield ( | 82 yield ( |
| 65 api.test('basic') | 83 api.test('basic') |
| 66 + api.properties( | 84 + api.properties( |
| 67 mastername='chromiumos.tryserver', | 85 mastername='chromiumos.tryserver', |
| 68 buildername='x86-generic-full', | 86 buildername='full', |
| 69 slavename='test', | 87 slavename='test', |
| 70 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 88 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 71 revision=api.gitiles.make_hash('test'), | 89 revision=api.gitiles.make_hash('test'), |
| 90 cbb_config='x86-generic-full', | |
| 72 ) | 91 ) |
| 73 + api.step_data( | 92 + api.step_data( |
| 74 'Fetch tryjob commit', | 93 'Fetch tryjob commit', |
| 75 api.gitiles.make_commit_test_data( | 94 api.gitiles.make_commit_test_data( |
| 76 'test', | 95 'test', |
| 77 '\n'.join([ | 96 '\n'.join([ |
| 78 'Commit message!', | 97 'Commit message!', |
| 79 ]), | 98 ]), |
| 80 new_files=['user/user.12345'], | 99 new_files=['user/user.12345'], |
| 81 ), | 100 ), |
| 82 ) | 101 ) |
| 83 + api.step_data( | 102 + api.step_data( |
| 84 'Fetch tryjob descriptor (user/user.12345)', | 103 'Fetch tryjob descriptor (user/user.12345)', |
| 85 api.gitiles.make_encoded_file(_TRYJOB_DATA) | 104 api.gitiles.make_encoded_file(_TRYJOB_DATA) |
| 86 ) | 105 ) |
| 87 ) | 106 ) |
| 88 | 107 |
| 89 # Test an 'etc' job (no Chromite config). | 108 # Test an 'etc' job (no Chromite config). |
| 90 yield ( | 109 yield ( |
| 91 api.test('etc') | 110 api.test('etc') |
| 92 + api.properties( | 111 + api.properties( |
| 93 mastername='chromiumos.tryserver', | 112 mastername='chromiumos.tryserver', |
| 94 buildername='etc', | 113 buildername='etc', |
| 95 slavename='test', | 114 slavename='test', |
| 96 cbb_variant='etc', | |
| 97 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 115 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 98 revision=api.gitiles.make_hash('test'), | 116 revision=api.gitiles.make_hash('test'), |
| 117 cbb_config='fakeboard-paladin', | |
| 118 cbb_variant='etc', | |
| 99 ) | 119 ) |
| 100 + api.step_data( | 120 + api.step_data( |
| 101 'Fetch tryjob commit', | 121 'Fetch tryjob commit', |
| 102 api.gitiles.make_commit_test_data( | 122 api.gitiles.make_commit_test_data( |
| 103 'test', | 123 'test', |
| 104 '\n'.join([ | 124 '\n'.join([ |
| 105 'Commit message!', | 125 'Commit message!', |
| 106 ]), | 126 ]), |
| 107 new_files=['user/user.12345'], | 127 new_files=['user/user.12345'], |
| 108 ), | 128 ), |
| 109 ) | 129 ) |
| 110 + api.step_data( | 130 + api.step_data( |
| 111 'Fetch tryjob descriptor (user/user.12345)', | 131 'Fetch tryjob descriptor (user/user.12345)', |
| 112 api.gitiles.make_encoded_file(_TRYJOB_DATA) | 132 api.gitiles.make_encoded_file(_TRYJOB_DATA) |
| 113 ) | 133 ) |
| 114 ) | 134 ) |
| 115 | 135 |
| 116 # Test an invalid CrOS tryjob (no files in commit). | 136 # Test an invalid CrOS tryjob (no files in commit). |
| 117 yield ( | 137 yield ( |
| 118 api.test('basic_no_files_in_commit') | 138 api.test('basic_no_files_in_commit') |
| 119 + api.properties( | 139 + api.properties( |
| 120 mastername='chromiumos.tryserver', | 140 mastername='chromiumos.tryserver', |
| 121 buildername='x86-generic-full', | 141 buildername='full', |
| 122 slavename='test', | 142 slavename='test', |
| 123 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 143 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 124 revision=api.gitiles.make_hash('test'), | 144 revision=api.gitiles.make_hash('test'), |
| 145 cbb_config='x86-generic-full', | |
| 125 ) | 146 ) |
| 126 + api.step_data( | 147 + api.step_data( |
| 127 'Fetch tryjob commit', | 148 'Fetch tryjob commit', |
| 128 api.gitiles.make_commit_test_data( | 149 api.gitiles.make_commit_test_data( |
| 129 'test', | 150 'test', |
| 130 '\n'.join([ | 151 '\n'.join([ |
| 131 'Commit message!', | 152 'Commit message!', |
| 132 ]), | 153 ]), |
| 133 ), | 154 ), |
| 134 ) | 155 ) |
| 135 ) | 156 ) |
| OLD | NEW |