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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# Copyright 2015 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.
DEPS = [
'bot_update',
'gclient',
'git',
'json',
'path',
'properties',
'python',
'tryserver',
]
def _run_presubmit(api, patch_root, bot_update_step):
upstream = bot_update_step.json.output['properties'].get(
api.gclient.c.got_revision_mapping[
'infra/go/src/github.com/luci/luci-go'])
# The presubmit must be run with proper Go environment.
# infra/go/env.py takes care of this.
presubmit_cmd = [
'python', # env.py will replace with this its sys.executable.
api.path['depot_tools'].join('presubmit_support.py'),
'--root', api.path['slave_build'].join(patch_root),
'--commit',
'--verbose', '--verbose',
'--issue', api.properties['issue'],
'--patchset', api.properties['patchset'],
'--skip_canned', 'CheckRietveldTryJobExecution',
'--skip_canned', 'CheckTreeIsOpen',
'--skip_canned', 'CheckBuildbotPendingBuilds',
'--rietveld_url', api.properties['rietveld'],
'--rietveld_fetch',
'--upstream', upstream,
'--trybot-json', api.json.output(),
'--rietveld_email', ''
]
api.python('presubmit', api.path['checkout'].join('go', 'env.py'),
presubmit_cmd, env={'PRESUBMIT_BUILDER': '1'})
def _commit_change(api, patch_root):
api.git('-c', 'user.email=commit-bot@chromium.org',
'-c', 'user.name=The Commit Bot',
'commit', '-a', '-m', 'Committed patch',
name='commit git patch',
cwd=api.path['slave_build'].join(patch_root))
def RunSteps(api):
api.gclient.set_config('luci_go')
# patch_root must match the luci-go repo, not infra checkout.
for path in api.gclient.c.got_revision_mapping:
if 'luci-go' in path:
patch_root = path
break
bot_update_step = api.bot_update.ensure_checkout(force=True,
patch_root=patch_root)
is_presubmit = 'presubmit' in api.properties.get('buildername', '').lower()
if is_presubmit:
_commit_change(api, patch_root)
api.gclient.runhooks()
# This downloads the third parties, so that the next step doesn't have junk
# output in it.
api.python(
'go third parties',
api.path['checkout'].join('go', 'env.py'),
['go', 'version'])
if is_presubmit:
with api.tryserver.set_failure_hash():
_run_presubmit(api, patch_root, bot_update_step)
else:
api.python(
'go build',
api.path['checkout'].join('go', 'env.py'),
['go', 'build', 'github.com/luci/luci-go/...'])
api.python(
'go test',
api.path['checkout'].join('go', 'env.py'),
['go', 'test', 'github.com/luci/luci-go/...'])
def GenTests(api):
yield (
api.test('luci_go') +
api.properties.git_scheduled(
buildername='luci-go-linux64',
buildnumber=123,
mastername='chromium.infra',
repository='https://chromium.googlesource.com/external/github.com/luci/luci-go',
)
)
yield (
api.test('presubmit_try_job') +
api.properties.tryserver(
mastername='tryserver.infra',
buildername='Luci-go Presubmit',
) + api.step_data('presubmit', api.json.output([[]]))
)
|