blob: e132c7cb3f28e714b6814b02bb883459e02e7e57 [file] [log] [blame]
# 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.
from recipe_engine.recipe_api import Property
DEPS = [
'depot_tools/osx_sdk',
'infra_checkout',
'recipe_engine/buildbucket',
'recipe_engine/context',
'recipe_engine/json',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/step',
]
PROPERTIES = {
'GOARCH': Property(
default=None,
kind=str,
help='Set GOARCH environment variable for go build+test'),
'go_version_variant': Property(
default=None,
kind=str,
help='A go version variant to bootstrap, see bootstrap.py'),
'run_integration_tests': Property(
default=False,
kind=bool,
help='Whether to run integration tests'),
}
LUCI_GO_PATH_IN_INFRA = 'infra/go/src/go.chromium.org/luci'
def RunSteps(api, GOARCH, go_version_variant, run_integration_tests):
co = api.infra_checkout.checkout(
'luci_go',
patch_root=LUCI_GO_PATH_IN_INFRA,
go_version_variant=go_version_variant)
is_presubmit = 'presubmit' in api.buildbucket.builder_name.lower()
if is_presubmit:
co.commit_change()
co.gclient_runhooks()
env = {}
if GOARCH is not None:
env['GOARCH'] = GOARCH
if run_integration_tests:
env['INTEGRATION_TESTS'] = '1'
with api.context(env=env), api.osx_sdk('mac'), co.go_env():
if is_presubmit:
co.run_presubmit()
else:
api.step('go build', ['go', 'build', 'go.chromium.org/luci/...'])
api.step('go test', ['go', 'test', 'go.chromium.org/luci/...'])
if not api.platform.is_win:
# Windows bots do not have gcc installed at the moment.
api.step('go test -race', [
'go', 'test', '-race', 'go.chromium.org/luci/...',
])
def GenTests(api):
for plat in ('linux', 'mac', 'win'):
yield (
api.test('luci_go_%s' % plat) +
api.platform(plat, 64) +
api.buildbucket.ci_build(
'infra', 'ci', 'luci-gae-trusty-64',
git_repo="https://chromium.googlesource.com/infra/infra",
revision='1'*40) +
# Sadly, hacks in gclient required to patch non-main git repo in
# a solution requires revision as a property :(
api.properties(revision='1'*40)
)
yield (
api.test('presubmit_try_job') +
api.buildbucket.try_build(
'infra', 'try', 'Luci-go Presubmit', change_number=607472, patch_set=2,
) + api.step_data('presubmit', api.json.output([[]]))
)
yield (
api.test('override_GOARCH') +
api.platform('linux', 64) +
api.buildbucket.try_build(
'infra', 'try', 'luci-go-trusty-64',
git_repo='https://chromium.googlesource.com/infra/luci/luci-go',
change_number=607472,
patch_set=2,
) + api.properties(GOARCH='386')
)
yield (
api.test('integration_tests') +
api.buildbucket.try_build(
'infra', 'try', 'integration_tests', change_number=607472, patch_set=2,
) +
api.properties(run_integration_tests=True)
)
yield (
api.test('override_go_version') +
api.platform('linux', 64) +
api.buildbucket.try_build(
'infra', 'try', 'luci-go-trusty-64',
git_repo='https://chromium.googlesource.com/infra/luci/luci-go',
change_number=607472,
patch_set=2,
) + api.properties(go_version_variant='bleeding_edge')
)