OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 DEPS = [ | 5 DEPS = [ |
6 'bot_update', | 6 'bot_update', |
7 'gclient', | 7 'gclient', |
| 8 'git', |
| 9 'json', |
8 'path', | 10 'path', |
9 'properties', | 11 'properties', |
10 'python', | 12 'python', |
11 'tryserver', | 13 'tryserver', |
12 ] | 14 ] |
13 | 15 |
14 | 16 |
| 17 def _run_presubmit(api, patch_root, bot_update_step): |
| 18 upstream = bot_update_step.json.output['properties'].get( |
| 19 api.gclient.c.got_revision_mapping[ |
| 20 'infra/go/src/github.com/luci/gae']) |
| 21 # The presubmit must be run with proper Go environment. |
| 22 # infra/go/env.py takes care of this. |
| 23 presubmit_cmd = [ |
| 24 'python', # env.py will replace with this its sys.executable. |
| 25 api.path['depot_tools'].join('presubmit_support.py'), |
| 26 '--root', api.path['slave_build'].join(patch_root), |
| 27 '--commit', |
| 28 '--verbose', '--verbose', |
| 29 '--issue', api.properties['issue'], |
| 30 '--patchset', api.properties['patchset'], |
| 31 '--skip_canned', 'CheckRietveldTryJobExecution', |
| 32 '--skip_canned', 'CheckTreeIsOpen', |
| 33 '--skip_canned', 'CheckBuildbotPendingBuilds', |
| 34 '--rietveld_url', api.properties['rietveld'], |
| 35 '--rietveld_fetch', |
| 36 '--upstream', upstream, |
| 37 '--trybot-json', api.json.output(), |
| 38 '--rietveld_email', '' |
| 39 ] |
| 40 api.python('presubmit', api.path['checkout'].join('go', 'env.py'), |
| 41 presubmit_cmd, env={'PRESUBMIT_BUILDER': '1'}) |
| 42 |
| 43 |
| 44 def _commit_change(api, patch_root): |
| 45 api.git('-c', 'user.email=commit-bot@chromium.org', |
| 46 '-c', 'user.name=The Commit Bot', |
| 47 'commit', '-a', '-m', 'Committed patch', |
| 48 name='commit git patch', |
| 49 cwd=api.path['slave_build'].join(patch_root)) |
| 50 |
| 51 |
15 def RunSteps(api): | 52 def RunSteps(api): |
16 api.gclient.set_config('luci_gae') | 53 api.gclient.set_config('luci_gae') |
17 # patch_root must match the luci/gae repo, not infra checkout. | 54 # patch_root must match the luci/gae repo, not infra checkout. |
18 for path in api.gclient.c.got_revision_mapping: | 55 for path in api.gclient.c.got_revision_mapping: |
19 if 'github.com/luci/gae' in path: | 56 if 'github.com/luci/gae' in path: |
20 patch_root = path | 57 patch_root = path |
21 break | 58 break |
22 api.bot_update.ensure_checkout(force=True, patch_root=patch_root) | 59 bot_update_step = api.bot_update.ensure_checkout(force=True, |
| 60 patch_root=patch_root) |
| 61 |
| 62 is_presubmit = 'presubmit' in api.properties.get('buildername', '').lower() |
| 63 if is_presubmit: |
| 64 _commit_change(api, patch_root) |
23 api.gclient.runhooks() | 65 api.gclient.runhooks() |
24 | 66 |
25 # This downloads the third parties, so that the next step doesn't have junk | 67 # This downloads the third parties, so that the next step doesn't have junk |
26 # output in it. | 68 # output in it. |
27 api.python( | 69 api.python( |
28 'go third parties', | 70 'go third parties', |
29 api.path['checkout'].join('go', 'env.py'), | 71 api.path['checkout'].join('go', 'env.py'), |
30 ['go', 'version']) | 72 ['go', 'version']) |
31 | 73 |
32 api.python( | 74 if is_presubmit: |
33 'go build', | 75 with api.tryserver.set_failure_hash(): |
34 api.path['checkout'].join('go', 'env.py'), | 76 _run_presubmit(api, patch_root, bot_update_step) |
35 ['go', 'build', 'github.com/luci/gae/...']) | 77 else: |
| 78 api.python( |
| 79 'go build', |
| 80 api.path['checkout'].join('go', 'env.py'), |
| 81 ['go', 'build', 'github.com/luci/gae/...']) |
36 | 82 |
37 api.python( | 83 api.python( |
38 'go test', | 84 'go test', |
39 api.path['checkout'].join('go', 'env.py'), | 85 api.path['checkout'].join('go', 'env.py'), |
40 ['go', 'test', 'github.com/luci/gae/...']) | 86 ['go', 'test', 'github.com/luci/gae/...']) |
41 | 87 |
42 | 88 |
43 def GenTests(api): | 89 def GenTests(api): |
44 yield ( | 90 yield ( |
45 api.test('luci_gae') + | 91 api.test('luci_gae') + |
46 api.properties.git_scheduled( | 92 api.properties.git_scheduled( |
47 buildername='luci-gae-linux64', | 93 buildername='luci-gae-linux64', |
48 buildnumber=123, | |
49 mastername='chromium.infra', | 94 mastername='chromium.infra', |
50 repository='https://chromium.googlesource.com/external/github.com/luci/g
ae', | 95 repository='https://chromium.googlesource.com/external/github.com/luci/g
ae', |
51 ) | 96 ) |
52 ) | 97 ) |
| 98 yield ( |
| 99 api.test('presubmit_try_job') + |
| 100 api.properties.tryserver( |
| 101 mastername='tryserver.infra', |
| 102 buildername='Luci-GAE Presubmit', |
| 103 ) + api.step_data('presubmit', api.json.output([[]])) |
| 104 ) |
OLD | NEW |