blob: b298caedc404a9d306ae9d31f081361408384ff8 [file] [log] [blame]
PYTHON_VERSION_COMPATIBILITY = "PY3"
# Reference: https://chromium.googlesource.com/infra/luci/recipes-py/+/HEAD/doc/
# All the deps get combined into an `api` variable passed in to RunSteps and
# GenTests. Versions and urls are specified in `recipes.cfg`.
DEPS = [
'depot_tools/bot_update',
'depot_tools/gclient',
'recipe_engine/buildbucket',
'recipe_engine/context',
'recipe_engine/path',
'recipe_engine/step',
'recipe_engine/nodejs',
]
# Check out the change and run the tests to verify the change as part of Change
# Verification (ie. CQ label).
def RunSteps(api):
cl = api.buildbucket.build.input.gerrit_changes[0]
# Remove "-review" part of host URL
host = cl.host
gs_suffix = '-review.googlesource.com'
if host.endswith(gs_suffix):
host = '%s.googlesource.com' % host[:-len(gs_suffix)]
gclient_config = api.gclient.make_config()
s = gclient_config.solutions.add()
s.url = 'https://%s/%s' % (host, cl.project)
# This is the name of the subfolder under api.path['cache'].join('builder')
# where the repo will be checked out at.
s.name = 'src'
gclient_config.got_revision_mapping[s.name] = 'got_revision'
# Check out the code for the change, this is by default cached between builds
# for the same builder.
with api.context(cwd=api.path['cache'].join('builder')):
update_result = api.bot_update.ensure_checkout(
gclient_config=gclient_config)
api.step.raise_on_failure(update_result)
# Now in the checked out code directory run our verification.
with api.context(cwd=api.path['cache'].join('builder').join(s.name)):
# Current LTS for Node.js
with api.nodejs(version='18.11.0'):
# Named steps to test the change
api.step('install deps', ['npm', 'install'])
api.step('run tests', ['npm', 'run', 'test'])
# Test the recipe and generate the expect json file.
def GenTests(api):
yield api.test(
'basic',
# Execute RunSteps with test data
api.buildbucket.try_build(
project="gerrit",
git_repo="https://gerrit.googlesource.com/luci-test",
),
)