blob: a5b02fa05862e04398577ba130061cb7286c0c9f [file] [log] [blame]
# Copyright 2020 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 = [
'flutter/monorepo',
'flutter/repo_util',
'recipe_engine/buildbucket',
'recipe_engine/context',
'recipe_engine/file',
'recipe_engine/json',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/raw_io',
]
def RunSteps(api):
flutter_checkout_path = api.path.start_dir / 'flutter'
api.repo_util.get_branch(flutter_checkout_path)
api.repo_util.checkout(
'flutter', flutter_checkout_path, ref='refs/heads/master'
)
api.repo_util.checkout(
'engine', api.path.start_dir / 'engine', ref='refs/heads/main'
)
api.repo_util.checkout(
'cocoon', api.path.start_dir / 'cocoon', ref='refs/heads/main'
)
api.repo_util.checkout(
'packages', api.path.start_dir / 'packages', ref='refs/heads/main'
)
# we need an override because all of the previous step calls on checkout directly overrides the ref variable
api.repo_util.checkout(
'flutter', flutter_checkout_path, ref='refs/heads/beta'
)
api.repo_util.get_env_ref()
env, env_paths = api.repo_util.engine_environment(flutter_checkout_path)
env, env_paths = api.repo_util.monorepo_environment(flutter_checkout_path)
env, env_paths = api.repo_util.flutter_environment(flutter_checkout_path)
api.repo_util.in_release_and_main(flutter_checkout_path)
checkout_path = api.path.start_dir
if api.monorepo.is_monorepo_ci_build or api.monorepo.is_monorepo_try_build:
api.file.ensure_directory('ensure directory', checkout_path)
api.repo_util.monorepo_checkout(checkout_path, {}, {})
else:
api.file.ensure_directory('ensure directory', checkout_path / 'engine')
api.repo_util.engine_checkout(checkout_path / 'engine', {}, {})
with api.context(env=env, env_prefixes=env_paths):
api.repo_util.sdk_checkout_path()
api.repo_util.get_build(api.path.start_dir)
method = api.properties.get('method', '')
if method == 'get_content_hash':
expected = api.properties.get('expectation', None)
actual = api.repo_util.content_hash()
assert expected is not None and actual == expected, "'%s' did not match expected ('%s') content_hash" % (
actual, expected
)
if method == 'get_content_hash_url':
content_hash = api.repo_util.content_hash()
original = api.properties.get('original')
actual = api.repo_util.get_content_hash_url(api, original, content_hash)
expected = api.properties.get('expectation', None)
assert expected is not None and actual == expected, "'%s' did not match expected ('%s') from '%s' original get_content_hash_url" % (
actual, expected, original
)
if method == 'get_content_hash_url-monorepo':
if api.monorepo.is_monorepo_ci_build or api.monorepo.is_monorepo_try_build:
actual = api.repo_util.get_content_hash_url(api, '', '1' * 40)
assert actual is None, "monorepo-hh does not support get_content_hash_url"
def GenTests(api):
yield api.test(
'mac',
api.properties(
git_branch='beta',
gn_artifacts='true',
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head',
clobber=True,
config_name='build_config.json',
package_sharding='shard1',
channel='stable',
env_variables={"key1": "value1"}
),
api.repo_util.flutter_environment_data(),
api.platform('mac', 64),
)
yield api.test(
'win',
api.properties(
git_branch='beta',
gn_artifacts='true',
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head',
clobber=True,
config_name='build_config.json',
package_sharding='shard1',
channel='stable',
),
api.repo_util.flutter_environment_data(),
api.platform.name('win'),
)
yield api.test(
'failed_flutter_environment',
api.properties(
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head'
),
status='FAILURE'
)
yield api.test(
'monorepo_release',
api.repo_util.flutter_environment_data(),
api.properties(
git_branch='beta',
clobber=True,
config_name='build_config.json',
),
api.monorepo.ci_build(git_ref='refs/heads/beta'),
api.platform('mac', 64),
)
yield api.test(
'monorepo',
api.repo_util.flutter_environment_data(),
api.properties(config_name='build_config.json',),
api.monorepo.ci_build(),
)
yield api.test(
'monorepo_tryjob',
api.repo_util.flutter_environment_data(),
api.properties(
clobber=True,
config_name='build_config.json',
),
api.monorepo.try_build(),
)
yield api.test(
'monorepo_wrong_host',
api.repo_util.flutter_environment_data(),
api.buildbucket.ci_build(
git_repo='https://not-dart.googlesource.com/monorepo',
git_ref='refs/heads/main'
),
api.expect_exception('ValueError'),
)
yield api.test(
'monorepo_first_bot_update_failed',
api.repo_util.flutter_environment_data(),
api.properties(
clobber=True,
config_name='build_config.json',
),
api.monorepo.ci_build(),
# Next line force a fail condition for the bot update
# first execution.
api.step_data("Checkout source code.bot_update", retcode=1),
)
yield api.test(
'bot_update',
api.properties(
config_name='build_config.json',
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head',
),
api.repo_util.flutter_environment_data(),
)
yield api.test(
'first_bot_update_failed',
api.properties(
config_name='build_config.json',
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head'
),
# Next line force a fail condition for the bot update
# first execution.
api.step_data("Checkout source code.bot_update", retcode=1),
api.repo_util.flutter_environment_data(),
)
yield api.test(
'first_bot_update_revision_not_found',
api.properties(
config_name='build_config.json',
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head'
),
# Next line force a fail condition for the bot update
# first execution.
api.path.exists(
api.path.cache_dir / 'git', api.path.start_dir / 'engine',
*api.repo_util.flutter_environment_path()
),
api.step_data(
"Checkout source code.bot_update",
api.json.output({
'properties': {
'got_revision': 'BOT_UPDATE_NO_REV_FOUND'
},
# Mandatory properties required to make bot_update work.
'did_run': True,
'root': 'src/flutter',
'patch_root': None,
})
),
)
yield api.test(
'fusion',
api.properties(
config_name='build_config.json',
is_fusion=True,
flutter_realm='foo-realm',
flutter_prebuilt_engine_version='sha1234',
),
api.repo_util.flutter_environment_data(),
)
yield api.test(
'content_hash',
api.properties(
method='get_content_hash',
config_name='build_config.json',
is_fusion=True,
flutter_realm='foo-realm',
flutter_prebuilt_engine_version='sha1234',
content_hash="CONTENT_HASH",
expectation="CONTENT_HASH",
),
api.repo_util.flutter_environment_data(),
api.step_data('Read build config file'),
)
yield api.test(
'get_content_hash_url',
api.properties(
method='get_content_hash_url',
config_name='build_config.json',
is_fusion=True,
flutter_realm='foo-realm',
flutter_prebuilt_engine_version='sha1234',
content_hash='56a17204be67e733f009facc7b77e721181a630a',
original='gs://flutter/foo/00a57d1a04dd1b248ebd8c980aae8034bbd7dfd1/bar.zip',
expectation='gs://flutter/foo/56a17204be67e733f009facc7b77e721181a630a/bar.zip',
),
api.repo_util.flutter_environment_data(),
)
yield api.test(
'get_content_hash_url-android',
api.properties(
method='get_content_hash_url',
config_name='build_config.json',
is_fusion=True,
flutter_realm='foo-realm',
flutter_prebuilt_engine_version='sha1234',
content_hash='56a17204be67e733f009facc7b77e721181a630a',
original='gs://download.flutter.io/io/flutter/x86_debug/1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584/x86_debug-1.0.0-0005149dca9b248663adcde4bdd7c6c915a76584.jar',
expectation='gs://download.flutter.io/io/flutter/x86_debug/1.0.0-56a17204be67e733f009facc7b77e721181a630a/x86_debug-1.0.0-56a17204be67e733f009facc7b77e721181a630a.jar',
),
api.repo_util.flutter_environment_data(),
)
yield api.test(
'get_content_hash_url-bad-url',
api.properties(
method='get_content_hash_url',
config_name='build_config.json',
is_fusion=True,
flutter_realm='foo-realm',
content_hash='56a17204be67e733f009facc7b77e721181a630a',
original='gs://flutter/foo/bad-url/bar.zip',
flutter_prebuilt_engine_version='sha1234',
),
api.expect_exception('AssertionError'),
api.repo_util.flutter_environment_data(),
)
yield api.test(
'get_content_hash_url-monorepo',
api.properties(
method='get_content_hash_url-monorepo',
config_name='build_config.json',
is_fusion=True,
flutter_realm='foo-realm',
),
api.repo_util.flutter_environment_data(),
api.monorepo.ci_build(),
)
yield api.test(
'release_branch_git_clean_failed',
api.properties(
config_name='build_config.json',
git_branch='beta',
git_url='https://github.com/flutter/engine',
git_ref='refs/pull/1/head'
),
# Force a failure of the git clean command.
api.step_data(
'Clean the builder cache.gclient git clean all repos', retcode=1
),
api.repo_util.flutter_environment_data(),
)