| # Copyright 2023 The Dart 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 import post_process |
| |
| DEPS = [ |
| 'dart', |
| 'depot_tools/bot_update', |
| 'depot_tools/gclient', |
| 'depot_tools/git', |
| 'depot_tools/gsutil', |
| 'recipe_engine/buildbucket', |
| 'recipe_engine/context', |
| 'recipe_engine/path', |
| 'recipe_engine/runtime', |
| 'recipe_engine/step', |
| ] |
| |
| PYTHON_VERSION_COMPATIBILITY = 'PY3' |
| |
| |
| def RunSteps(api): |
| if api.buildbucket.builder_name.endswith('-try'): |
| api.gclient.c = api.gclient.make_config() |
| soln = api.gclient.c.solutions.add() |
| soln.name = 'homebrew-dart' |
| soln.url = 'https://dart.googlesource.com/homebrew-dart' |
| soln.managed = False |
| api.bot_update.ensure_checkout() |
| else: |
| api.git.checkout( |
| url='https://dart.googlesource.com/homebrew-dart', |
| ref='refs/heads/main') |
| with api.context(cwd=api.path['checkout']): |
| api.git('config', 'user.name', 'Dart CI', name='configure user.name') |
| api.git( |
| 'config', |
| 'user.email', |
| api.buildbucket.swarming_task_service_account, |
| name='configure user.email') |
| dart = api.dart.download_dart_sdk(api.path['checkout'].join('pubspec.yaml')) |
| api.step('pub get', [dart, 'pub', 'get']) |
| api.step('bin/update_homebrew.dart', [dart, 'bin/update_homebrew.dart']) |
| if (not api.runtime.is_experimental and |
| not api.buildbucket.builder_name.endswith('-try')): |
| api.git('push', 'origin', 'HEAD:refs/heads/main') |
| |
| |
| def GenTests(api): |
| build = api.buildbucket.ci_build_message( |
| project='homebrew-dart', |
| builder='homebrew', |
| git_repo='https://dart.googlesource.com/homebrew-dart', |
| git_ref='refs/heads/main', |
| revision='18df0aae67183931b1b6d5d12cc04d89f7137919') |
| api.buildbucket.update_backend_service_account(build, 'service@example.com') |
| try_build = api.buildbucket.ci_build_message( |
| project='homebrew-dart', |
| builder='homebrew-try', |
| git_repo='https://dart.googlesource.com/homebrew-dart', |
| git_ref='refs/heads/main', |
| revision='18df0aae67183931b1b6d5d12cc04d89f7137919') |
| api.buildbucket.update_backend_service_account(try_build, |
| 'service@example.com') |
| yield api.test( |
| 'update', |
| api.buildbucket.build(build), |
| api.post_process(post_process.StatusSuccess), |
| ) |
| yield api.test( |
| 'try', |
| api.buildbucket.build(try_build), |
| api.post_process(post_process.StatusSuccess), |
| api.post_process(post_process.DropExpectation), |
| ) |
| yield api.test( |
| 'dry', |
| api.runtime(is_experimental=True), |
| api.buildbucket.build(build), |
| api.post_process(post_process.StatusSuccess), |
| api.post_process(post_process.DoesNotRunRE, 'git push'), |
| ) |